diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 17:26:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 17:26:53 +0000 |
commit | f64dd0f4f8b31ca939519efaab5cb001ee76cb1f (patch) | |
tree | 0a26678cc6628701691498dfbba11962c015f3ec /src/transport/plugin_transport_http_client.c | |
parent | d11a7abfaf81303da7e166268200873b17caa6bc (diff) | |
download | gnunet-f64dd0f4f8b31ca939519efaab5cb001ee76cb1f.tar.gz gnunet-f64dd0f4f8b31ca939519efaab5cb001ee76cb1f.zip |
-doxygen, indentation
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 194 |
1 files changed, 107 insertions, 87 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 74d9f308c..f70393595 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -97,7 +97,7 @@ struct HTTP_Message | |||
97 | GNUNET_TRANSPORT_TransmitContinuation transmit_cont; | 97 | GNUNET_TRANSPORT_TransmitContinuation transmit_cont; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Closure for transmit_cont. | 100 | * Closure for @e transmit_cont. |
101 | */ | 101 | */ |
102 | void *transmit_cont_cls; | 102 | void *transmit_cont_cls; |
103 | }; | 103 | }; |
@@ -159,11 +159,6 @@ struct Session | |||
159 | struct GNUNET_HELLO_Address *address; | 159 | struct GNUNET_HELLO_Address *address; |
160 | 160 | ||
161 | /** | 161 | /** |
162 | * ATS network type in NBO | ||
163 | */ | ||
164 | uint32_t ats_address_network_type; | ||
165 | |||
166 | /** | ||
167 | * Pointer to the global plugin struct. | 162 | * Pointer to the global plugin struct. |
168 | */ | 163 | */ |
169 | struct HTTP_Client_Plugin *plugin; | 164 | struct HTTP_Client_Plugin *plugin; |
@@ -173,40 +168,20 @@ struct Session | |||
173 | */ | 168 | */ |
174 | void *client_put; | 169 | void *client_put; |
175 | 170 | ||
176 | struct ConnectionHandle put; | ||
177 | struct ConnectionHandle get; | ||
178 | |||
179 | /** | 171 | /** |
180 | * Is the client PUT handle currently paused | 172 | * Handle for the HTTP PUT request. |
181 | */ | 173 | */ |
182 | int put_paused; | 174 | struct ConnectionHandle put; |
183 | |||
184 | /** | ||
185 | * Is the client PUT handle disconnect in progress? | ||
186 | */ | ||
187 | int put_tmp_disconnecting; | ||
188 | |||
189 | /** | ||
190 | * Is the client PUT handle temporarily disconnected? | ||
191 | */ | ||
192 | int put_tmp_disconnected; | ||
193 | 175 | ||
194 | /** | 176 | /** |
195 | * We received data to send while disconnecting, reconnect immediately | 177 | * Handle for the HTTP GET request. |
196 | */ | 178 | */ |
197 | int put_reconnect_required; | 179 | struct ConnectionHandle get; |
198 | 180 | ||
199 | /** | 181 | /** |
200 | * Client receive handle | 182 | * Client receive handle |
201 | */ | 183 | */ |
202 | void *client_get; | 184 | void *client_get; |
203 | |||
204 | /** | ||
205 | * Outbound overhead due to HTTP connection | ||
206 | * Add to next message of this session when calling callback | ||
207 | */ | ||
208 | size_t overhead; | ||
209 | |||
210 | /** | 185 | /** |
211 | * next pointer for double linked list | 186 | * next pointer for double linked list |
212 | */ | 187 | */ |
@@ -242,6 +217,37 @@ struct Session | |||
242 | * Used for receive throttling | 217 | * Used for receive throttling |
243 | */ | 218 | */ |
244 | struct GNUNET_TIME_Absolute next_receive; | 219 | struct GNUNET_TIME_Absolute next_receive; |
220 | |||
221 | /** | ||
222 | * Outbound overhead due to HTTP connection | ||
223 | * Add to next message of this session when calling callback | ||
224 | */ | ||
225 | size_t overhead; | ||
226 | |||
227 | /** | ||
228 | * ATS network type in NBO | ||
229 | */ | ||
230 | uint32_t ats_address_network_type; | ||
231 | |||
232 | /** | ||
233 | * Is the client PUT handle currently paused | ||
234 | */ | ||
235 | int put_paused; | ||
236 | |||
237 | /** | ||
238 | * Is the client PUT handle disconnect in progress? | ||
239 | */ | ||
240 | int put_tmp_disconnecting; | ||
241 | |||
242 | /** | ||
243 | * Is the client PUT handle temporarily disconnected? | ||
244 | */ | ||
245 | int put_tmp_disconnected; | ||
246 | |||
247 | /** | ||
248 | * We received data to send while disconnecting, reconnect immediately | ||
249 | */ | ||
250 | int put_reconnect_required; | ||
245 | }; | 251 | }; |
246 | 252 | ||
247 | 253 | ||
@@ -291,6 +297,16 @@ struct HTTP_Client_Plugin | |||
291 | char *proxy_password; | 297 | char *proxy_password; |
292 | 298 | ||
293 | /** | 299 | /** |
300 | * cURL Multihandle | ||
301 | */ | ||
302 | CURLM *curl_multi_handle; | ||
303 | |||
304 | /** | ||
305 | * curl perform task | ||
306 | */ | ||
307 | GNUNET_SCHEDULER_TaskIdentifier client_perform_task; | ||
308 | |||
309 | /** | ||
294 | * Type of proxy server: | 310 | * Type of proxy server: |
295 | * | 311 | * |
296 | * Valid values as supported by curl: | 312 | * Valid values as supported by curl: |
@@ -340,15 +356,6 @@ struct HTTP_Client_Plugin | |||
340 | */ | 356 | */ |
341 | uint16_t use_ipv4; | 357 | uint16_t use_ipv4; |
342 | 358 | ||
343 | /** | ||
344 | * cURL Multihandle | ||
345 | */ | ||
346 | CURLM *curl_multi_handle; | ||
347 | |||
348 | /** | ||
349 | * curl perform task | ||
350 | */ | ||
351 | GNUNET_SCHEDULER_TaskIdentifier client_perform_task; | ||
352 | }; | 359 | }; |
353 | 360 | ||
354 | 361 | ||
@@ -365,10 +372,11 @@ client_reschedule_session_timeout (struct Session *s); | |||
365 | * | 372 | * |
366 | * @param plugin plugin as closure | 373 | * @param plugin plugin as closure |
367 | * @param now schedule task in 1ms, regardless of what curl may say | 374 | * @param now schedule task in 1ms, regardless of what curl may say |
368 | * @return GNUNET_SYSERR for hard failure, GNUNET_OK for ok | 375 | * @return #GNUNET_SYSERR for hard failure, #GNUNET_OK for ok |
369 | */ | 376 | */ |
370 | static int | 377 | static int |
371 | client_schedule (struct HTTP_Client_Plugin *plugin, int now); | 378 | client_schedule (struct HTTP_Client_Plugin *plugin, |
379 | int now); | ||
372 | 380 | ||
373 | 381 | ||
374 | /** | 382 | /** |
@@ -412,51 +420,53 @@ client_exist_session (struct HTTP_Client_Plugin *plugin, | |||
412 | * @return always 0 | 420 | * @return always 0 |
413 | */ | 421 | */ |
414 | static int | 422 | static int |
415 | client_log (CURL *curl, curl_infotype type, | 423 | client_log (CURL *curl, |
416 | const char *data, size_t size, void *cls) | 424 | curl_infotype type, |
425 | const char *data, | ||
426 | size_t size, | ||
427 | void *cls) | ||
417 | { | 428 | { |
418 | struct ConnectionHandle *ch = cls; | 429 | struct ConnectionHandle *ch = cls; |
419 | const char *ttype = "UNSPECIFIED"; | 430 | const char *ttype = "UNSPECIFIED"; |
431 | char text[size + 2]; | ||
420 | 432 | ||
421 | if ((type == CURLINFO_TEXT) || (type == CURLINFO_HEADER_IN) || (type == CURLINFO_HEADER_OUT)) | 433 | if (! ((type == CURLINFO_TEXT) || (type == CURLINFO_HEADER_IN) || (type == CURLINFO_HEADER_OUT))) |
434 | return 0; | ||
435 | switch (type) | ||
422 | { | 436 | { |
423 | char text[size + 2]; | 437 | case CURLINFO_TEXT: |
424 | 438 | ttype = "TEXT"; | |
425 | switch (type) { | 439 | break; |
426 | case CURLINFO_TEXT: | 440 | case CURLINFO_HEADER_IN: |
427 | ttype = "TEXT"; | 441 | ttype = "HEADER_IN"; |
428 | break; | 442 | break; |
429 | case CURLINFO_HEADER_IN: | 443 | case CURLINFO_HEADER_OUT: |
430 | ttype = "HEADER_IN"; | 444 | ttype = "HEADER_OUT"; |
431 | break; | 445 | /* Overhead*/ |
432 | case CURLINFO_HEADER_OUT: | 446 | GNUNET_assert (NULL != ch); |
433 | ttype = "HEADER_OUT"; | 447 | GNUNET_assert (NULL != ch->easyhandle); |
434 | /* Overhead*/ | 448 | GNUNET_assert (NULL != ch->s); |
435 | 449 | ch->s->overhead += size; | |
436 | GNUNET_assert (NULL != ch); | 450 | break; |
437 | GNUNET_assert (NULL != ch->easyhandle); | 451 | default: |
438 | GNUNET_assert (NULL != ch->s); | 452 | ttype = "UNSPECIFIED"; |
439 | ch->s->overhead += size; | 453 | break; |
440 | break; | 454 | } |
441 | default: | 455 | memcpy (text, data, size); |
442 | ttype = "UNSPECIFIED"; | 456 | if (text[size - 1] == '\n') |
443 | break; | 457 | { |
444 | } | 458 | text[size] = '\0'; |
445 | |||
446 | memcpy (text, data, size); | ||
447 | if (text[size - 1] == '\n') | ||
448 | text[size] = '\0'; | ||
449 | else | ||
450 | { | ||
451 | text[size] = '\n'; | ||
452 | text[size + 1] = '\0'; | ||
453 | } | ||
454 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
455 | "Connection %p %s: %s", | ||
456 | ch->easyhandle, | ||
457 | ttype, | ||
458 | text); | ||
459 | } | 459 | } |
460 | else | ||
461 | { | ||
462 | text[size] = '\n'; | ||
463 | text[size + 1] = '\0'; | ||
464 | } | ||
465 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
466 | "Connection %p %s: %s", | ||
467 | ch->easyhandle, | ||
468 | ttype, | ||
469 | text); | ||
460 | return 0; | 470 | return 0; |
461 | } | 471 | } |
462 | 472 | ||
@@ -472,7 +482,7 @@ client_log (CURL *curl, curl_infotype type, | |||
472 | * @param cls closure | 482 | * @param cls closure |
473 | * @param s which session must be used | 483 | * @param s which session must be used |
474 | * @param msgbuf the message to transmit | 484 | * @param msgbuf the message to transmit |
475 | * @param msgbuf_size number of bytes in 'msgbuf' | 485 | * @param msgbuf_size number of bytes in @a msgbuf |
476 | * @param priority how important is the message (most plugins will | 486 | * @param priority how important is the message (most plugins will |
477 | * ignore message priority and just FIFO) | 487 | * ignore message priority and just FIFO) |
478 | * @param to how long to wait at most for the transmission (does not | 488 | * @param to how long to wait at most for the transmission (does not |
@@ -491,7 +501,8 @@ client_log (CURL *curl, curl_infotype type, | |||
491 | static ssize_t | 501 | static ssize_t |
492 | http_client_plugin_send (void *cls, | 502 | http_client_plugin_send (void *cls, |
493 | struct Session *s, | 503 | struct Session *s, |
494 | const char *msgbuf, size_t msgbuf_size, | 504 | const char *msgbuf, |
505 | size_t msgbuf_size, | ||
495 | unsigned int priority, | 506 | unsigned int priority, |
496 | struct GNUNET_TIME_Relative to, | 507 | struct GNUNET_TIME_Relative to, |
497 | GNUNET_TRANSPORT_TransmitContinuation cont, | 508 | GNUNET_TRANSPORT_TransmitContinuation cont, |
@@ -624,7 +635,7 @@ client_delete_session (struct Session *s) | |||
624 | /** | 635 | /** |
625 | * Disconnect a session | 636 | * Disconnect a session |
626 | * | 637 | * |
627 | * @param cls the `struct HTTP_Client_Plugin` | 638 | * @param cls the `struct HTTP_Client_Plugin *` |
628 | * @param s session | 639 | * @param s session |
629 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 640 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
630 | */ | 641 | */ |
@@ -726,7 +737,7 @@ http_client_session_disconnect (void *cls, | |||
726 | 737 | ||
727 | /** | 738 | /** |
728 | * Function that is called to get the keepalive factor. | 739 | * Function that is called to get the keepalive factor. |
729 | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | 740 | * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to |
730 | * calculate the interval between keepalive packets. | 741 | * calculate the interval between keepalive packets. |
731 | * | 742 | * |
732 | * @param cls closure with the `struct Plugin` | 743 | * @param cls closure with the `struct Plugin` |
@@ -798,6 +809,9 @@ client_lookup_session (struct HTTP_Client_Plugin *plugin, | |||
798 | } | 809 | } |
799 | 810 | ||
800 | 811 | ||
812 | /** | ||
813 | * FIXME. | ||
814 | */ | ||
801 | static void | 815 | static void |
802 | client_put_disconnect (void *cls, | 816 | client_put_disconnect (void *cls, |
803 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 817 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -827,7 +841,10 @@ client_put_disconnect (void *cls, | |||
827 | * @return bytes written to stream, returning 0 will terminate connection! | 841 | * @return bytes written to stream, returning 0 will terminate connection! |
828 | */ | 842 | */ |
829 | static size_t | 843 | static size_t |
830 | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | 844 | client_send_cb (void *stream, |
845 | size_t size, | ||
846 | size_t nmemb, | ||
847 | void *cls) | ||
831 | { | 848 | { |
832 | struct Session *s = cls; | 849 | struct Session *s = cls; |
833 | struct HTTP_Client_Plugin *plugin = s->plugin; | 850 | struct HTTP_Client_Plugin *plugin = s->plugin; |
@@ -985,7 +1002,7 @@ client_receive_mst_cb (void *cls, void *client, | |||
985 | 1002 | ||
986 | /** | 1003 | /** |
987 | * Callback method used with libcurl when data for a PUT connection are | 1004 | * Callback method used with libcurl when data for a PUT connection are |
988 | * received. We do not expect data here, so we just dismiss it | 1005 | * received. We do not expect data here, so we just discard it. |
989 | * | 1006 | * |
990 | * @param stream pointer where to write data | 1007 | * @param stream pointer where to write data |
991 | * @param size size of an individual element | 1008 | * @param size size of an individual element |
@@ -994,7 +1011,10 @@ client_receive_mst_cb (void *cls, void *client, | |||
994 | * @return bytes read from stream | 1011 | * @return bytes read from stream |
995 | */ | 1012 | */ |
996 | static size_t | 1013 | static size_t |
997 | client_receive_put (void *stream, size_t size, size_t nmemb, void *cls) | 1014 | client_receive_put (void *stream, |
1015 | size_t size, | ||
1016 | size_t nmemb, | ||
1017 | void *cls) | ||
998 | { | 1018 | { |
999 | return size * nmemb; | 1019 | return size * nmemb; |
1000 | } | 1020 | } |