[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19480 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19480 - gnunet/src/transport |
Date: |
Fri, 27 Jan 2012 13:27:15 +0100 |
Author: wachs
Date: 2012-01-27 13:27:15 +0100 (Fri, 27 Jan 2012)
New Revision: 19480
Modified:
gnunet/src/transport/plugin_transport_unix.c
Log:
-first half of write select implementation
Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c 2012-01-27 12:09:45 UTC
(rev 19479)
+++ gnunet/src/transport/plugin_transport_unix.c 2012-01-27 12:27:15 UTC
(rev 19480)
@@ -325,6 +325,11 @@
struct GNUNET_NETWORK_FDSet *rs;
/**
+ * FD Write set
+ */
+ struct GNUNET_NETWORK_FDSet *ws;
+
+ /**
* socket that we transmit all data with
*/
struct UNIX_Sock_Info unix_sock;
@@ -806,19 +811,9 @@
}
-/*
- * @param cls the plugin handle
- * @param tc the scheduling context (for rescheduling this function again)
- *
- * We have been notified that our writeset has something to read. We don't
- * know which socket needs to be read, so we have to check each one
- * Then reschedule this function to be called again once more is available.
- *
- */
static void
-unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+unix_plugin_select_read (struct Plugin * plugin)
{
- struct Plugin *plugin = cls;
char buf[65536];
struct UNIXMessage *msg;
struct GNUNET_PeerIdentity sender;
@@ -831,14 +826,9 @@
const struct GNUNET_MessageHeader *currhdr;
uint16_t csize;
- plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
- if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
-
addrlen = sizeof (un);
memset (&un, 0, sizeof (un));
- GNUNET_assert (GNUNET_NETWORK_fdset_isset
- (tc->read_ready, plugin->unix_sock.desc));
+
ret =
GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc, buf, sizeof
(buf),
(struct sockaddr *) &un, &addrlen);
@@ -846,11 +836,6 @@
if (ret == GNUNET_SYSERR)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
- plugin->select_task =
- GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
- NULL, &unix_plugin_select, plugin);
return;
}
else
@@ -871,11 +856,6 @@
if ((csize < sizeof (struct UNIXMessage)) || (csize > ret))
{
GNUNET_break_op (0);
- plugin->select_task =
- GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
- NULL, &unix_plugin_select, plugin);
return;
}
msgbuf = (char *) &msg[1];
@@ -895,11 +875,53 @@
unix_demultiplexer (plugin, &sender, currhdr, &un, sizeof (un));
offset += csize;
}
+}
+
+static void
+unix_plugin_select_write (struct Plugin * plugin)
+{
+
+
+}
+
+/*
+ * @param cls the plugin handle
+ * @param tc the scheduling context (for rescheduling this function again)
+ *
+ * We have been notified that our writeset has something to read. We don't
+ * know which socket needs to be read, so we have to check each one
+ * Then reschedule this function to be called again once more is available.
+ *
+ */
+static void
+unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct Plugin *plugin = cls;
+
+ plugin->select_task = GNUNET_SCHEDULER_NO_TASK;
+ if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+
+
+ if ((tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY) != 0)
+ {
+ GNUNET_assert (GNUNET_NETWORK_fdset_isset
+ (tc->write_ready, plugin->unix_sock.desc));
+ unix_plugin_select_write (plugin);
+ }
+
+ if ((tc->reason & GNUNET_SCHEDULER_REASON_READ_READY) != 0)
+ {
+ GNUNET_assert (GNUNET_NETWORK_fdset_isset
+ (tc->read_ready, plugin->unix_sock.desc));
+ unix_plugin_select_read (plugin);
+ }
+
plugin->select_task =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
GNUNET_SCHEDULER_NO_TASK,
GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
- NULL, &unix_plugin_select, plugin);
+ plugin->ws, &unix_plugin_select, plugin);
}
/**
@@ -956,14 +978,17 @@
&un.sun_path[0]);
#endif
plugin->rs = GNUNET_NETWORK_fdset_create ();
+ plugin->ws = GNUNET_NETWORK_fdset_create ();
GNUNET_NETWORK_fdset_zero (plugin->rs);
+ GNUNET_NETWORK_fdset_zero (plugin->ws);
GNUNET_NETWORK_fdset_set (plugin->rs, plugin->unix_sock.desc);
+ GNUNET_NETWORK_fdset_set (plugin->ws, plugin->unix_sock.desc);
plugin->select_task =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
GNUNET_SCHEDULER_NO_TASK,
GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs,
- NULL, &unix_plugin_select, plugin);
+ plugin->ws, &unix_plugin_select, plugin);
return 1;
}
@@ -1171,6 +1196,7 @@
unix_transport_server_stop (plugin);
GNUNET_NETWORK_fdset_destroy (plugin->rs);
+ GNUNET_NETWORK_fdset_destroy (plugin->ws);
GNUNET_free (plugin->unix_socket_path);
GNUNET_free (plugin);
GNUNET_free (api);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19480 - gnunet/src/transport,
gnunet <=