diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-service-fs_lc.c | 72 |
1 files changed, 28 insertions, 44 deletions
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index e8d6bda47..474d2da2a 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c | |||
@@ -58,7 +58,6 @@ struct ClientRequest | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | 60 | ||
61 | |||
62 | /** | 61 | /** |
63 | * Replies to be transmitted to the client. The actual | 62 | * Replies to be transmitted to the client. The actual |
64 | * response message is allocated after this struct. | 63 | * response message is allocated after this struct. |
@@ -87,7 +86,6 @@ struct ClientResponse | |||
87 | }; | 86 | }; |
88 | 87 | ||
89 | 88 | ||
90 | |||
91 | /** | 89 | /** |
92 | * A local client. | 90 | * A local client. |
93 | */ | 91 | */ |
@@ -188,6 +186,7 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client) | |||
188 | * | 186 | * |
189 | * @param cls user-specified closure | 187 | * @param cls user-specified closure |
190 | * @param pr handle to the original pending request | 188 | * @param pr handle to the original pending request |
189 | * @param expiration when does 'data' expire? | ||
191 | * @param data response data, NULL on request expiration | 190 | * @param data response data, NULL on request expiration |
192 | * @param data_len number of bytes in data | 191 | * @param data_len number of bytes in data |
193 | * @param more GNUNET_YES if the request remains active (may call | 192 | * @param more GNUNET_YES if the request remains active (may call |
@@ -197,11 +196,15 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client) | |||
197 | static void | 196 | static void |
198 | client_response_handler (void *cls, | 197 | client_response_handler (void *cls, |
199 | struct GSF_PendingRequest *pr, | 198 | struct GSF_PendingRequest *pr, |
199 | struct GNUNET_TIME_Absolute expiration, | ||
200 | const void *data, | 200 | const void *data, |
201 | size_t data_len, | 201 | size_t data_len, |
202 | int more) | 202 | int more) |
203 | { | 203 | { |
204 | struct ClientRequest *cr = cls; | 204 | struct ClientRequest *cr = cls; |
205 | struct GSF_LocalClient *lc; | ||
206 | struct PutMessage *pm; | ||
207 | const struct GSF_PendingRequestData *prd; | ||
205 | 208 | ||
206 | if (NULL == data) | 209 | if (NULL == data) |
207 | { | 210 | { |
@@ -210,51 +213,31 @@ client_response_handler (void *cls, | |||
210 | GNUNET_assert (GNUNET_NO == more); | 213 | GNUNET_assert (GNUNET_NO == more); |
211 | return; | 214 | return; |
212 | } | 215 | } |
213 | /* FIXME: adapt old code below to new API! */ | 216 | GNUNET_STATISTICS_update (stats, |
214 | 217 | gettext_noop ("# replies received for local clients"), | |
215 | GNUNET_STATISTICS_update (stats, | 218 | 1, |
216 | gettext_noop ("# replies received for local clients"), | 219 | GNUNET_NO); |
217 | 1, | 220 | prd = GSF_pending_request_get_data_ (pr); |
218 | GNUNET_NO); | 221 | GNUNET_assert (pr == cr->pr); |
219 | cl = pr->client_request_list->client_list; | 222 | lc = cr->lc; |
220 | msize = sizeof (struct PutMessage) + prq->size; | 223 | pm = GNUNET_malloc (sizeof (PutMessage) + data_len); |
221 | creply = GNUNET_malloc (msize + sizeof (struct ClientResponseMessage)); | 224 | pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); |
222 | creply->msize = msize; | 225 | pm->header.size = htons (msize); |
223 | creply->client_list = cl; | 226 | pm->type = htonl (prd->type); |
224 | GNUNET_CONTAINER_DLL_insert_after (cl->res_head, | 227 | pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); |
225 | cl->res_tail, | 228 | memcpy (&pm[1], data, data_len); |
226 | cl->res_tail, | 229 | GSF_local_client_transmit_ (lc, &pm->header); |
227 | creply); | 230 | |
228 | pm = (struct PutMessage*) &creply[1]; | 231 | if (GNUNET_NO == more) |
229 | pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); | 232 | { |
230 | pm->header.size = htons (msize); | 233 | GNUNET_CONTAINER_DLL_remove (lc->cr_head, |
231 | pm->type = htonl (prq->type); | 234 | lc->cr_tail, |
232 | pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); | 235 | cr); |
233 | memcpy (&pm[1], prq->data, prq->size); | 236 | GNUNET_free (cr); |
234 | if (NULL == cl->th) | 237 | } |
235 | { | ||
236 | #if DEBUG_FS | ||
237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
238 | "Transmitting result for query `%s' to client\n", | ||
239 | GNUNET_h2s (key)); | ||
240 | #endif | ||
241 | cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, | ||
242 | msize, | ||
243 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
244 | &transmit_to_client, | ||
245 | cl); | ||
246 | } | ||
247 | GNUNET_break (cl->th != NULL); | ||
248 | if (pr->do_remove) | ||
249 | { | ||
250 | prq->finished = GNUNET_YES; | ||
251 | destroy_pending_request (pr); | ||
252 | } | ||
253 | |||
254 | } | 238 | } |
255 | 239 | ||
256 | 240 | ||
257 | |||
258 | /** | 241 | /** |
259 | * Handle START_SEARCH-message (search request from local client). | 242 | * Handle START_SEARCH-message (search request from local client). |
260 | * | 243 | * |
@@ -431,6 +414,7 @@ GSF_local_client_transmit_ (struct GSF_LocalClient *lc, | |||
431 | res = GNUNET_malloc (sizeof (struct ClientResponse) + msize); | 414 | res = GNUNET_malloc (sizeof (struct ClientResponse) + msize); |
432 | res->lc = lc; | 415 | res->lc = lc; |
433 | res->msize = msize; | 416 | res->msize = msize; |
417 | memcpy (&res[1], msg, msize); | ||
434 | GNUNET_CONTAINER_DLL_insert_tail (lc->res_head, | 418 | GNUNET_CONTAINER_DLL_insert_tail (lc->res_head, |
435 | lc->res_tail, | 419 | lc->res_tail, |
436 | res); | 420 | res); |