support freeing of evrpc base

svn:r356
This commit is contained in:
Niels Provos 2007-05-23 05:31:33 +00:00
parent 0c2808246a
commit 621a1b2947
4 changed files with 15 additions and 4 deletions

View File

@ -82,7 +82,13 @@ evrpc_init(struct evhttp *http_server)
void
evrpc_free(struct evrpc_base *base)
{
struct evrpc *rpc;
while ((rpc = TAILQ_FIRST(&base->registered_rpcs)) != NULL) {
assert(evrpc_unregister_rpc(base, rpc->uri));
}
free(base);
}
static void evrpc_pool_schedule(struct evrpc_pool *pool);

View File

@ -211,6 +211,9 @@ struct evhttp;
/* functions to start up the rpc system */
struct evrpc_base *evrpc_init(struct evhttp *server);
/* frees the base - for now, you are responsible for making sure that no rpcs are ongoing */
void evrpc_free(struct evrpc_base *);
/* this macro is used to register RPCs with the HTTP Server */
#define EVRPC_REGISTER(base, name, request, reply, callback, cbarg) \
do { \

View File

@ -1079,16 +1079,16 @@ main (int argc, char **argv)
test_want_only_once();
evtag_test();
rpc_test();
#ifndef WIN32
test_signal_dealloc();
test_signal_pipeloss();
test_signal_switchbase();
#endif
evtag_test();
rpc_test();
return (0);
}

View File

@ -133,6 +133,8 @@ rpc_teardown(struct evrpc_base *base)
{
assert(EVRPC_UNREGISTER(base, Message) == 0);
assert(EVRPC_UNREGISTER(base, NeverReply) == 0);
evrpc_free(base);
}
static void