aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-14 15:55:10 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-14 15:55:10 +0000
commit4dcfba594f22f77667e4e3510e0b6da6a94f786b (patch)
tree0ccf236b5781c9cff4b68ddf333a1defbcfe7acb /src
parent6d5f2d7b3d3daefada86869e8a4b2930f80b7ee3 (diff)
downloadgnunet-4dcfba594f22f77667e4e3510e0b6da6a94f786b.tar.gz
gnunet-4dcfba594f22f77667e4e3510e0b6da6a94f786b.zip
fix mantis 0002653
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_unix.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index b6b6cf35f..4f21cf105 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -548,8 +548,14 @@ resend:
548 548
549 if (GNUNET_SYSERR == sent) 549 if (GNUNET_SYSERR == sent)
550 { 550 {
551 if ((errno == EAGAIN) || (errno == ENOBUFS)) 551 if (errno == EAGAIN)
552 {
553 return RETRY; /* We have to retry later */
554 }
555 if (errno == ENOBUFS)
556 {
552 return RETRY; /* We have to retry later */ 557 return RETRY; /* We have to retry later */
558 }
553 if (errno == EMSGSIZE) 559 if (errno == EMSGSIZE)
554 { 560 {
555 socklen_t size = 0; 561 socklen_t size = 0;
@@ -560,7 +566,7 @@ resend:
560 &len); 566 &len);
561 if (size < msgbuf_size) 567 if (size < msgbuf_size)
562 { 568 {
563 LOG (GNUNET_ERROR_TYPE_DEBUG, 569 LOG (GNUNET_ERROR_TYPE_ERROR,
564 "Trying to increase socket buffer size from %i to %i for message size %i\n", 570 "Trying to increase socket buffer size from %i to %i for message size %i\n",
565 size, ((msgbuf_size / 1000) + 2) * 1000, msgbuf_size); 571 size, ((msgbuf_size / 1000) + 2) * 1000, msgbuf_size);
566 size = ((msgbuf_size / 1000) + 2) * 1000; 572 size = ((msgbuf_size / 1000) + 2) * 1000;
@@ -584,6 +590,7 @@ resend:
584 } 590 }
585 } 591 }
586 } 592 }
593
587 LOG (GNUNET_ERROR_TYPE_DEBUG, 594 LOG (GNUNET_ERROR_TYPE_DEBUG,
588 "UNIX transmit %u-byte message to %s (%d: %s)\n", 595 "UNIX transmit %u-byte message to %s (%d: %s)\n",
589 (unsigned int) msgbuf_size, GNUNET_a2s (sb, sbs), (int) sent, 596 (unsigned int) msgbuf_size, GNUNET_a2s (sb, sbs), (int) sent,
@@ -734,7 +741,7 @@ unix_plugin_send (void *cls,
734 return GNUNET_SYSERR; 741 return GNUNET_SYSERR;
735 } 742 }
736 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u bytes with session for peer `%s' `%s'\n", 743 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending %u bytes with session for peer `%s' `%s'\n",
737 msgbuf_size, 744 msgbuf_size,
738 GNUNET_i2s (&session->target), 745 GNUNET_i2s (&session->target),
739 (char *) session->addr); 746 (char *) session->addr);
740 747
@@ -753,7 +760,7 @@ unix_plugin_send (void *cls,
753 wrapper->msgsize = ssize; 760 wrapper->msgsize = ssize;
754 wrapper->payload = msgbuf_size; 761 wrapper->payload = msgbuf_size;
755 wrapper->priority = priority; 762 wrapper->priority = priority;
756 wrapper->timeout = GNUNET_TIME_relative_to_absolute (to); 763 wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), to);
757 wrapper->cont = cont; 764 wrapper->cont = cont;
758 wrapper->cont_cls = cont_cls; 765 wrapper->cont_cls = cont_cls;
759 wrapper->session = session; 766 wrapper->session = session;
@@ -894,10 +901,8 @@ unix_plugin_select_read (struct Plugin * plugin)
894static void 901static void
895unix_plugin_select_write (struct Plugin * plugin) 902unix_plugin_select_write (struct Plugin * plugin)
896{ 903{
897 static int retry_counter = 0;
898 int sent = 0; 904 int sent = 0;
899 905
900
901 struct UNIXMessageWrapper * msgw = plugin->msg_tail; 906 struct UNIXMessageWrapper * msgw = plugin->msg_tail;
902 while (NULL != msgw) 907 while (NULL != msgw)
903 { 908 {
@@ -906,6 +911,8 @@ unix_plugin_select_write (struct Plugin * plugin)
906 else 911 else
907 { 912 {
908 /* Message has a timeout */ 913 /* Message has a timeout */
914 LOG (GNUNET_ERROR_TYPE_DEBUG,
915 "Timeout for message with %llu bytes \n", msgw->msgsize);
909 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw); 916 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
910 if (NULL != msgw->cont) 917 if (NULL != msgw->cont)
911 msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR, msgw->payload, 0); 918 msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR, msgw->payload, 0);
@@ -938,21 +945,13 @@ unix_plugin_select_write (struct Plugin * plugin)
938 msgw->payload, 945 msgw->payload,
939 msgw->cont, msgw->cont_cls); 946 msgw->cont, msgw->cont_cls);
940 947
941 if (0 == sent) 948 if (RETRY == sent)
942 { 949 {
943 retry_counter ++; 950 GNUNET_STATISTICS_update (plugin->env->stats,"# UNIX retry attempts",
944 if (retry_counter <= MAX_RETRIES) 951 1, GNUNET_NO);
945 {
946 GNUNET_STATISTICS_update (plugin->env->stats,"# UNIX retry attempts",
947 1, GNUNET_NO);
948 return; /* retry */
949 }
950 else
951 sent = GNUNET_SYSERR; /* abort */
952 }
953 retry_counter = 0;
954 952
955 if (GNUNET_SYSERR == sent) 953 }
954 else if (GNUNET_SYSERR == sent)
956 { 955 {
957 /* failed and no retry */ 956 /* failed and no retry */
958 if (NULL != msgw->cont) 957 if (NULL != msgw->cont)
@@ -972,8 +971,7 @@ unix_plugin_select_write (struct Plugin * plugin)
972 GNUNET_free (msgw); 971 GNUNET_free (msgw);
973 return; 972 return;
974 } 973 }
975 974 else if (sent > 0)
976 else if (sent >= 0)
977 { 975 {
978 /* successfully sent bytes */ 976 /* successfully sent bytes */
979 if (NULL != msgw->cont) 977 if (NULL != msgw->cont)