buffer[i] = i;
bev1 = bufferevent_filter_new(bev1, NULL, bufferevent_output_filter,
- 0, NULL, NULL);
+ BEV_OPT_CLOSE_ON_FREE, NULL, NULL);
bev2 = bufferevent_filter_new(bev2, bufferevent_input_filter,
- NULL, 0, NULL, NULL);
+ NULL, BEV_OPT_CLOSE_ON_FREE, NULL, NULL);
bufferevent_setcb(bev1, NULL, writecb, errorcb, NULL);
bufferevent_setcb(bev2, readcb, NULL, errorcb, NULL);
char type;
int count;
int ttl;
+ size_t addrs_len;
void *addrs;
+ char addrs_buf[256];
};
static void
else if (type == DNS_PTR)
len = strlen(addresses)+1;
else {
- len = 0;
+ res->addrs_len = len = 0;
res->addrs = NULL;
}
if (len) {
- res->addrs = malloc(len);
- memcpy(res->addrs, addresses, len);
+ res->addrs_len = len;
+ if (len > 256)
+ len = 256;
+ memcpy(res->addrs_buf, addresses, len);
+ res->addrs = res->addrs_buf;
}
if (--n_replies_left == 0)
http_bad_request_test(void)
{
struct timeval tv;
- struct bufferevent *bev;
+ struct bufferevent *bev = NULL;
evutil_socket_t fd;
const char *http_request;
short port = -1;
end:
evhttp_free(http);
+ if (bev)
+ bufferevent_free(bev);
}
static struct evhttp_connection *delayed_client;
terminate_chunked_trickle_cb(evutil_socket_t fd, short events, void *arg)
{
struct terminate_state *state = arg;
- struct evbuffer *evb = evbuffer_new();
+ struct evbuffer *evb;
struct timeval tv;
if (evhttp_request_get_connection(state->req) == NULL) {
return;
}
+ evb = evbuffer_new();
evbuffer_add_printf(evb, "%p", evb);
evhttp_send_reply_chunk(state->req, evb);
evbuffer_free(evb);
EVUTIL_CLOSESOCKET(fd2);
if (fd3>=0)
EVUTIL_CLOSESOCKET(fd3);
+ if (listener1)
+ evconnlistener_free(listener1);
+ if (listener2)
+ evconnlistener_free(listener2);
}
struct _rpc_hook_ctx *ctx = arg;
++hook_pause_cb_called;
evrpc_resume_request(ctx->vbase, ctx->ctx, EVRPC_CONTINUE);
+ free(arg);
}
static int
r = inflateInit(&z_input);
/* initialize filters */
- bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter, 0,
- zlib_deflate_free, &z_output);
+ bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter,
+ BEV_OPT_CLOSE_ON_FREE, zlib_deflate_free, &z_output);
bev2 = bufferevent_filter_new(bev2, zlib_input_filter,
- NULL, 0, zlib_inflate_free, &z_input);
+ NULL, BEV_OPT_CLOSE_ON_FREE, zlib_inflate_free, &z_input);
bufferevent_setcb(bev1, readcb, writecb, errorcb, NULL);
bufferevent_setcb(bev2, readcb, writecb, errorcb, NULL);