aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-05-29 09:05:12 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-05-29 09:05:12 +0000
commitcec8e7eee09c84d32e7e8c6ae18d03a43eaa3e13 (patch)
tree7265c035f31625a2d0f631f43bd51128428213a9 /src
parent8c85ee6619a2580c239fe7807368bf8a6a8286fa (diff)
downloadgnunet-cec8e7eee09c84d32e7e8c6ae18d03a43eaa3e13.tar.gz
gnunet-cec8e7eee09c84d32e7e8c6ae18d03a43eaa3e13.zip
- refactorind reverting last fix
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_http.c2
-rw-r--r--src/transport/plugin_transport_http.h22
-rw-r--r--src/transport/plugin_transport_http_server.c40
3 files changed, 29 insertions, 35 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 2bc82d8f0..d55cdb76b 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -601,6 +601,8 @@ delete_session (struct Session *s)
601 s->msg_tk = NULL; 601 s->msg_tk = NULL;
602 } 602 }
603 GNUNET_free (s->addr); 603 GNUNET_free (s->addr);
604 GNUNET_free_non_null (s->server_recv);
605 GNUNET_free_non_null (s->server_send);
604 GNUNET_free (s); 606 GNUNET_free (s);
605} 607}
606 608
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h
index 8ec47fe4c..c3c9367ad 100644
--- a/src/transport/plugin_transport_http.h
+++ b/src/transport/plugin_transport_http.h
@@ -305,6 +305,24 @@ struct IPv6HttpAddress
305}; 305};
306GNUNET_NETWORK_STRUCT_END 306GNUNET_NETWORK_STRUCT_END
307 307
308
309struct ServerConnection
310{
311 /* _RECV or _SEND */
312 int direction;
313
314 /* Should this connection get disconnected? GNUNET_YES/NO */
315 int disconnect;
316
317 /* The session this server connection belongs to */
318 struct Session *session;
319
320 /* The MHD connection */
321 struct MHD_Connection *mhd_conn;
322};
323
324
325
308/** 326/**
309 * Session handle for connections. 327 * Session handle for connections.
310 */ 328 */
@@ -417,12 +435,12 @@ struct Session
417 /** 435 /**
418 * Client send handle 436 * Client send handle
419 */ 437 */
420 void *server_recv; 438 struct ServerConnection *server_recv;
421 439
422 /** 440 /**
423 * Client send handle 441 * Client send handle
424 */ 442 */
425 void *server_send; 443 struct ServerConnection *server_send;
426}; 444};
427 445
428/** 446/**
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index d8383b0a9..58c8fd215 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -32,18 +32,6 @@
32 32
33static struct Plugin * p; 33static struct Plugin * p;
34 34
35struct ServerConnection
36{
37 /* _RECV or _SEND */
38 int direction;
39
40 /* should this connection get disconnected? GNUNET_YES/NO */
41 int disconnect;
42
43 struct Session *session;
44 struct MHD_Connection *mhd_conn;
45};
46
47/** 35/**
48 * Function that queries MHD's select sets and 36 * Function that queries MHD's select sets and
49 * starts the task waiting for them. 37 * starts the task waiting for them.
@@ -540,14 +528,9 @@ create:
540 s = create_session (plugin, &target, a, a_len); 528 s = create_session (plugin, &target, a, a_len);
541 GNUNET_assert (NULL != s); 529 GNUNET_assert (NULL != s);
542 s->ats_address_network_type = ats.value; 530 s->ats_address_network_type = ats.value;
543
544 s->inbound = GNUNET_YES; 531 s->inbound = GNUNET_YES;
545 s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS; 532 s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS;
546 s->tag = tag; 533 s->tag = tag;
547 if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
548 s->server_recv = s;
549 if (0 == strcmp (MHD_HTTP_METHOD_GET, method))
550 s->server_send = s;
551 GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head, 534 GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head,
552 plugin->server_semi_tail, s); 535 plugin->server_semi_tail, s);
553 goto found; 536 goto found;
@@ -853,24 +836,15 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
853int 836int
854server_disconnect (struct Session *s) 837server_disconnect (struct Session *s)
855{ 838{
856 struct Plugin *plugin = s->plugin; 839 if (s->server_send != NULL)
857 struct Session *t = plugin->head;
858
859 while (t != NULL)
860 { 840 {
861 if (t->inbound == GNUNET_YES) 841 ((struct ServerConnection *) s->server_send)->disconnect = GNUNET_YES;
862 { 842 }
863 if (t->server_send != NULL) 843 if (s->server_recv != NULL)
864 { 844 {
865 ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES; 845 ((struct ServerConnection *) s->server_recv)->disconnect = GNUNET_YES;
866 }
867 if (t->server_send != NULL)
868 {
869 ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES;
870 }
871 }
872 t = t->next;
873 } 846 }
847
874 return GNUNET_OK; 848 return GNUNET_OK;
875} 849}
876 850