diff options
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r-- | src/transport/plugin_transport_unix.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 4e153aab4..f5ab3a694 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -452,7 +452,7 @@ struct LookupCtx | |||
452 | * @param value a session | 452 | * @param value a session |
453 | * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success | 453 | * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success |
454 | */ | 454 | */ |
455 | static int | 455 | static int |
456 | lookup_session_it (void *cls, | 456 | lookup_session_it (void *cls, |
457 | const struct GNUNET_PeerIdentity * key, | 457 | const struct GNUNET_PeerIdentity * key, |
458 | void *value) | 458 | void *value) |
@@ -486,8 +486,8 @@ lookup_session_it (void *cls, | |||
486 | * @return NULL if session was not found | 486 | * @return NULL if session was not found |
487 | */ | 487 | */ |
488 | static struct Session * | 488 | static struct Session * |
489 | lookup_session (struct Plugin *plugin, | 489 | lookup_session (struct Plugin *plugin, |
490 | const struct GNUNET_PeerIdentity *sender, | 490 | const struct GNUNET_PeerIdentity *sender, |
491 | const struct UnixAddress *ua, size_t ua_len) | 491 | const struct UnixAddress *ua, size_t ua_len) |
492 | { | 492 | { |
493 | struct LookupCtx lctx; | 493 | struct LookupCtx lctx; |
@@ -498,7 +498,7 @@ lookup_session (struct Plugin *plugin, | |||
498 | lctx.s = NULL; | 498 | lctx.s = NULL; |
499 | lctx.ua = ua; | 499 | lctx.ua = ua; |
500 | lctx.ua_len = ua_len; | 500 | lctx.ua_len = ua_len; |
501 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, | 501 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, |
502 | sender, | 502 | sender, |
503 | &lookup_session_it, &lctx); | 503 | &lookup_session_it, &lctx); |
504 | return lctx.s; | 504 | return lctx.s; |
@@ -520,9 +520,9 @@ disconnect_session (struct Session *s) | |||
520 | struct UNIXMessageWrapper *next; | 520 | struct UNIXMessageWrapper *next; |
521 | int removed; | 521 | int removed; |
522 | 522 | ||
523 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 523 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
524 | "Disconnecting session for peer `%s' `%s'\n", | 524 | "Disconnecting session for peer `%s' `%s'\n", |
525 | GNUNET_i2s (&s->target), | 525 | GNUNET_i2s (&s->target), |
526 | s->addr); | 526 | s->addr); |
527 | plugin->env->session_end (plugin->env->cls, &s->target, s); | 527 | plugin->env->session_end (plugin->env->cls, &s->target, s); |
528 | removed = GNUNET_NO; | 528 | removed = GNUNET_NO; |
@@ -539,11 +539,11 @@ disconnect_session (struct Session *s) | |||
539 | msgw->payload, 0); | 539 | msgw->payload, 0); |
540 | GNUNET_free (msgw->msg); | 540 | GNUNET_free (msgw->msg); |
541 | GNUNET_free (msgw); | 541 | GNUNET_free (msgw); |
542 | removed = GNUNET_YES; | 542 | removed = GNUNET_YES; |
543 | } | 543 | } |
544 | GNUNET_assert (GNUNET_YES == | 544 | GNUNET_assert (GNUNET_YES == |
545 | GNUNET_CONTAINER_multipeermap_remove (plugin->session_map, | 545 | GNUNET_CONTAINER_multipeermap_remove (plugin->session_map, |
546 | &s->target, | 546 | &s->target, |
547 | s)); | 547 | s)); |
548 | GNUNET_STATISTICS_set (plugin->env->stats, | 548 | GNUNET_STATISTICS_set (plugin->env->stats, |
549 | "# UNIX sessions active", | 549 | "# UNIX sessions active", |
@@ -671,7 +671,7 @@ resend: | |||
671 | 671 | ||
672 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 672 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
673 | "UNIX transmit %u-byte message to %s (%d: %s)\n", | 673 | "UNIX transmit %u-byte message to %s (%d: %s)\n", |
674 | (unsigned int) msgbuf_size, | 674 | (unsigned int) msgbuf_size, |
675 | GNUNET_a2s ((const struct sockaddr *)un, un_len), | 675 | GNUNET_a2s ((const struct sockaddr *)un, un_len), |
676 | (int) sent, | 676 | (int) sent, |
677 | (sent < 0) ? STRERROR (errno) : "ok"); | 677 | (sent < 0) ? STRERROR (errno) : "ok"); |
@@ -684,7 +684,7 @@ resend: | |||
684 | * Closure for 'get_session_it'. | 684 | * Closure for 'get_session_it'. |
685 | */ | 685 | */ |
686 | struct GetSessionIteratorContext | 686 | struct GetSessionIteratorContext |
687 | { | 687 | { |
688 | /** | 688 | /** |
689 | * Location to store the session, if found. | 689 | * Location to store the session, if found. |
690 | */ | 690 | */ |
@@ -711,8 +711,8 @@ struct GetSessionIteratorContext | |||
711 | * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success | 711 | * @return GNUNET_YES if not found (continue looking), GNUNET_NO on success |
712 | */ | 712 | */ |
713 | static int | 713 | static int |
714 | get_session_it (void *cls, | 714 | get_session_it (void *cls, |
715 | const struct GNUNET_PeerIdentity *key, | 715 | const struct GNUNET_PeerIdentity *key, |
716 | void *value) | 716 | void *value) |
717 | { | 717 | { |
718 | struct GetSessionIteratorContext *gsi = cls; | 718 | struct GetSessionIteratorContext *gsi = cls; |
@@ -735,11 +735,11 @@ get_session_it (void *cls, | |||
735 | * @param tc scheduler context | 735 | * @param tc scheduler context |
736 | */ | 736 | */ |
737 | static void | 737 | static void |
738 | session_timeout (void *cls, | 738 | session_timeout (void *cls, |
739 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 739 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
740 | { | 740 | { |
741 | struct Session *s = cls; | 741 | struct Session *s = cls; |
742 | 742 | ||
743 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 743 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
744 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 744 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
745 | "Session %p was idle for %s, disconnecting\n", | 745 | "Session %p was idle for %s, disconnecting\n", |
@@ -758,7 +758,7 @@ session_timeout (void *cls, | |||
758 | * @return the network type in HBO or GNUNET_SYSERR | 758 | * @return the network type in HBO or GNUNET_SYSERR |
759 | */ | 759 | */ |
760 | static enum GNUNET_ATS_Network_Type | 760 | static enum GNUNET_ATS_Network_Type |
761 | unix_get_network (void *cls, | 761 | unix_get_network (void *cls, |
762 | struct Session *session) | 762 | struct Session *session) |
763 | { | 763 | { |
764 | GNUNET_assert (NULL != session); | 764 | GNUNET_assert (NULL != session); |
@@ -818,12 +818,12 @@ unix_plugin_get_session (void *cls, | |||
818 | gsi.address = (const char *) address->address; | 818 | gsi.address = (const char *) address->address; |
819 | gsi.addrlen = address->address_length; | 819 | gsi.addrlen = address->address_length; |
820 | gsi.res = NULL; | 820 | gsi.res = NULL; |
821 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, | 821 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, |
822 | &address->peer, | 822 | &address->peer, |
823 | &get_session_it, &gsi); | 823 | &get_session_it, &gsi); |
824 | if (NULL != gsi.res) | 824 | if (NULL != gsi.res) |
825 | { | 825 | { |
826 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 826 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
827 | "Found existing session\n"); | 827 | "Found existing session\n"); |
828 | return gsi.res; | 828 | return gsi.res; |
829 | } | 829 | } |
@@ -893,23 +893,23 @@ unix_plugin_send (void *cls, | |||
893 | struct UNIXMessageWrapper *wrapper; | 893 | struct UNIXMessageWrapper *wrapper; |
894 | struct UNIXMessage *message; | 894 | struct UNIXMessage *message; |
895 | int ssize; | 895 | int ssize; |
896 | 896 | ||
897 | GNUNET_assert (NULL != plugin); | 897 | GNUNET_assert (NULL != plugin); |
898 | GNUNET_assert (NULL != session); | 898 | GNUNET_assert (NULL != session); |
899 | 899 | ||
900 | if (GNUNET_OK != | 900 | if (GNUNET_OK != |
901 | GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map, | 901 | GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map, |
902 | &session->target, | 902 | &session->target, |
903 | session)) | 903 | session)) |
904 | { | 904 | { |
905 | LOG (GNUNET_ERROR_TYPE_ERROR, | 905 | LOG (GNUNET_ERROR_TYPE_ERROR, |
906 | "Invalid session for peer `%s' `%s'\n", | 906 | "Invalid session for peer `%s' `%s'\n", |
907 | GNUNET_i2s (&session->target), | 907 | GNUNET_i2s (&session->target), |
908 | (const char *) session->addr); | 908 | (const char *) session->addr); |
909 | GNUNET_break (0); | 909 | GNUNET_break (0); |
910 | return GNUNET_SYSERR; | 910 | return GNUNET_SYSERR; |
911 | } | 911 | } |
912 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 912 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
913 | "Sending %u bytes with session for peer `%s' `%s'\n", | 913 | "Sending %u bytes with session for peer `%s' `%s'\n", |
914 | msgbuf_size, | 914 | msgbuf_size, |
915 | GNUNET_i2s (&session->target), | 915 | GNUNET_i2s (&session->target), |
@@ -931,13 +931,13 @@ unix_plugin_send (void *cls, | |||
931 | wrapper->cont = cont; | 931 | wrapper->cont = cont; |
932 | wrapper->cont_cls = cont_cls; | 932 | wrapper->cont_cls = cont_cls; |
933 | wrapper->session = session; | 933 | wrapper->session = session; |
934 | GNUNET_CONTAINER_DLL_insert (plugin->msg_head, | 934 | GNUNET_CONTAINER_DLL_insert (plugin->msg_head, |
935 | plugin->msg_tail, | 935 | plugin->msg_tail, |
936 | wrapper); | 936 | wrapper); |
937 | plugin->bytes_in_queue += ssize; | 937 | plugin->bytes_in_queue += ssize; |
938 | GNUNET_STATISTICS_set (plugin->env->stats, | 938 | GNUNET_STATISTICS_set (plugin->env->stats, |
939 | "# bytes currently in UNIX buffers", | 939 | "# bytes currently in UNIX buffers", |
940 | plugin->bytes_in_queue, | 940 | plugin->bytes_in_queue, |
941 | GNUNET_NO); | 941 | GNUNET_NO); |
942 | if (GNUNET_NO == plugin->with_ws) | 942 | if (GNUNET_NO == plugin->with_ws) |
943 | reschedule_select (plugin); | 943 | reschedule_select (plugin); |
@@ -1101,25 +1101,25 @@ unix_plugin_select_write (struct Plugin *plugin) | |||
1101 | break; /* Message is ready for sending */ | 1101 | break; /* Message is ready for sending */ |
1102 | /* Message has a timeout */ | 1102 | /* Message has a timeout */ |
1103 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1103 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1104 | "Timeout for message with %u bytes \n", | 1104 | "Timeout for message with %u bytes \n", |
1105 | (unsigned int) msgw->msgsize); | 1105 | (unsigned int) msgw->msgsize); |
1106 | GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw); | 1106 | GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw); |
1107 | plugin->bytes_in_queue -= msgw->msgsize; | 1107 | plugin->bytes_in_queue -= msgw->msgsize; |
1108 | GNUNET_STATISTICS_set (plugin->env->stats, | 1108 | GNUNET_STATISTICS_set (plugin->env->stats, |
1109 | "# bytes currently in UNIX buffers", | 1109 | "# bytes currently in UNIX buffers", |
1110 | plugin->bytes_in_queue, GNUNET_NO); | 1110 | plugin->bytes_in_queue, GNUNET_NO); |
1111 | GNUNET_STATISTICS_update (plugin->env->stats, | 1111 | GNUNET_STATISTICS_update (plugin->env->stats, |
1112 | "# UNIX bytes discarded", | 1112 | "# UNIX bytes discarded", |
1113 | msgw->msgsize, | 1113 | msgw->msgsize, |
1114 | GNUNET_NO); | 1114 | GNUNET_NO); |
1115 | if (NULL != msgw->cont) | 1115 | if (NULL != msgw->cont) |
1116 | msgw->cont (msgw->cont_cls, | 1116 | msgw->cont (msgw->cont_cls, |
1117 | &msgw->session->target, | 1117 | &msgw->session->target, |
1118 | GNUNET_SYSERR, | 1118 | GNUNET_SYSERR, |
1119 | msgw->payload, | 1119 | msgw->payload, |
1120 | 0); | 1120 | 0); |
1121 | GNUNET_free (msgw->msg); | 1121 | GNUNET_free (msgw->msg); |
1122 | GNUNET_free (msgw); | 1122 | GNUNET_free (msgw); |
1123 | } | 1123 | } |
1124 | if (NULL == msgw) | 1124 | if (NULL == msgw) |
1125 | return; /* Nothing to send at the moment */ | 1125 | return; /* Nothing to send at the moment */ |
@@ -1153,7 +1153,7 @@ unix_plugin_select_write (struct Plugin *plugin) | |||
1153 | 1153 | ||
1154 | GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); | 1154 | GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); |
1155 | plugin->bytes_in_queue -= msgw->msgsize; | 1155 | plugin->bytes_in_queue -= msgw->msgsize; |
1156 | GNUNET_STATISTICS_set (plugin->env->stats, | 1156 | GNUNET_STATISTICS_set (plugin->env->stats, |
1157 | "# bytes currently in UNIX buffers", | 1157 | "# bytes currently in UNIX buffers", |
1158 | plugin->bytes_in_queue, GNUNET_NO); | 1158 | plugin->bytes_in_queue, GNUNET_NO); |
1159 | GNUNET_STATISTICS_update (plugin->env->stats, | 1159 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -1167,9 +1167,9 @@ unix_plugin_select_write (struct Plugin *plugin) | |||
1167 | } | 1167 | } |
1168 | /* successfully sent bytes */ | 1168 | /* successfully sent bytes */ |
1169 | GNUNET_break (sent > 0); | 1169 | GNUNET_break (sent > 0); |
1170 | GNUNET_CONTAINER_DLL_remove (plugin->msg_head, | 1170 | GNUNET_CONTAINER_DLL_remove (plugin->msg_head, |
1171 | plugin->msg_tail, | 1171 | plugin->msg_tail, |
1172 | msgw); | 1172 | msgw); |
1173 | GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); | 1173 | GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize); |
1174 | plugin->bytes_in_queue -= msgw->msgsize; | 1174 | plugin->bytes_in_queue -= msgw->msgsize; |
1175 | GNUNET_STATISTICS_set (plugin->env->stats, | 1175 | GNUNET_STATISTICS_set (plugin->env->stats, |
@@ -1179,12 +1179,12 @@ unix_plugin_select_write (struct Plugin *plugin) | |||
1179 | GNUNET_STATISTICS_update (plugin->env->stats, | 1179 | GNUNET_STATISTICS_update (plugin->env->stats, |
1180 | "# bytes transmitted via UNIX", | 1180 | "# bytes transmitted via UNIX", |
1181 | msgw->msgsize, | 1181 | msgw->msgsize, |
1182 | GNUNET_NO); | 1182 | GNUNET_NO); |
1183 | if (NULL != msgw->cont) | 1183 | if (NULL != msgw->cont) |
1184 | msgw->cont (msgw->cont_cls, &msgw->session->target, | 1184 | msgw->cont (msgw->cont_cls, &msgw->session->target, |
1185 | GNUNET_OK, | 1185 | GNUNET_OK, |
1186 | msgw->payload, | 1186 | msgw->payload, |
1187 | msgw->msgsize); | 1187 | msgw->msgsize); |
1188 | GNUNET_free (msgw->msg); | 1188 | GNUNET_free (msgw->msg); |
1189 | GNUNET_free (msgw); | 1189 | GNUNET_free (msgw); |
1190 | } | 1190 | } |
@@ -1553,8 +1553,8 @@ reschedule_session_timeout (struct Session *s) | |||
1553 | * @return GNUNET_YES (always, continue to iterate) | 1553 | * @return GNUNET_YES (always, continue to iterate) |
1554 | */ | 1554 | */ |
1555 | static int | 1555 | static int |
1556 | get_session_delete_it (void *cls, | 1556 | get_session_delete_it (void *cls, |
1557 | const struct GNUNET_PeerIdentity *key, | 1557 | const struct GNUNET_PeerIdentity *key, |
1558 | void *value) | 1558 | void *value) |
1559 | { | 1559 | { |
1560 | struct Session *s = value; | 1560 | struct Session *s = value; |
@@ -1572,14 +1572,14 @@ get_session_delete_it (void *cls, | |||
1572 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed | 1572 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed |
1573 | */ | 1573 | */ |
1574 | static void | 1574 | static void |
1575 | unix_disconnect (void *cls, | 1575 | unix_disconnect (void *cls, |
1576 | const struct GNUNET_PeerIdentity *target) | 1576 | const struct GNUNET_PeerIdentity *target) |
1577 | { | 1577 | { |
1578 | struct Plugin *plugin = cls; | 1578 | struct Plugin *plugin = cls; |
1579 | 1579 | ||
1580 | GNUNET_assert (plugin != NULL); | 1580 | GNUNET_assert (plugin != NULL); |
1581 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, | 1581 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, |
1582 | target, | 1582 | target, |
1583 | &get_session_delete_it, plugin); | 1583 | &get_session_delete_it, plugin); |
1584 | } | 1584 | } |
1585 | 1585 | ||
@@ -1618,7 +1618,7 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1618 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1618 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1619 | plugin->port = port; | 1619 | plugin->port = port; |
1620 | plugin->env = env; | 1620 | plugin->env = env; |
1621 | GNUNET_asprintf (&plugin->unix_socket_path, | 1621 | GNUNET_asprintf (&plugin->unix_socket_path, |
1622 | "/tmp/unix-plugin-sock.%d", | 1622 | "/tmp/unix-plugin-sock.%d", |
1623 | plugin->port); | 1623 | plugin->port); |
1624 | 1624 | ||