]> granicus.if.org Git - pgbouncer/commitdiff
Fix some compiler warnings on Windows 64-bit
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 12 Sep 2019 18:47:21 +0000 (20:47 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 12 Sep 2019 18:47:21 +0000 (20:47 +0200)
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.

include/sbuf.h
src/dnslookup.c
src/janitor.c
src/main.c
src/pktbuf.c
src/pooler.c
src/sbuf.c
src/stats.c
src/takeover.c

index 5e5c1c1f26989162d3515a10ae59bf2a5141671a..1e283573108f85f31e85aaad07c0b0e7398583e8 100644 (file)
@@ -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);
index 9282362c0da3dc1d27ca86fa7bbd0574b038ba55..7612e2ef8a136aaf0e36d82d511ef9c07c0f5205 100644 (file)
@@ -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;
index 7e5b612c45a440cfda53e36e661531ea8fe8a960..0fc6c2f9712076102fe60d80744e637a3adae2ec 100644 (file)
@@ -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;
index aa77551f256cfcd306a0adf1c9a0f6339c967d37..21647496b97a60e59bcc7f8e849782c5bb181d02 100644 (file)
@@ -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)
index 722f8b431ad5f47c0f8e5354452ce2c6ebd5cdd1..81125855237b5cf80f3542f78c4696d4e4c2dad9 100644 (file)
@@ -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;
index 277d0f216624924bac9fce6ea69ede5cb2a422e4..1a74cff7943cf974f18ea04b8136d0d9beb03d4a 100644 (file)
@@ -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;
index 25ea4b8c46230af5d384386330a64813a52a44df..fdc78620358ea8ab7c6945e14c64582b3cb1de2d 100644 (file)
@@ -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;
index a02252cda2b684bc44fb94aee9fe580b4362a507..9a5b697acbf7e8c028e0f4a41aca92e3f0aa3ef9 100644 (file)
@@ -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;
index 0e7ebe6a53a37a3bf82f020343b6466e9e5cf993..feb648330f028757b00960b40e91f6dc19c2f3d0 100644 (file)
@@ -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];