Skip to content

Commit

Permalink
Use correct signature for event_callback_fn (libevent) in tests
Browse files Browse the repository at this point in the history
Use the correct libevent2 type `evutil_socket_t` instead of `int`
when implementing the libevent2 callback function in our tests.
On Windows evutil_socket_t is an intptr_t (long long int).

Defined in include/event2/event.h:
typedef void(*  event_callback_fn )(evutil_socket_t, short, void *)

Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Aug 13, 2024
1 parent 6fd71f3 commit 72dfb21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ void async_disconnect(valkeyAsyncContext *ac) {
}

/* Testcase timeout, will trigger a failure */
void timeout_cb(int fd, short event, void *arg) {
void timeout_cb(evutil_socket_t fd, short event, void *arg) {
(void) fd; (void) event; (void) arg;
printf("Timeout in async testing!\n");
exit(1);
Expand Down
4 changes: 2 additions & 2 deletions tests/clusterclient_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int num_running = 0;
int resend_failed_cmd = 0;
int send_to_all = 0;

void sendNextCommand(int, short, void *);
void sendNextCommand(evutil_socket_t, short, void *);

void printReply(const valkeyReply *reply) {
switch (reply->type) {
Expand Down Expand Up @@ -102,7 +102,7 @@ void replyCallback(valkeyClusterAsyncContext *acc, void *r, void *privdata) {
}
}

void sendNextCommand(int fd, short kind, void *arg) {
void sendNextCommand(evutil_socket_t fd, short kind, void *arg) {
UNUSED(fd);
UNUSED(kind);
valkeyClusterAsyncContext *acc = arg;
Expand Down
4 changes: 2 additions & 2 deletions tests/clusterclient_reconnect_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* Unfortunately there is no error code for this error to match */
#define VALKEY_ENOCLUSTER "ERR This instance has cluster support disabled"

void sendNextCommand(int, short, void *);
void sendNextCommand(evutil_socket_t, short, void *);

void connectToValkey(valkeyClusterAsyncContext *acc) {
/* reset context in case of reconnect */
Expand Down Expand Up @@ -61,7 +61,7 @@ void replyCallback(valkeyClusterAsyncContext *acc, void *r, void *privdata) {
event_base_once(acc->adapter, -1, EV_TIMEOUT, sendNextCommand, acc, NULL);
}

void sendNextCommand(int fd, short kind, void *arg) {
void sendNextCommand(evutil_socket_t fd, short kind, void *arg) {
UNUSED(fd);
UNUSED(kind);
valkeyClusterAsyncContext *acc = arg;
Expand Down

0 comments on commit 72dfb21

Please sign in to comment.