]> granicus.if.org Git - libevent/commitdiff
Export an ev_socklen_t.
authorNick Mathewson <nickm@torproject.org>
Thu, 30 Jul 2009 17:01:21 +0000 (17:01 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 30 Jul 2009 17:01:21 +0000 (17:01 +0000)
svn:r1391

ChangeLog
evdns.c
evutil.c
http.c
include/event2/util.h

index 1566120ea8fda3e685b40c7b796a9ab623d6ae2a..8a27e2a8578dd81e7c2ac7f6b3753d476b90f7b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ Changes in 2.0.3-alpha:
  o Export new evutil_ascii_* functions to perform locale-independent character type operations.
  o Try to compile better with MSVC: patches from Brodie Thiesfield
  o New evconnlistener_get_fd function to expose a listener's associated socket.
+ o Expose an ev_socklen_t type for consistent use across platforms.
 
 Changes in 2.0.2-alpha:
  o Add a new flag to bufferevents to make all callbacks automatically deferred.
diff --git a/evdns.c b/evdns.c
index 98d51424c65e80e0c397fc117a78e68f49b51c84..c997d56e07cfce559e7d35cc67b522528a496bb3 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -222,7 +222,7 @@ struct reply {
 struct nameserver {
        evutil_socket_t socket;  /* a connected UDP socket */
        struct sockaddr_storage address;
-       socklen_t addrlen;
+       ev_socklen_t addrlen;
        int failed_times;  /* number of times which we have given this server a chance */
        int timedout;  /* number of times in a row a request has timed out */
        struct event event;
@@ -284,7 +284,7 @@ struct server_request {
        u16 trans_id; /* Transaction id. */
        struct evdns_server_port *port; /* Which port received this request on? */
        struct sockaddr_storage addr; /* Where to send the response */
-       socklen_t addrlen; /* length of addr */
+       ev_socklen_t addrlen; /* length of addr */
 
        int n_answer; /* how many answer RRs have been set? */
        int n_authority; /* how many authority RRs have been set? */
@@ -339,8 +339,8 @@ struct evdns_base {
 
        /** Port to bind to for outgoing DNS packets. */
        struct sockaddr_storage global_outgoing_address;
-       /** Socklen_t for global_outgoing_address. 0 if it isn't set. */
-       socklen_t global_outgoing_addrlen;
+       /** ev_socklen_t for global_outgoing_address. 0 if it isn't set. */
+       ev_socklen_t global_outgoing_addrlen;
 
        struct search_state *global_search_state;
 
@@ -1104,7 +1104,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) {
 /* a DNS client (addr,addrlen), and if it's well-formed, call the corresponding */
 /* callback. */
 static int
-request_parse(u8 *packet, int length, struct evdns_server_port *port, struct sockaddr *addr, socklen_t addrlen)
+request_parse(u8 *packet, int length, struct evdns_server_port *port, struct sockaddr *addr, ev_socklen_t addrlen)
 {
        int j = 0;      /* index into packet */
        u16 _t;  /* used by the macros */
@@ -1334,7 +1334,7 @@ nameserver_pick(struct evdns_base *base) {
 static void
 nameserver_read(struct nameserver *ns) {
        struct sockaddr_storage ss;
-       socklen_t addrlen = sizeof(ss);
+       ev_socklen_t addrlen = sizeof(ss);
        u8 packet[1500];
        ASSERT_LOCKED(ns->base);
 
@@ -1368,7 +1368,7 @@ static void
 server_port_read(struct evdns_server_port *s) {
        u8 packet[1500];
        struct sockaddr_storage addr;
-       socklen_t addrlen;
+       ev_socklen_t addrlen;
        int r;
        ASSERT_LOCKED(s);
 
index 5477047e954010a3dec38fb620f45c8a77d0e626..8f338f993c0e342e74271c6f110158cf2efc6a73 100644 (file)
--- a/evutil.c
+++ b/evutil.c
@@ -198,7 +198,7 @@ evutil_make_listen_socket_reuseable(evutil_socket_t sock)
         * listener is closed."  On Windows, though, it means "don't keep other
         * processes from binding to this address while we're using it. */
        return setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one,
-           (socklen_t)sizeof(one));
+           (ev_socklen_t)sizeof(one));
 #else
        return 0;
 #endif
diff --git a/http.c b/http.c
index 7828966bdb043f3394b14b54dec4fbb20cea29cb..52362bc9efa9ce2203264ddd9c008882347b2ec1 100644 (file)
--- a/http.c
+++ b/http.c
@@ -195,7 +195,7 @@ extern int debug;
 static int socket_connect(evutil_socket_t kefd, const char *address, unsigned short port);
 static evutil_socket_t bind_socket_ai(struct addrinfo *, int reuse);
 static evutil_socket_t bind_socket(const char *, ev_uint16_t, int reuse);
-static void name_from_addr(struct sockaddr *, socklen_t, char **, char **);
+static void name_from_addr(struct sockaddr *, ev_socklen_t, char **, char **);
 static int evhttp_associate_new_request_with_connection(
        struct evhttp_connection *evcon);
 static void evhttp_connection_start_detectclose(
@@ -1153,7 +1153,7 @@ evhttp_connection_cb(struct bufferevent *bufev, void *arg)
 {
        struct evhttp_connection *evcon = arg;
        int error;
-       socklen_t errsz = sizeof(error);
+       ev_socklen_t errsz = sizeof(error);
 
        /* Check if the connection completed */
        if (getsockopt(evcon->fd, SOL_SOCKET, SO_ERROR, (void*)&error,
@@ -2365,7 +2365,7 @@ accept_socket(evutil_socket_t fd, short what, void *arg)
 {
        struct evhttp *http = arg;
        struct sockaddr_storage ss;
-       socklen_t addrlen = sizeof(ss);
+       ev_socklen_t addrlen = sizeof(ss);
        evutil_socket_t nfd;
 
        if ((nfd = accept(fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
@@ -2755,7 +2755,7 @@ struct evbuffer *evhttp_request_get_output_buffer(struct evhttp_request *req)
 static struct evhttp_connection*
 evhttp_get_request_connection(
        struct evhttp* http,
-       evutil_socket_t fd, struct sockaddr *sa, socklen_t salen)
+       evutil_socket_t fd, struct sockaddr *sa, ev_socklen_t salen)
 {
        struct evhttp_connection *evcon;
        char *hostname = NULL, *portname = NULL;
@@ -2814,7 +2814,7 @@ evhttp_associate_new_request_with_connection(struct evhttp_connection *evcon)
 
 void
 evhttp_get_request(struct evhttp *http, evutil_socket_t fd,
-    struct sockaddr *sa, socklen_t salen)
+    struct sockaddr *sa, ev_socklen_t salen)
 {
        struct evhttp_connection *evcon;
 
@@ -2873,7 +2873,7 @@ addr_from_name(char *address)
 #endif
 
 static void
-name_from_addr(struct sockaddr *sa, socklen_t salen,
+name_from_addr(struct sockaddr *sa, ev_socklen_t salen,
     char **phost, char **pport)
 {
        char ntop[NI_MAXHOST];
index 0b9865ec8b4e4c8b8c484d9c5a9fa0652a9f8cec..4042f47a1d29156b357d9b680b37029ab0f10a20 100644 (file)
@@ -118,6 +118,14 @@ extern "C" {
 #define ev_ssize_t ssize_t
 #endif
 
+#ifdef WIN32
+#define ev_socklen_t int
+#elif defined(_EVENT_socklen_t)
+#define ev_socklen_t _EVENT_socklen_t
+#else
+#define ev_socklen_t socklen_t
+#endif
+
 #ifdef WIN32
 /** A type wide enough to hold the output of "socket()" or "accept()".  On
  * Windows, this is an intptr_t; elsewhere, it is an int. */