[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Re: RPC: patch for evrpc_free() and evrpc_unregister_rpc()
Nick Mathewson wrote:
Hi Nick,
When I apply this patch, the unit tests don't pass any more. I get:
rpc/basic_test: [forking] OK
rpc/basic_message: [forking] OK
rpc/basic_client: [forking] [err] evrpc.c:109: Assertion r == 0 failed
in evrpc_free
[Lost connection!]
[basic_client FAILED]
rpc/basic_queued_client: [forking] OK
rpc/basic_client_with_pause: [forking] [err] evrpc.c:109: Assertion r
== 0 failed in evrpc_free
[Lost connection!]
[basic_client_with_pause FAILED]
Did the tests pass for you?
Hmmm ok I'm stupid, evrpc_unregister_rpc() returns 0 for success
and -1 for error, whereas evrpc_remove_hook() returns 1 for success
and 0 for error. So I incorrectly modified the asserts for the hooks.
The attached patch should be ok :)
Christophe
diff -ur libevent-2.0.10-stable/evrpc.c libevent-2.0.10-patch/evrpc.c
--- libevent-2.0.10-stable/evrpc.c 2011-02-25 16:25:50.466781289 +0100
+++ libevent-2.0.10-patch/evrpc.c 2011-03-08 09:29:59.758281916 +0100
@@ -98,7 +98,7 @@
while ((rpc = TAILQ_FIRST(&base->registered_rpcs)) != NULL) {
r = evrpc_unregister_rpc(base, rpc->uri);
- EVUTIL_ASSERT(r);
+ EVUTIL_ASSERT(r == 0);
}
while ((pause = TAILQ_FIRST(&base->paused_requests)) != NULL) {
TAILQ_REMOVE(&base->paused_requests, pause, next);
@@ -263,9 +263,6 @@
}
TAILQ_REMOVE(&base->registered_rpcs, rpc, next);
- mm_free((char *)rpc->uri);
- mm_free(rpc);
-
registered_uri = evrpc_construct_uri(name);
/* remove the http server callback */
@@ -273,6 +270,9 @@
EVUTIL_ASSERT(r == 0);
mm_free(registered_uri);
+
+ mm_free((char *)rpc->uri);
+ mm_free(rpc);
return (0);
}