X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libevent%2Fevrpc.c;h=4bf3d2b42540d3bd7d01844dcfe31244c9b9be98;hb=33c70ce1349f3e7fcbc5776785f34f3bd89f1d92;hp=9d69299490cbaf2108413c75b857bcbaab54be0e;hpb=dd07aea71f86aa97f05db188c49e0a3c035ee41c;p=netatalk.git diff --git a/libevent/evrpc.c b/libevent/evrpc.c index 9d692994..4bf3d2b4 100644 --- a/libevent/evrpc.c +++ b/libevent/evrpc.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2000-2007 Niels Provos - * Copyright (c) 2007-2010 Niels Provos and Nick Mathewson + * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -98,7 +98,7 @@ evrpc_free(struct evrpc_base *base) 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 @@ evrpc_unregister_rpc(struct evrpc_base *base, const char *name) } 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 @@ evrpc_unregister_rpc(struct evrpc_base *base, const char *name) EVUTIL_ASSERT(r == 0); mm_free(registered_uri); + + mm_free((char *)rpc->uri); + mm_free(rpc); return (0); } @@ -338,8 +338,12 @@ static void evrpc_request_cb_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) { struct evrpc_req_generic *rpc_state = arg; - struct evrpc *rpc = rpc_state->rpc; - struct evhttp_request *req = rpc_state->http_req; + struct evrpc *rpc; + struct evhttp_request *req; + + EVUTIL_ASSERT(rpc_state); + rpc = rpc_state->rpc; + req = rpc_state->http_req; if (hook_res == EVRPC_TERMINATE) goto error; @@ -399,8 +403,13 @@ evrpc_request_done_closure(void *, enum EVRPC_HOOK_RESULT); void evrpc_request_done(struct evrpc_req_generic *rpc_state) { - struct evhttp_request *req = rpc_state->http_req; - struct evrpc *rpc = rpc_state->rpc; + struct evhttp_request *req; + struct evrpc *rpc; + + EVUTIL_ASSERT(rpc_state); + + req = rpc_state->http_req; + rpc = rpc_state->rpc; if (rpc->reply_complete(rpc_state->reply) == -1) { /* the reply was not completely filled in. error out */ @@ -466,7 +475,9 @@ static void evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res) { struct evrpc_req_generic *rpc_state = arg; - struct evhttp_request *req = rpc_state->http_req; + struct evhttp_request *req; + EVUTIL_ASSERT(rpc_state); + req = rpc_state->http_req; if (hook_res == EVRPC_TERMINATE) goto error;