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

Conflicts:
	configure.in
	test/regress_buffer.c
	test/regress_dns.c
This commit is contained in:
Nick Mathewson 2012-07-26 10:09:13 -04:00
commit 7ef04e4b48
10 changed files with 72 additions and 19 deletions

View File

@ -216,11 +216,13 @@ AC_CHECK_HEADERS([ \
sys/select.h \
sys/sendfile.h \
sys/socket.h \
sys/stat.h \
sys/time.h \
sys/timerfd.h \
sys/uio.h \
sys/wait.h \
])
AC_CHECK_HEADERS(sys/sysctl.h, [], [], [
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
@ -354,6 +356,7 @@ AC_CHECK_FUNCS([ \
strtoll \
sysctl \
timerfd_create \
umask \
unsetenv \
usleep \
vasprintf \

View File

@ -2274,6 +2274,10 @@ test_event_pending(void *ptr)
NULL);
t = evtimer_new(data->base, timeout_cb, NULL);
tt_assert(r);
tt_assert(w);
tt_assert(t);
evutil_gettimeofday(&now, NULL);
event_add(r, NULL);
event_add(t, &tv);
@ -2371,7 +2375,8 @@ end:
event_free(ev1);
if (ev2)
event_free(ev2);
close(dfd);
if (dfd >= 0)
close(dfd);
}
#endif

View File

@ -1232,6 +1232,8 @@ test_evbuffer_find(void *ptr)
unsigned int i;
struct evbuffer * buf = evbuffer_new();
tt_assert(buf);
/* make sure evbuffer_find doesn't match past the end of the buffer */
evbuffer_add(buf, (u_char*)test1, strlen(test1));
evbuffer_validate(buf);
@ -1273,6 +1275,8 @@ test_evbuffer_ptr_set(void *ptr)
struct evbuffer_ptr pos;
struct evbuffer_iovec v[1];
tt_assert(buf);
tt_int_op(evbuffer_get_length(buf), ==, 0);
tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0);
@ -1331,6 +1335,9 @@ test_evbuffer_search(void *ptr)
struct evbuffer *tmp = evbuffer_new();
struct evbuffer_ptr pos, end;
tt_assert(buf);
tt_assert(tmp);
pos = evbuffer_search(buf, "x", 1, NULL);
tt_int_op(pos.pos, ==, -1);
tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0);
@ -1436,6 +1443,10 @@ test_evbuffer_callbacks(void *ptr)
struct evbuffer *buf_out2 = evbuffer_new();
struct evbuffer_cb_entry *cb1, *cb2;
tt_assert(buf);
tt_assert(buf_out1);
tt_assert(buf_out2);
cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1);
cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2);

View File

@ -256,6 +256,8 @@ test_bufferevent_watermarks_impl(int use_pair)
bev1 = bufferevent_new(pair[0], NULL, wm_writecb, wm_errorcb, NULL);
bev2 = bufferevent_new(pair[1], wm_readcb, NULL, wm_errorcb, NULL);
}
tt_assert(bev1);
tt_assert(bev2);
bufferevent_disable(bev1, EV_READ);
bufferevent_enable(bev2, EV_READ);
@ -280,8 +282,10 @@ test_bufferevent_watermarks_impl(int use_pair)
tt_assert(!event_pending(&bev2->ev_write, EV_WRITE, NULL));
end:
bufferevent_free(bev1);
bufferevent_free(bev2);
if (bev1)
bufferevent_free(bev1);
if (bev2)
bufferevent_free(bev2);
}
static void
@ -390,8 +394,10 @@ test_bufferevent_filters_impl(int use_pair)
test_ok = 0;
end:
bufferevent_free(bev1);
bufferevent_free(bev2);
if (bev1)
bufferevent_free(bev1);
if (bev2)
bufferevent_free(bev2);
}

View File

@ -1070,6 +1070,7 @@ test_bufferevent_connect_hostname(void *arg)
&n_accept,
LEV_OPT_REUSEABLE|LEV_OPT_CLOSE_ON_EXEC,
-1, (struct sockaddr *)&sin, sizeof(sin));
tt_assert(listener);
listener_port = regress_get_socket_port(
evconnlistener_get_fd(listener));
@ -1215,6 +1216,7 @@ test_getaddrinfo_async(void *arg)
int n_dns_questions = 0;
struct evdns_base *dns_base = evdns_base_new(data->base, 0);
tt_assert(dns_base);
/* for localhost */
evdns_base_load_hosts(dns_base, NULL);
@ -1712,6 +1714,7 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_)
{
int ok = 0;
struct testleak_env_t *env = env_;
tt_assert(env);
#ifdef EVENT__DISABLE_DEBUG_MODE
tt_int_op(allocated_chunks, ==, 0);
#else
@ -1720,12 +1723,13 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_)
#endif
ok = 1;
end:
if (env->dns_base)
evdns_base_free(env->dns_base, 0);
if (env->base)
event_base_free(env->base);
if (env)
if (env) {
if (env->dns_base)
evdns_base_free(env->dns_base, 0);
if (env->base)
event_base_free(env->base);
free(env);
}
return ok;
}

View File

@ -173,7 +173,9 @@ test_edgetriggered_mix_error(void *data_)
/* try mixing edge-triggered and level-triggered to make sure it fails*/
ev_et = event_new(base, data->pair[0], EV_READ|EV_ET, read_cb, ev_et);
tt_assert(ev_et);
ev_lt = event_new(base, data->pair[0], EV_READ, read_cb, ev_lt);
tt_assert(ev_lt);
/* Add edge-triggered, then level-triggered. Get an error. */
tt_int_op(0, ==, event_add(ev_et, NULL));

View File

@ -2665,9 +2665,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
if (header == NULL)
goto out;
/* 13 chars */
if (strcmp(header, "d"))
if (strcmp(header, "d")) {
free((void*)header);
goto out;
free((char*)header);
}
free((void*)header);
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13),
"This is funny", 13))
@ -2693,8 +2695,10 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
if (header == NULL)
goto out;
/* 8 chars */
if (strcmp(header, "8"))
if (strcmp(header, "8")) {
free((void*)header);
goto out;
}
free((char *)header);
if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8),
@ -2707,9 +2711,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg)
if (header == NULL)
goto out;
/* 0 chars */
if (strcmp(header, "0"))
if (strcmp(header, "0")) {
free((void*)header);
goto out;
free((char *)header);
}
free((void *)header);
test_ok = 2;
@ -3220,26 +3226,30 @@ static void
http_primitives(void *ptr)
{
char *escaped = NULL;
struct evhttp *http;
struct evhttp *http = NULL;
escaped = evhttp_htmlescape("<script>");
tt_assert(escaped);
tt_str_op(escaped, ==, "&lt;script&gt;");
free(escaped);
escaped = evhttp_htmlescape("\"\'&");
tt_assert(escaped);
tt_str_op(escaped, ==, "&quot;&#039;&amp;");
http = evhttp_new(NULL);
tt_assert(http);
tt_int_op(evhttp_set_cb(http, "/test", http_basic_cb, NULL), ==, 0);
tt_int_op(evhttp_set_cb(http, "/test", http_basic_cb, NULL), ==, -1);
tt_int_op(evhttp_del_cb(http, "/test"), ==, 0);
tt_int_op(evhttp_del_cb(http, "/test"), ==, -1);
tt_int_op(evhttp_set_cb(http, "/test", http_basic_cb, NULL), ==, 0);
evhttp_free(http);
end:
if (escaped)
free(escaped);
if (http)
evhttp_free(http);
}
static void

View File

@ -59,6 +59,9 @@
#endif
#include <sys/types.h>
#ifdef EVENT__HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifndef _WIN32
#include <sys/socket.h>
@ -125,6 +128,9 @@ regress_make_tmpfile(const void *data, size_t datalen, char **filename_out)
int fd;
*filename_out = NULL;
strcpy(tmpfilename, "/tmp/eventtmp.XXXXXX");
#ifdef EVENT__HAVE_UMASK
umask(0077);
#endif
fd = mkstemp(tmpfilename);
if (fd == -1)
return (-1);
@ -305,7 +311,7 @@ static void *
legacy_test_setup(const struct testcase_t *testcase)
{
struct basic_test_data *data = basic_test_setup(testcase);
if (data == (void*)TT_SKIP)
if (data == (void*)TT_SKIP || data == NULL)
return data;
global_base = data->base;
pair[0] = data->pair[0];

View File

@ -113,6 +113,7 @@ MessageCb(EVRPC_STRUCT(Message)* rpc, void *arg)
struct evhttp_request* req = EVRPC_REQUEST_HTTP(rpc);
const char *header = evhttp_find_header(
req->input_headers, "X-Hook");
assert(header);
assert(strcmp(header, "input") == 0);
}
@ -332,6 +333,7 @@ GotKillCb(struct evrpc_status *status,
struct evhttp_request *req = status->http_req;
const char *header = evhttp_find_header(
req->input_headers, "X-Pool-Hook");
assert(header);
assert(strcmp(header, "ran") == 0);
}
@ -734,6 +736,9 @@ rpc_test(void)
int i;
msg = msg_new();
tt_assert(msg);
EVTAG_ASSIGN(msg, from_name, "niels");
EVTAG_ASSIGN(msg, to_name, "phoenix");

View File

@ -101,7 +101,7 @@ regress_get_dnsserver(struct event_base *base,
struct sockaddr_in my_addr;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock <= 0) {
if (sock < 0) {
tt_abort_perror("socket");
}
@ -112,6 +112,7 @@ regress_get_dnsserver(struct event_base *base,
my_addr.sin_port = htons(*portnum);
my_addr.sin_addr.s_addr = htonl(0x7f000001UL);
if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) {
evutil_closesocket(sock);
tt_abort_perror("bind");
}
port = evdns_add_server_port_with_base(base, sock, 0, cb, arg);