From: Peter Eisentraut Date: Thu, 12 Sep 2019 18:47:21 +0000 (+0200) Subject: Fix some compiler warnings on Windows 64-bit X-Git-Tag: pgbouncer_1_12_0~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=817ba0efe126ab169de94b6816b4b072c67aa35d;p=pgbouncer Fix some compiler warnings on Windows 64-bit For event_set() callbacks, use evutil_socket_t instead of int as the first argument. This is required for 64-bit Windows; on all other platforms, the two types are the same. This requires libevent version 2. Note that the rest of the socket code still uses int everywhere, so Windows 64-bit is still probably not going to work correctly. --- diff --git a/include/sbuf.h b/include/sbuf.h index 5e5c1c1..1e28357 100644 --- a/include/sbuf.h +++ b/include/sbuf.h @@ -54,7 +54,7 @@ typedef bool (*sbuf_cb_t)(SBuf *sbuf, struct MBuf *mbuf); /* for some reason, libevent has no typedef for callback */ -typedef void (*sbuf_libevent_cb)(int, short, void *); +typedef void (*sbuf_libevent_cb)(evutil_socket_t, short, void *); struct SBufIO { int (*sbufio_recv)(SBuf *sbuf, void *buf, unsigned int len); diff --git a/src/dnslookup.c b/src/dnslookup.c index 9282362..7612e2e 100644 --- a/src/dnslookup.c +++ b/src/dnslookup.c @@ -1464,7 +1464,7 @@ static void zone_register(struct DNSContext *ctx, struct DNSRequest *req) req->zone = z; } -static void zone_timer(int fd, short flg, void *arg) +static void zone_timer(evutil_socket_t fd, short flg, void *arg) { struct DNSContext *ctx = arg; struct List *el; diff --git a/src/janitor.c b/src/janitor.c index 7e5b612..0fc6c2f 100644 --- a/src/janitor.c +++ b/src/janitor.c @@ -606,7 +606,7 @@ static void cleanup_inactive_autodatabases(void) } /* full-scale maintenance, done only occasionally */ -static void do_full_maint(int sock, short flags, void *arg) +static void do_full_maint(evutil_socket_t sock, short flags, void *arg) { struct List *item, *tmp; PgPool *pool; diff --git a/src/main.c b/src/main.c index aa77551..2164749 100644 --- a/src/main.c +++ b/src/main.c @@ -419,14 +419,14 @@ void load_config(void) static struct event ev_sigterm; static struct event ev_sigint; -static void handle_sigterm(int sock, short flags, void *arg) +static void handle_sigterm(evutil_socket_t sock, short flags, void *arg) { log_info("got SIGTERM, fast exit"); /* pidfile cleanup happens via atexit() */ exit(1); } -static void handle_sigint(int sock, short flags, void *arg) +static void handle_sigint(evutil_socket_t sock, short flags, void *arg) { log_info("got SIGINT, shutting down"); if (cf_reboot) diff --git a/src/pktbuf.c b/src/pktbuf.c index 722f8b4..8112585 100644 --- a/src/pktbuf.c +++ b/src/pktbuf.c @@ -116,13 +116,13 @@ bool pktbuf_send_immediate(PktBuf *buf, PgSocket *sk) return res == amount; } -static void pktbuf_send_func(int fd, short flags, void *arg) +static void pktbuf_send_func(evutil_socket_t fd, short flags, void *arg) { PktBuf *buf = arg; SBuf *sbuf = &buf->queued_dst->sbuf; int amount, res; - log_debug("pktbuf_send_func(%d, %d, %p)", fd, (int)flags, buf); + log_debug("pktbuf_send_func(%" PRId64 ", %d, %p)", (int64_t)fd, (int)flags, buf); if (buf->failed) return; diff --git a/src/pooler.c b/src/pooler.c index 277d0f2..1a74cff 100644 --- a/src/pooler.c +++ b/src/pooler.c @@ -244,7 +244,7 @@ void pooler_tune_accept(bool on) } } -static void err_wait_func(int sock, short flags, void *arg) +static void err_wait_func(evutil_socket_t sock, short flags, void *arg) { if (cf_pause_mode != P_SUSPEND) resume_pooler(); @@ -275,7 +275,7 @@ static const char *conninfo(const PgSocket *sk) } /* got new connection, associate it with client struct */ -static void pool_accept(int sock, short flags, void *arg) +static void pool_accept(evutil_socket_t sock, short flags, void *arg) { struct ListenSocket *ls = arg; int fd; diff --git a/src/sbuf.c b/src/sbuf.c index 25ea4b8..fdc7862 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -67,9 +67,9 @@ enum WaitType { static bool sbuf_queue_send(SBuf *sbuf) _MUSTCHECK; static bool sbuf_send_pending(SBuf *sbuf) _MUSTCHECK; static bool sbuf_process_pending(SBuf *sbuf) _MUSTCHECK; -static void sbuf_connect_cb(int sock, short flags, void *arg); -static void sbuf_recv_cb(int sock, short flags, void *arg); -static void sbuf_send_cb(int sock, short flags, void *arg); +static void sbuf_connect_cb(evutil_socket_t sock, short flags, void *arg); +static void sbuf_recv_cb(evutil_socket_t sock, short flags, void *arg); +static void sbuf_send_cb(evutil_socket_t sock, short flags, void *arg); static void sbuf_try_resync(SBuf *sbuf, bool release); static bool sbuf_wait_for_data(SBuf *sbuf) _MUSTCHECK; static void sbuf_main_loop(SBuf *sbuf, bool skip_recv); @@ -98,7 +98,7 @@ static const SBufIO tls_sbufio_ops = { tls_sbufio_send, tls_sbufio_close }; -static void sbuf_tls_handshake_cb(int fd, short flags, void *_sbuf); +static void sbuf_tls_handshake_cb(evutil_socket_t fd, short flags, void *_sbuf); #endif /********************************* @@ -407,7 +407,7 @@ static bool sbuf_wait_for_data(SBuf *sbuf) return true; } -static void sbuf_recv_forced_cb(int sock, short flags, void *arg) +static void sbuf_recv_forced_cb(evutil_socket_t sock, short flags, void *arg) { SBuf *sbuf = arg; @@ -444,7 +444,7 @@ static bool sbuf_wait_for_data_forced(SBuf *sbuf) } /* libevent EV_WRITE: called when dest socket is writable again */ -static void sbuf_send_cb(int sock, short flags, void *arg) +static void sbuf_send_cb(evutil_socket_t sock, short flags, void *arg) { SBuf *sbuf = arg; bool res; @@ -661,7 +661,7 @@ static bool sbuf_actual_recv(SBuf *sbuf, unsigned len) } /* callback for libevent EV_READ */ -static void sbuf_recv_cb(int sock, short flags, void *arg) +static void sbuf_recv_cb(evutil_socket_t sock, short flags, void *arg) { SBuf *sbuf = arg; sbuf_main_loop(sbuf, DO_RECV); @@ -794,7 +794,7 @@ static bool sbuf_after_connect_check(SBuf *sbuf) } /* callback for libevent EV_WRITE when connecting */ -static void sbuf_connect_cb(int sock, short flags, void *arg) +static void sbuf_connect_cb(evutil_socket_t sock, short flags, void *arg) { SBuf *sbuf = arg; @@ -1010,7 +1010,7 @@ static bool handle_tls_handshake(SBuf *sbuf) } } -static void sbuf_tls_handshake_cb(int fd, short flags, void *_sbuf) +static void sbuf_tls_handshake_cb(evutil_socket_t fd, short flags, void *_sbuf) { SBuf *sbuf = _sbuf; sbuf->wait_type = W_NONE; diff --git a/src/stats.c b/src/stats.c index a02252c..9a5b697 100644 --- a/src/stats.c +++ b/src/stats.c @@ -331,7 +331,7 @@ bool show_stat_totals(PgSocket *client, struct StatList *pool_list) return true; } -static void refresh_stats(int s, short flags, void *arg) +static void refresh_stats(evutil_socket_t s, short flags, void *arg) { struct List *item; PgPool *pool; diff --git a/src/takeover.c b/src/takeover.c index 0e7ebe6..feb6483 100644 --- a/src/takeover.c +++ b/src/takeover.c @@ -286,7 +286,7 @@ static void takeover_parse_data(PgSocket *bouncer, * * use always recvmsg, to keep code simpler */ -static void takeover_recv_cb(int sock, short flags, void *arg) +static void takeover_recv_cb(evutil_socket_t sock, short flags, void *arg) { PgSocket *bouncer = container_of(arg, PgSocket, sbuf); uint8_t data_buf[STARTUP_BUF * 2];