Export an ev_socklen_t.

svn:r1391
This commit is contained in:
Nick Mathewson 2009-07-30 17:01:21 +00:00
parent 75fe762e03
commit 7c20a6ae52
5 changed files with 23 additions and 14 deletions

View File

@ -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.

14
evdns.c
View File

@ -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);

View File

@ -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

12
http.c
View File

@ -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];

View 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. */