aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-14 14:09:43 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-14 14:09:43 +0000
commit0b911f6f0cb0159a97509b37ce0557942eac9ce9 (patch)
tree665c788dfd2ed8918c43abca9b5c2af52dc35a6e /src/transport/plugin_transport_unix.c
parent053fc309fa633d585a6e1171f06f4dec39930056 (diff)
downloadgnunet-0b911f6f0cb0159a97509b37ce0557942eac9ce9.tar.gz
gnunet-0b911f6f0cb0159a97509b37ce0557942eac9ce9.zip
improve unix timeout behaviour
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index fee1c58c0..d9badf380 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -108,7 +108,7 @@ struct UNIXMessageWrapper
108 size_t msgsize; 108 size_t msgsize;
109 size_t payload; 109 size_t payload;
110 110
111 struct GNUNET_TIME_Relative timeout; 111 struct GNUNET_TIME_Absolute timeout;
112 unsigned int priority; 112 unsigned int priority;
113 113
114 struct Session *session; 114 struct Session *session;
@@ -495,7 +495,7 @@ unix_real_send (void *cls,
495 struct GNUNET_NETWORK_Handle *send_handle, 495 struct GNUNET_NETWORK_Handle *send_handle,
496 const struct GNUNET_PeerIdentity *target, const char *msgbuf, 496 const struct GNUNET_PeerIdentity *target, const char *msgbuf,
497 size_t msgbuf_size, unsigned int priority, 497 size_t msgbuf_size, unsigned int priority,
498 struct GNUNET_TIME_Relative timeout, 498 struct GNUNET_TIME_Absolute timeout,
499 const void *addr, 499 const void *addr,
500 size_t addrlen, 500 size_t addrlen,
501 size_t payload, 501 size_t payload,
@@ -753,7 +753,7 @@ unix_plugin_send (void *cls,
753 wrapper->msgsize = ssize; 753 wrapper->msgsize = ssize;
754 wrapper->payload = msgbuf_size; 754 wrapper->payload = msgbuf_size;
755 wrapper->priority = priority; 755 wrapper->priority = priority;
756 wrapper->timeout = to; 756 wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), to);
757 wrapper->cont = cont; 757 wrapper->cont = cont;
758 wrapper->cont_cls = cont_cls; 758 wrapper->cont_cls = cont_cls;
759 wrapper->session = session; 759 wrapper->session = session;
@@ -896,7 +896,35 @@ unix_plugin_select_write (struct Plugin * plugin)
896{ 896{
897 static int retry_counter = 0; 897 static int retry_counter = 0;
898 int sent = 0; 898 int sent = 0;
899 struct UNIXMessageWrapper * msgw = plugin->msg_head; 899
900
901 struct UNIXMessageWrapper * msgw = plugin->msg_tail;
902 while (NULL != msgw)
903 {
904 if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value > 0)
905 break; /* Message is ready for sending */
906 else
907 {
908 /* Message has a timeout */
909 GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
910 if (NULL != msgw->cont)
911 msgw->cont (msgw->cont_cls, &msgw->session->target, GNUNET_SYSERR, msgw->payload, 0);
912
913 plugin->bytes_in_queue -= msgw->msgsize;
914 GNUNET_STATISTICS_set (plugin->env->stats, "# bytes currently in UNIX buffers",
915 plugin->bytes_in_queue, GNUNET_NO);
916
917 plugin->bytes_discarded += msgw->msgsize;
918 GNUNET_STATISTICS_set (plugin->env->stats,"# UNIX bytes discarded",
919 plugin->bytes_discarded, GNUNET_NO);
920
921 GNUNET_free (msgw->msg);
922 GNUNET_free (msgw);
923 }
924 msgw = plugin->msg_tail;
925 }
926 if (NULL == msgw)
927 return; /* Nothing to send at the moment */
900 928
901 sent = unix_real_send (plugin, 929 sent = unix_real_send (plugin,
902 plugin->unix_sock.desc, 930 plugin->unix_sock.desc,
@@ -965,8 +993,6 @@ unix_plugin_select_write (struct Plugin * plugin)
965 GNUNET_free (msgw); 993 GNUNET_free (msgw);
966 return; 994 return;
967 } 995 }
968
969
970} 996}
971 997
972 998