mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
fix a couple memory leaks; time buffer marshaling
svn:r417
This commit is contained in:
parent
98f9616bf4
commit
e678f009a8
@ -602,6 +602,8 @@ test_evbuffer(void) {
|
||||
strcmp((char*)EVBUFFER_DATA(evb), "hello/1") == 0)
|
||||
test_ok = 1;
|
||||
|
||||
evbuffer_free(evb);
|
||||
|
||||
cleanup_test();
|
||||
}
|
||||
|
||||
@ -970,6 +972,7 @@ rpc_test(void)
|
||||
struct kill *kill;
|
||||
struct run *run;
|
||||
struct evbuffer *tmp = evbuffer_new();
|
||||
struct timeval tv_start, tv_end;
|
||||
int i;
|
||||
|
||||
fprintf(stdout, "Testing RPC: ");
|
||||
@ -986,13 +989,14 @@ rpc_test(void)
|
||||
EVTAG_ASSIGN(kill, weapon, "feather");
|
||||
EVTAG_ASSIGN(kill, action, "tickle");
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
gettimeofday(&tv_start, NULL);
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
run = EVTAG_ADD(msg, run);
|
||||
if (run == NULL) {
|
||||
fprintf(stderr, "Failed to add run message.\n");
|
||||
exit(1);
|
||||
}
|
||||
EVTAG_ASSIGN(run, how, "very fast");
|
||||
EVTAG_ASSIGN(run, how, "very fast but with some data in it");
|
||||
}
|
||||
|
||||
if (msg_complete(msg) == -1) {
|
||||
@ -1008,6 +1012,12 @@ rpc_test(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gettimeofday(&tv_end, NULL);
|
||||
timersub(&tv_end, &tv_start, &tv_end);
|
||||
fprintf(stderr, "(%.1f us/add) ",
|
||||
(float)tv_end.tv_sec/(float)i * 1000000.0 +
|
||||
tv_end.tv_usec / (float)i);
|
||||
|
||||
if (!EVTAG_HAS(msg2, from_name) ||
|
||||
!EVTAG_HAS(msg2, to_name) ||
|
||||
!EVTAG_HAS(msg2, kill)) {
|
||||
@ -1015,7 +1025,7 @@ rpc_test(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (EVTAG_LEN(msg2, run) != 3) {
|
||||
if (EVTAG_LEN(msg2, run) != i) {
|
||||
fprintf(stderr, "Wrong number of run messages.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -756,6 +756,8 @@ http_bad_header_test(void)
|
||||
if (evhttp_add_header(&headers, "One", "Two\n") != -1)
|
||||
goto fail;
|
||||
|
||||
evhttp_clear_headers(&headers);
|
||||
|
||||
fprintf(stdout, "OK\n");
|
||||
return;
|
||||
fail:
|
||||
|
@ -199,6 +199,8 @@ rpc_basic_test(void)
|
||||
|
||||
event_dispatch();
|
||||
|
||||
evhttp_connection_free(evcon);
|
||||
|
||||
rpc_teardown(base);
|
||||
|
||||
if (test_ok != 1) {
|
||||
@ -286,6 +288,8 @@ rpc_basic_message(void)
|
||||
test_ok = 0;
|
||||
|
||||
event_dispatch();
|
||||
|
||||
evhttp_connection_free(evcon);
|
||||
|
||||
rpc_teardown(base);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user