diff options
-rw-r--r-- | src/rps/gnunet-service-rps.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 82f092137..de1a71680 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -120,6 +120,11 @@ struct ClientContext | |||
120 | */ | 120 | */ |
121 | struct ReplyCls *rep_cls_head; | 121 | struct ReplyCls *rep_cls_head; |
122 | struct ReplyCls *rep_cls_tail; | 122 | struct ReplyCls *rep_cls_tail; |
123 | |||
124 | /** | ||
125 | * The client handle to send the reply to | ||
126 | */ | ||
127 | struct GNUNET_SERVER_Client *client; | ||
123 | }; | 128 | }; |
124 | 129 | ||
125 | /** | 130 | /** |
@@ -2132,8 +2137,33 @@ process_peerinfo_peers (void *cls, | |||
2132 | static void | 2137 | static void |
2133 | shutdown_task (void *cls) | 2138 | shutdown_task (void *cls) |
2134 | { | 2139 | { |
2140 | struct ClientContext *client_ctx; | ||
2141 | struct ReplyCls *reply_cls; | ||
2142 | |||
2135 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2143 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2136 | "RPS is going down\n"); | 2144 | "RPS is going down\n"); |
2145 | |||
2146 | /* Clean all clients */ | ||
2147 | for (client_ctx = cli_ctx_head; | ||
2148 | NULL != cli_ctx_head; | ||
2149 | client_ctx = cli_ctx_head) | ||
2150 | { | ||
2151 | /* Clean pending requests to the sampler */ | ||
2152 | for (reply_cls = client_ctx->rep_cls_head; | ||
2153 | NULL != client_ctx->rep_cls_head; | ||
2154 | reply_cls = client_ctx->rep_cls_head) | ||
2155 | { | ||
2156 | RPS_sampler_request_cancel (reply_cls->req_handle); | ||
2157 | GNUNET_CONTAINER_DLL_remove (client_ctx->rep_cls_head, | ||
2158 | client_ctx->rep_cls_tail, | ||
2159 | reply_cls); | ||
2160 | GNUNET_free (reply_cls); | ||
2161 | } | ||
2162 | GNUNET_MQ_destroy (client_ctx->mq); | ||
2163 | GNUNET_SERVER_client_disconnect (client_ctx->client); | ||
2164 | GNUNET_CONTAINER_DLL_remove (cli_ctx_head, cli_ctx_tail, client_ctx); | ||
2165 | GNUNET_free (client_ctx); | ||
2166 | } | ||
2137 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); | 2167 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); |
2138 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 2168 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
2139 | 2169 | ||
@@ -2187,6 +2217,7 @@ handle_client_connect (void *cls, | |||
2187 | return; /* Server was destroyed before a client connected. Shutting down */ | 2217 | return; /* Server was destroyed before a client connected. Shutting down */ |
2188 | cli_ctx = GNUNET_new (struct ClientContext); | 2218 | cli_ctx = GNUNET_new (struct ClientContext); |
2189 | cli_ctx->mq = GNUNET_MQ_queue_for_server_client (client); | 2219 | cli_ctx->mq = GNUNET_MQ_queue_for_server_client (client); |
2220 | cli_ctx->client = client; | ||
2190 | GNUNET_SERVER_client_set_user_context (client, cli_ctx); | 2221 | GNUNET_SERVER_client_set_user_context (client, cli_ctx); |
2191 | GNUNET_CONTAINER_DLL_insert (cli_ctx_head, | 2222 | GNUNET_CONTAINER_DLL_insert (cli_ctx_head, |
2192 | cli_ctx_tail, | 2223 | cli_ctx_tail, |
@@ -2249,8 +2280,7 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
2249 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); | 2280 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
2250 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 2281 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
2251 | 2282 | ||
2252 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 2283 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2253 | NULL); | ||
2254 | } | 2284 | } |
2255 | 2285 | ||
2256 | 2286 | ||