Merge remote-tracking branch 'origin/patches-2.0'

Conflicts:
	buffer.c
	http.c
This commit is contained in:
Nick Mathewson 2012-07-26 10:43:13 -04:00
commit 9852107f37
12 changed files with 39 additions and 19 deletions

View File

@ -2382,6 +2382,9 @@ evbuffer_write_iovec(struct evbuffer *buffer, evutil_socket_t fd,
}
chain = chain->next;
}
if (! i)
return 0;
#ifdef _WIN32
{
DWORD bytesSent;

View File

@ -2533,6 +2533,7 @@ evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address)
{
struct sockaddr_in sin;
int res;
memset(&sin, 0, sizeof(sin));
sin.sin_addr.s_addr = address;
sin.sin_port = htons(53);
sin.sin_family = AF_INET;

9
http.c
View File

@ -3992,9 +3992,12 @@ bind_socket_ai(struct evutil_addrinfo *ai, int reuse)
return (-1);
}
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
if (reuse)
evutil_make_listen_socket_reuseable(fd);
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on))<0)
goto out;
if (reuse) {
if (evutil_make_listen_socket_reuseable(fd) < 0)
goto out;
}
if (ai != NULL) {
r = bind(fd, ai->ai_addr, (ev_socklen_t)ai->ai_addrlen);

View File

@ -227,9 +227,15 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb,
if (fd == -1)
return NULL;
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on));
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on))<0) {
evutil_closesocket(fd);
return NULL;
}
if (flags & LEV_OPT_REUSEABLE) {
evutil_make_listen_socket_reuseable(fd);
if (evutil_make_listen_socket_reuseable(fd) < 0) {
evutil_closesocket(fd);
return NULL;
}
}
if (flags & LEV_OPT_DEFERRED_ACCEPT) {

View File

@ -70,8 +70,10 @@ read_cb(evutil_socket_t fd, short which, void *arg)
long idx = (long) arg;
recv(fd, &ch, sizeof(ch), 0);
if (idx >= 0)
send(idx, "e", 1, 0);
if (idx >= 0) {
if (send(idx, "e", 1, 0) < 0)
perror("send");
}
fired++;
}
@ -112,7 +114,8 @@ run_once(int num_pipes)
fired = 0;
/* kick everything off with a single write */
send(pipes[1], "e", 1, 0);
if (send(pipes[1], "e", 1, 0) < 0)
perror("send");
event_dispatch();

View File

@ -115,11 +115,12 @@ frob_socket(evutil_socket_t sock)
{
struct linger l;
int one = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one));
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one))<0)
perror("setsockopt(SO_REUSEADDR)");
l.l_onoff = 1;
l.l_linger = 0;
if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0)
perror("setsockopt");
perror("setsockopt(SO_LINGER)");
}
static int

View File

@ -1052,7 +1052,6 @@ test_bufferevent_connect_hostname(void *arg)
int expect_err5;
struct evdns_base *dns=NULL;
struct evdns_server_port *port=NULL;
evutil_socket_t server_fd=-1;
struct sockaddr_in sin;
int listener_port=-1;
ev_uint16_t dns_port=0;
@ -1154,8 +1153,6 @@ test_bufferevent_connect_hostname(void *arg)
end:
if (listener)
evconnlistener_free(listener);
if (server_fd>=0)
evutil_closesocket(server_fd);
if (port)
evdns_close_server_port(port);
if (dns)

View File

@ -104,7 +104,7 @@ test_edgetriggered(void *et)
called = was_et = 0;
send(pair[0], test, (int)strlen(test)+1, 0);
tt_int_op(send(pair[0], test, (int)strlen(test)+1, 0), >, 0);
shutdown(pair[0], SHUT_WR);
/* Initalize the event library */

View File

@ -162,7 +162,7 @@ regress_listener_error(void *arg)
}
/* send, so that pair[0] will look 'readable'*/
send(data->pair[1], "hello", 5, 0);
tt_int_op(send(data->pair[1], "hello", 5, 0), >, 0);
/* Start a listener with a bogus socket. */
listener = evconnlistener_new(base, acceptcb, &count,

View File

@ -108,7 +108,8 @@ getcert(void)
name = X509_NAME_new();
tt_assert(name);
tt_assert(NID_undef != (nid = OBJ_txt2nid("commonName")));
nid = OBJ_txt2nid("commonName");
tt_assert(NID_undef != nid);
tt_assert(0 != X509_NAME_add_entry_by_NID(
name, nid, MBSTRING_ASC, (unsigned char*)"example.com",
-1, -1, 0));

View File

@ -178,12 +178,16 @@ regress_dns_server_cb(struct evdns_server_request *req, void *data)
return;
} else if (!strcmp(tab->anstype, "A")) {
struct in_addr in;
evutil_inet_pton(AF_INET, tab->ans, &in);
if (!evutil_inet_pton(AF_INET, tab->ans, &in)) {
TT_DIE(("Bad A value %s in table", tab->ans));
}
evdns_server_request_add_a_reply(req, question, 1, &in.s_addr,
100);
} else if (!strcmp(tab->anstype, "AAAA")) {
struct in6_addr in6;
evutil_inet_pton(AF_INET6, tab->ans, &in6);
if (!evutil_inet_pton(AF_INET6, tab->ans, &in6)) {
TT_DIE(("Bad AAAA value %s in table", tab->ans));
}
evdns_server_request_add_aaaa_reply(req,
question, 1, &in6.s6_addr, 100);
} else {

View File

@ -106,7 +106,8 @@ main(int argc, char **argv)
return (1);
send(pair[0], test, (int)strlen(test)+1, 0);
if (send(pair[0], test, (int)strlen(test)+1, 0) < 0)
return (1);
shutdown(pair[0], SHUT_WR);
/* Initalize the event library */