aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-23 18:08:02 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-23 18:08:02 +0000
commitf8bb1ee6e0059fa94aaae188f5fc3461e6961ed2 (patch)
treecb6d2a2cf92a6b9a13fae07d40ba5143e5663d47 /src/transport/plugin_transport_unix.c
parenta3453282c5d4969fd9d38f4408604754294b2aa2 (diff)
downloadgnunet-f8bb1ee6e0059fa94aaae188f5fc3461e6961ed2.tar.gz
gnunet-f8bb1ee6e0059fa94aaae188f5fc3461e6961ed2.zip
improved rescheduling
improved recv error handling
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 317ff2089..499cc23ad 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -223,6 +223,8 @@ struct Plugin
223 */ 223 */
224 struct GNUNET_NETWORK_FDSet *ws; 224 struct GNUNET_NETWORK_FDSet *ws;
225 225
226 int with_ws;
227
226 /** 228 /**
227 * socket that we transmit all data with 229 * socket that we transmit all data with
228 */ 230 */
@@ -315,7 +317,7 @@ unix_transport_server_stop (void *cls)
315 GNUNET_break (GNUNET_OK == 317 GNUNET_break (GNUNET_OK ==
316 GNUNET_NETWORK_socket_close (plugin->unix_sock.desc)); 318 GNUNET_NETWORK_socket_close (plugin->unix_sock.desc));
317 plugin->unix_sock.desc = NULL; 319 plugin->unix_sock.desc = NULL;
318 320 plugin->with_ws = GNUNET_NO;
319 return GNUNET_OK; 321 return GNUNET_OK;
320} 322}
321 323
@@ -635,17 +637,20 @@ unix_plugin_send (void *cls,
635 (char *) session->addr); 637 (char *) session->addr);
636#endif 638#endif
637 639
638 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) 640 if (plugin->with_ws == GNUNET_NO)
639 GNUNET_SCHEDULER_cancel(plugin->select_task); 641 {
640 642 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
641 plugin->select_task = 643 GNUNET_SCHEDULER_cancel(plugin->select_task);
642 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 644
643 GNUNET_SCHEDULER_NO_TASK, 645 plugin->select_task =
644 GNUNET_TIME_UNIT_FOREVER_REL, 646 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
645 plugin->rs, 647 GNUNET_SCHEDULER_NO_TASK,
646 plugin->ws, 648 GNUNET_TIME_UNIT_FOREVER_REL,
647 &unix_plugin_select, plugin); 649 plugin->rs,
648 650 plugin->ws,
651 &unix_plugin_select, plugin);
652 plugin->with_ws = GNUNET_YES;
653 }
649 return ssize; 654 return ssize;
650} 655}
651 656
@@ -705,6 +710,9 @@ unix_plugin_select_read (struct Plugin * plugin)
705 GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof (buf), 710 GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof (buf),
706 (struct sockaddr *) &un, &addrlen); 711 (struct sockaddr *) &un, &addrlen);
707 712
713 if ((GNUNET_SYSERR == ret) && ((errno == EAGAIN) || (errno == ENOBUFS)))
714 return;
715
708 if (ret == GNUNET_SYSERR) 716 if (ret == GNUNET_SYSERR)
709 { 717 {
710 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom"); 718 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
@@ -807,7 +815,7 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
807 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 815 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
808 return; 816 return;
809 817
810 818 plugin->with_ws = GNUNET_NO;
811 if ((tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY) != 0) 819 if ((tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY) != 0)
812 { 820 {
813 GNUNET_assert (GNUNET_NETWORK_fdset_isset 821 GNUNET_assert (GNUNET_NETWORK_fdset_isset
@@ -823,6 +831,8 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
823 unix_plugin_select_read (plugin); 831 unix_plugin_select_read (plugin);
824 } 832 }
825 833
834 if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK)
835 GNUNET_SCHEDULER_cancel (plugin->select_task);
826 plugin->select_task = 836 plugin->select_task =
827 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 837 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
828 GNUNET_SCHEDULER_NO_TASK, 838 GNUNET_SCHEDULER_NO_TASK,
@@ -830,6 +840,8 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
830 plugin->rs, 840 plugin->rs,
831 (plugin->msg_head != NULL) ? plugin->ws : NULL, 841 (plugin->msg_head != NULL) ? plugin->ws : NULL,
832 &unix_plugin_select, plugin); 842 &unix_plugin_select, plugin);
843 if (plugin->msg_head != NULL)
844 plugin->with_ws = GNUNET_YES;
833} 845}
834 846
835/** 847/**
@@ -895,8 +907,12 @@ unix_transport_server_start (void *cls)
895 plugin->select_task = 907 plugin->select_task =
896 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 908 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
897 GNUNET_SCHEDULER_NO_TASK, 909 GNUNET_SCHEDULER_NO_TASK,
898 GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, 910 GNUNET_TIME_UNIT_FOREVER_REL,
899 plugin->ws, &unix_plugin_select, plugin); 911 plugin->rs,
912 NULL,
913 &unix_plugin_select, plugin);
914 plugin->with_ws = GNUNET_NO;
915
900 return 1; 916 return 1;
901} 917}
902 918