diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-05 18:38:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-05 18:38:41 +0000 |
commit | 91f269212bf40fd8ca90c3a68b5bead624728b44 (patch) | |
tree | 43eab6e66a935838e893876c412940e48afaa108 /src/conversation | |
parent | 23fe13890f31317cc2ab86ef55264622ed72375f (diff) | |
download | gnunet-91f269212bf40fd8ca90c3a68b5bead624728b44.tar.gz gnunet-91f269212bf40fd8ca90c3a68b5bead624728b44.zip |
-fix double frees
Diffstat (limited to 'src/conversation')
-rw-r--r-- | src/conversation/gnunet-service-conversation.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c index 1e6fb10d9..daf51b54e 100644 --- a/src/conversation/gnunet-service-conversation.c +++ b/src/conversation/gnunet-service-conversation.c | |||
@@ -294,6 +294,9 @@ handle_client_pickup_message (void *cls, | |||
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | line->status = LS_CALLEE_CONNECTED; | 296 | line->status = LS_CALLEE_CONNECTED; |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
298 | "Sending PICK_UP message to client with meta data `%s'\n", | ||
299 | meta); | ||
297 | e = GNUNET_MQ_msg_extra (mppm, | 300 | e = GNUNET_MQ_msg_extra (mppm, |
298 | len, | 301 | len, |
299 | GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP); | 302 | GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP); |
@@ -311,6 +314,8 @@ handle_client_pickup_message (void *cls, | |||
311 | static void | 314 | static void |
312 | destroy_line_mesh_tunnels (struct Line *line) | 315 | destroy_line_mesh_tunnels (struct Line *line) |
313 | { | 316 | { |
317 | struct GNUNET_MESH_Tunnel *t; | ||
318 | |||
314 | if (NULL != line->reliable_mq) | 319 | if (NULL != line->reliable_mq) |
315 | { | 320 | { |
316 | GNUNET_MQ_destroy (line->reliable_mq); | 321 | GNUNET_MQ_destroy (line->reliable_mq); |
@@ -321,15 +326,15 @@ destroy_line_mesh_tunnels (struct Line *line) | |||
321 | GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth); | 326 | GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth); |
322 | line->unreliable_mth = NULL; | 327 | line->unreliable_mth = NULL; |
323 | } | 328 | } |
324 | if (NULL != line->tunnel_unreliable) | 329 | if (NULL != (t = line->tunnel_unreliable)) |
325 | { | 330 | { |
326 | GNUNET_MESH_tunnel_destroy (line->tunnel_unreliable); | ||
327 | line->tunnel_unreliable = NULL; | 331 | line->tunnel_unreliable = NULL; |
332 | GNUNET_MESH_tunnel_destroy (t); | ||
328 | } | 333 | } |
329 | if (NULL != line->tunnel_reliable) | 334 | if (NULL != (t = line->tunnel_reliable)) |
330 | { | 335 | { |
331 | GNUNET_MESH_tunnel_destroy (line->tunnel_reliable); | ||
332 | line->tunnel_reliable = NULL; | 336 | line->tunnel_reliable = NULL; |
337 | GNUNET_MESH_tunnel_destroy (t); | ||
333 | } | 338 | } |
334 | } | 339 | } |
335 | 340 | ||
@@ -368,11 +373,6 @@ mq_done_finish_caller_shutdown (void *cls) | |||
368 | break; | 373 | break; |
369 | case LS_CALLER_SHUTDOWN: | 374 | case LS_CALLER_SHUTDOWN: |
370 | destroy_line_mesh_tunnels (line); | 375 | destroy_line_mesh_tunnels (line); |
371 | GNUNET_CONTAINER_DLL_remove (lines_head, | ||
372 | lines_tail, | ||
373 | line); | ||
374 | GNUNET_free_non_null (line->audio_data); | ||
375 | GNUNET_free (line); | ||
376 | break; | 376 | break; |
377 | } | 377 | } |
378 | } | 378 | } |
@@ -440,6 +440,9 @@ handle_client_hangup_message (void *cls, | |||
440 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 440 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
441 | return; | 441 | return; |
442 | } | 442 | } |
443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
444 | "Sending HANG_UP message via mesh with meta data `%s'\n", | ||
445 | meta); | ||
443 | e = GNUNET_MQ_msg_extra (mhum, | 446 | e = GNUNET_MQ_msg_extra (mhum, |
444 | len, | 447 | len, |
445 | GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP); | 448 | GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP); |
@@ -511,6 +514,8 @@ handle_client_call_message (void *cls, | |||
511 | GNUNET_CRYPTO_ecc_sign (&msg->caller_id, | 514 | GNUNET_CRYPTO_ecc_sign (&msg->caller_id, |
512 | &ring->purpose, | 515 | &ring->purpose, |
513 | &ring->signature); | 516 | &ring->signature); |
517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
518 | "Sending RING message via mesh\n"); | ||
514 | GNUNET_MQ_send (line->reliable_mq, e); | 519 | GNUNET_MQ_send (line->reliable_mq, e); |
515 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 520 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
516 | } | 521 | } |
@@ -545,6 +550,9 @@ transmit_line_audio (void *cls, | |||
545 | memcpy (&mam[1], line->audio_data, line->audio_size); | 550 | memcpy (&mam[1], line->audio_data, line->audio_size); |
546 | GNUNET_free (line->audio_data); | 551 | GNUNET_free (line->audio_data); |
547 | line->audio_data = NULL; | 552 | line->audio_data = NULL; |
553 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
554 | "Sending %u bytes of audio data via mesh\n", | ||
555 | line->audio_size); | ||
548 | return sizeof (struct MeshAudioMessage) + line->audio_size; | 556 | return sizeof (struct MeshAudioMessage) + line->audio_size; |
549 | } | 557 | } |
550 | 558 | ||
@@ -701,6 +709,8 @@ handle_mesh_ring_message (void *cls, | |||
701 | cring.header.size = htons (sizeof (cring)); | 709 | cring.header.size = htons (sizeof (cring)); |
702 | cring.reserved = htonl (0); | 710 | cring.reserved = htonl (0); |
703 | cring.caller_id = msg->caller_id; | 711 | cring.caller_id = msg->caller_id; |
712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
713 | "Sending RING message to client\n"); | ||
704 | GNUNET_SERVER_notification_context_unicast (nc, | 714 | GNUNET_SERVER_notification_context_unicast (nc, |
705 | line->client, | 715 | line->client, |
706 | &cring.header, | 716 | &cring.header, |
@@ -781,6 +791,9 @@ handle_mesh_hangup_message (void *cls, | |||
781 | hup->header.size = sizeof (buf); | 791 | hup->header.size = sizeof (buf); |
782 | hup->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | 792 | hup->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); |
783 | memcpy (&hup[1], reason, len); | 793 | memcpy (&hup[1], reason, len); |
794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
795 | "Sending HANG UP message to client with reason `%s'\n", | ||
796 | reason); | ||
784 | GNUNET_SERVER_notification_context_unicast (nc, | 797 | GNUNET_SERVER_notification_context_unicast (nc, |
785 | line->client, | 798 | line->client, |
786 | &hup->header, | 799 | &hup->header, |
@@ -859,6 +872,9 @@ handle_mesh_pickup_message (void *cls, | |||
859 | pick->header.size = sizeof (buf); | 872 | pick->header.size = sizeof (buf); |
860 | pick->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP); | 873 | pick->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP); |
861 | memcpy (&pick[1], metadata, len); | 874 | memcpy (&pick[1], metadata, len); |
875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
876 | "Sending PICK UP message via mesh with metadata `%s'\n", | ||
877 | metadata); | ||
862 | GNUNET_SERVER_notification_context_unicast (nc, | 878 | GNUNET_SERVER_notification_context_unicast (nc, |
863 | line->client, | 879 | line->client, |
864 | &pick->header, | 880 | &pick->header, |
@@ -899,10 +915,6 @@ handle_mesh_busy_message (void *cls, | |||
899 | } | 915 | } |
900 | busy.header.size = sizeof (busy); | 916 | busy.header.size = sizeof (busy); |
901 | busy.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_BUSY); | 917 | busy.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_BUSY); |
902 | GNUNET_SERVER_notification_context_unicast (nc, | ||
903 | line->client, | ||
904 | &busy.header, | ||
905 | GNUNET_NO); | ||
906 | GNUNET_MESH_receive_done (tunnel); | 918 | GNUNET_MESH_receive_done (tunnel); |
907 | *tunnel_ctx = NULL; | 919 | *tunnel_ctx = NULL; |
908 | switch (line->status) | 920 | switch (line->status) |
@@ -920,14 +932,22 @@ handle_mesh_busy_message (void *cls, | |||
920 | GNUNET_break_op (0); | 932 | GNUNET_break_op (0); |
921 | break; | 933 | break; |
922 | case LS_CALLER_CALLING: | 934 | case LS_CALLER_CALLING: |
935 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
936 | "Sending BUSY message to client\n"); | ||
937 | GNUNET_SERVER_notification_context_unicast (nc, | ||
938 | line->client, | ||
939 | &busy.header, | ||
940 | GNUNET_NO); | ||
923 | line->status = LS_CALLER_SHUTDOWN; | 941 | line->status = LS_CALLER_SHUTDOWN; |
924 | mq_done_finish_caller_shutdown (line); | 942 | mq_done_finish_caller_shutdown (line); |
925 | break; | 943 | break; |
926 | case LS_CALLER_CONNECTED: | 944 | case LS_CALLER_CONNECTED: |
945 | GNUNET_break_op (0); | ||
927 | line->status = LS_CALLER_SHUTDOWN; | 946 | line->status = LS_CALLER_SHUTDOWN; |
928 | mq_done_finish_caller_shutdown (line); | 947 | mq_done_finish_caller_shutdown (line); |
929 | break; | 948 | break; |
930 | case LS_CALLER_SHUTDOWN: | 949 | case LS_CALLER_SHUTDOWN: |
950 | GNUNET_break_op (0); | ||
931 | mq_done_finish_caller_shutdown (line); | 951 | mq_done_finish_caller_shutdown (line); |
932 | break; | 952 | break; |
933 | } | 953 | } |
@@ -980,6 +1000,9 @@ handle_mesh_audio_message (void *cls, | |||
980 | line->tunnel_unreliable = tunnel; | 1000 | line->tunnel_unreliable = tunnel; |
981 | *tunnel_ctx = line; | 1001 | *tunnel_ctx = line; |
982 | } | 1002 | } |
1003 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1004 | "Forwarding %u bytes of AUDIO data to client\n", | ||
1005 | msize); | ||
983 | cam = (struct ClientAudioMessage *) buf; | 1006 | cam = (struct ClientAudioMessage *) buf; |
984 | cam->header.size = htons (sizeof (buf)); | 1007 | cam->header.size = htons (sizeof (buf)); |
985 | cam->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); | 1008 | cam->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); |
@@ -1070,18 +1093,9 @@ inbound_end (void *cls, | |||
1070 | &hup.header, | 1093 | &hup.header, |
1071 | GNUNET_NO); | 1094 | GNUNET_NO); |
1072 | destroy_line_mesh_tunnels (line); | 1095 | destroy_line_mesh_tunnels (line); |
1073 | GNUNET_CONTAINER_DLL_remove (lines_head, | ||
1074 | lines_tail, | ||
1075 | line); | ||
1076 | GNUNET_free_non_null (line->audio_data); | ||
1077 | GNUNET_free (line); | ||
1078 | break; | 1096 | break; |
1079 | case LS_CALLER_SHUTDOWN: | 1097 | case LS_CALLER_SHUTDOWN: |
1080 | destroy_line_mesh_tunnels (line); | 1098 | destroy_line_mesh_tunnels (line); |
1081 | GNUNET_CONTAINER_DLL_remove (lines_head, | ||
1082 | lines_tail, | ||
1083 | line); | ||
1084 | GNUNET_free (line); | ||
1085 | break; | 1099 | break; |
1086 | } | 1100 | } |
1087 | } | 1101 | } |
@@ -1104,11 +1118,15 @@ handle_client_disconnect (void *cls, | |||
1104 | line = GNUNET_SERVER_client_get_user_context (client, struct Line); | 1118 | line = GNUNET_SERVER_client_get_user_context (client, struct Line); |
1105 | if (NULL == line) | 1119 | if (NULL == line) |
1106 | return; | 1120 | return; |
1121 | GNUNET_SERVER_client_set_user_context (client, NULL); | ||
1122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1123 | "Client disconnected, closing line\n"); | ||
1107 | GNUNET_CONTAINER_DLL_remove (lines_head, | 1124 | GNUNET_CONTAINER_DLL_remove (lines_head, |
1108 | lines_tail, | 1125 | lines_tail, |
1109 | line); | 1126 | line); |
1127 | destroy_line_mesh_tunnels (line); | ||
1128 | GNUNET_free_non_null (line->audio_data); | ||
1110 | GNUNET_free (line); | 1129 | GNUNET_free (line); |
1111 | GNUNET_SERVER_client_set_user_context (client, NULL); | ||
1112 | } | 1130 | } |
1113 | 1131 | ||
1114 | 1132 | ||