int
evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch)
{
- struct evbuffer_chain *chain, **chainp;
+ struct evbuffer_chain **chainp;
int n;
int result;
#ifdef USE_IOVEC_IMPL
int nvecs, i, remaining;
#else
+ struct evbuffer_chain *chain;
unsigned char *p;
#endif
EVBUFFER_LOCK(buf);
- chain = buf->last;
-
if (buf->freeze_end) {
result = -1;
goto done;
else
state = BEV_NORMAL;
+ /* XXXX use return value */
res = be_filter_process_input(bevf, state, &processed_any);
/* XXX This should be in process_input, not here. There are
}
/* XXX use the other addrinfos? */
+ /* XXX use this return value */
r = bufferevent_socket_connect(bev, ai->ai_addr, (int)ai->ai_addrlen);
_bufferevent_decref_and_unlock(bev);
evutil_freeaddrinfo(ai);
if (head)
evdns_request_remove(req, head);
- log(EVDNS_LOG_DEBUG, "Removing timeout for request %lx",
- (unsigned long) req);
+ log(EVDNS_LOG_DEBUG, "Removing timeout for request %p", req);
if (was_inflight) {
evtimer_del(&req->timeout_event);
base->global_requests_inflight--;
(void) fd;
(void) events;
- log(EVDNS_LOG_DEBUG, "Request %lx timed out", (unsigned long) arg);
+ log(EVDNS_LOG_DEBUG, "Request %p timed out", arg);
EVDNS_LOCK(base);
req->ns->timedout++;
default:
/* all ok */
log(EVDNS_LOG_DEBUG,
- "Setting timeout for request %lx", (unsigned long) req);
+ "Setting timeout for request %p", req);
if (evtimer_add(&req->timeout_event, &req->base->global_timeout) < 0) {
log(EVDNS_LOG_WARN,
- "Error from libevent when adding timer for request %lx",
- (unsigned long) req);
+ "Error from libevent when adding timer for request %p",
+ req);
/* ???? Do more? */
}
req->tx_count++;
struct evbuffer *input_buffer; /* read data */
ev_int64_t ntoread;
- int chunked:1, /* a chunked request */
+ unsigned chunked:1, /* a chunked request */
userdone:1; /* the user has sent all data */
struct evbuffer *output_buffer; /* outgoing post or data */
event_base_dispatch(base);
+ evconnlistener_free(listener);
+ event_base_free(base);
+
return 0;
}
event_del(&ev);
}
-static int total_common_counts;
-
struct common_timeout_info {
struct event ev;
struct timeval called_at;
tt_int_op(ms_100->tv_usec, ==, 100000|0x50000000);
tt_int_op(ms_200->tv_usec, ==, 200000|0x50100000);
- total_common_counts = 0;
-
memset(info, 0, sizeof(info));
for (i=0; i<100; ++i) {
re_add_read_cb(evutil_socket_t fd, short event, void *arg)
{
char buf[256];
- int len;
struct event *ev_other = arg;
readd_test_event_last_added = ev_other;
- len = read(fd, buf, sizeof(buf));
+ (void) read(fd, buf, sizeof(buf));
event_add(ev_other, NULL);
++test_ok;
}
test_nonpersist_readd(void)
{
struct event ev1, ev2;
- int n, m;
-
+
setup_test("Re-add nonpersistent events: ");
event_set(&ev1, pair[0], EV_READ, re_add_read_cb, &ev2);
event_set(&ev2, pair[1], EV_READ, re_add_read_cb, &ev1);
- n = write(pair[0], "Hello", 5);
- m = write(pair[1], "Hello", 5);
+ (void) write(pair[0], "Hello", 5);
+ (void) write(pair[1], "Hello", 5);
if (event_add(&ev1, NULL) == -1 ||
event_add(&ev2, NULL) == -1) {
test_ok = 0;
memset(&local_outcome, 0, sizeof(local_outcome));
r = evdns_getaddrinfo(dns_base, "1.2.3.4", "http",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(! r);
if (!local_outcome.err) {
tt_ptr_op(local_outcome.ai,!=,NULL);
test_ai_eq(local_outcome.ai, "1.2.3.4:80", SOCK_STREAM, IPPROTO_TCP);
hints.ai_protocol = IPPROTO_TCP;
r = evdns_getaddrinfo(dns_base, "f::f", "8008",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(!r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
tt_ptr_op(local_outcome.ai->ai_next,==,NULL);
hints.ai_family = PF_UNSPEC;
r = evdns_getaddrinfo(dns_base, "5.6.7.8", NULL,
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(!r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
a = ai_find_by_protocol(local_outcome.ai, IPPROTO_TCP);
hints.ai_flags = EVUTIL_AI_PASSIVE;
r = evdns_getaddrinfo(dns_base, NULL, "9090",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(!r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
/* we should get a v4 address of 0.0.0.0... */
hints.ai_socktype = SOCK_STREAM;
r = evdns_getaddrinfo(dns_base, NULL, "2",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(!r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
/* we should get a v4 address of 127.0.0.1 .... */
hints.ai_socktype = SOCK_STREAM;
r = evdns_getaddrinfo(dns_base, "LOCALHOST", "80",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(!r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
/* we should get a v4 address of 127.0.0.1 .... */
hints.ai_socktype = SOCK_STREAM;
r = evdns_getaddrinfo(dns_base, "LOCALHOST", "9999",
&hints, gai_cb, &local_outcome);
- tt_int_op(r,==,0);
+ tt_assert(! r);
tt_int_op(local_outcome.err,==,0);
tt_assert(local_outcome.ai);
a = local_outcome.ai;
const char *test = "test string";
evutil_socket_t pair[2] = {-1,-1};
int supports_et;
- int success;
if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, pair) == -1) {
tt_abort_perror("socketpair");
} else {
tt_int_op(called, ==, 2);
tt_assert(!was_et);
- success = (called == 2) && !was_et;
-
}
end:
void
test_bufferevent_zlib(void *arg)
{
- struct bufferevent *bev1=NULL, *bev2=NULL, *bev1_orig, *bev2_orig;
+ struct bufferevent *bev1=NULL, *bev2=NULL;
char buffer[8333];
z_stream z_input, z_output;
int i, pair[2]={-1,-1}, r;
evutil_make_socket_nonblocking(pair[0]);
evutil_make_socket_nonblocking(pair[1]);
- bev1_orig = bev1 = bufferevent_socket_new(NULL, pair[0], 0);
- bev2_orig = bev2 = bufferevent_socket_new(NULL, pair[1], 0);
+ bev1 = bufferevent_socket_new(NULL, pair[0], 0);
+ bev2 = bufferevent_socket_new(NULL, pair[1], 0);
memset(&z_output, 0, sizeof(z_output));
r = deflateInit(&z_output, Z_DEFAULT_COMPRESSION);
struct event_base* base;
evutil_socket_t pair[2];
- int res;
struct timeval tv;
struct cpu_usage_timer timer;
start_cpu_usage_timer(&timer);
- res = event_base_dispatch(base);
+ event_base_dispatch(base);
get_cpu_usage(&timer, &secPassed, &secUsed, &usage);
exit(1);
}
exit(0);
+ return FAIL; /* unreachable */
} else {
/* parent */
int status, r;
if (opt_forked) {
exit(outcome==OK ? 0 : (outcome==SKIP?MAGIC_EXITCODE : 1));
+ return 1; /* unreachable */
} else {
return (int)outcome;
}