gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15722 - in gnunet/src: arm include util


From: gnunet
Subject: [GNUnet-SVN] r15722 - in gnunet/src: arm include util
Date: Mon, 20 Jun 2011 11:24:05 +0200

Author: grothoff
Date: 2011-06-20 11:24:05 +0200 (Mon, 20 Jun 2011)
New Revision: 15722

Modified:
   gnunet/src/arm/gnunet-service-arm.c
   gnunet/src/include/gnunet_connection_lib.h
   gnunet/src/include/gnunet_network_lib.h
   gnunet/src/include/gnunet_server_lib.h
   gnunet/src/util/connection.c
   gnunet/src/util/network.c
   gnunet/src/util/server.c
Log:
Mantis 1716:


Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2011-06-20 09:15:18 UTC (rev 15721)
+++ gnunet/src/arm/gnunet-service-arm.c 2011-06-20 09:24:05 UTC (rev 15722)
@@ -958,6 +958,10 @@
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               _("Transmitting shutdown ACK.\n"));
 
+  /* Make the connection flushing for the purpose of ACK transmitting,
+     needed on W32 to ensure that the message is even received, harmless
+     on other platforms... */
+  GNUNET_break (GNUNET_OK == GNUNET_SERVER_client_disable_corking (client));
   msg = (struct GNUNET_MessageHeader *) buf;
   msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
   msg->size = htons (sizeof (struct GNUNET_MessageHeader));

Modified: gnunet/src/include/gnunet_connection_lib.h
===================================================================
--- gnunet/src/include/gnunet_connection_lib.h  2011-06-20 09:15:18 UTC (rev 
15721)
+++ gnunet/src/include/gnunet_connection_lib.h  2011-06-20 09:24:05 UTC (rev 
15722)
@@ -114,6 +114,21 @@
 GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock);
 
 /**
+ * Disable the "CORK" feature for communication with the given socket,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.  Essentially
+ * reduces the OS send buffers to zero.
+ * Used to make sure that the last messages sent through the connection
+ * reach the other side before the process is terminated.
+ *
+ * @param sock the connection to make flushing and blocking
+ * @return GNUNET_OK on success
+ */
+int
+GNUNET_CONNECTION_disable_corking (struct GNUNET_CONNECTION_Handle *sock);
+
+
+/**
  * Create a socket handle by boxing an existing OS socket.  The OS
  * socket should henceforth be no longer used directly.
  * GNUNET_socket_destroy will close it.

Modified: gnunet/src/include/gnunet_network_lib.h
===================================================================
--- gnunet/src/include/gnunet_network_lib.h     2011-06-20 09:15:18 UTC (rev 
15721)
+++ gnunet/src/include/gnunet_network_lib.h     2011-06-20 09:24:05 UTC (rev 
15722)
@@ -240,7 +240,18 @@
 int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
                                     int how);
 
+/**
+ * Disable the "CORK" feature for communication with the given socket,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.  Essentially
+ * reduces the OS send buffers to zero.
+ *
+ * @param desc socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
+int GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
 
+
 /**
  * Create a new socket.   Configure it for non-blocking IO and
  * mark it as non-inheritable to child processes (set the

Modified: gnunet/src/include/gnunet_server_lib.h
===================================================================
--- gnunet/src/include/gnunet_server_lib.h      2011-06-20 09:15:18 UTC (rev 
15721)
+++ gnunet/src/include/gnunet_server_lib.h      2011-06-20 09:24:05 UTC (rev 
15722)
@@ -384,6 +384,18 @@
 
 
 /**
+ * Disable the "CORK" feature for communication with the given client,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.
+ *
+ * @param client handle to the client
+ * @return GNUNET_OK on success
+ */
+int
+GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client);
+
+
+/**
  * The tansmit context is the key datastructure for a conveniance API
  * used for transmission of complex results to the client followed
  * ONLY by signaling receive_done with success or error

Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c        2011-06-20 09:15:18 UTC (rev 15721)
+++ gnunet/src/util/connection.c        2011-06-20 09:24:05 UTC (rev 15722)
@@ -301,7 +301,24 @@
   sock->persist = GNUNET_YES;
 }
 
+
 /**
+ * Disable the "CORK" feature for communication with the given socket,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.  Essentially
+ * reduces the OS send buffers to zero.
+ * Used to make sure that the last messages sent through the connection
+ * reach the other side before the process is terminated.
+ *
+ * @param sock the connection to make flushing and blocking
+ * @return GNUNET_OK on success
+ */
+int GNUNET_CONNECTION_disable_corking (struct GNUNET_CONNECTION_Handle *sock)
+{
+  return GNUNET_NETWORK_socket_disable_corking (sock->sock);
+}
+
+/**
  * Create a socket handle by boxing an existing OS socket.  The OS
  * socket should henceforth be no longer used directly.
  * GNUNET_socket_destroy will close it.

Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2011-06-20 09:15:18 UTC (rev 15721)
+++ gnunet/src/util/network.c   2011-06-20 09:24:05 UTC (rev 15722)
@@ -722,6 +722,30 @@
 
 
 /**
+ * Disable the "CORK" feature for communication with the given socket,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.  Essentially
+ * reduces the OS send buffers to zero.
+ *
+ * @param desc socket
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
+int
+GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc)
+{
+  int value = 0;
+  int ret = 0;
+
+  if (0 != (ret = setsockopt (desc->fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof 
(value))))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
+  if (0 != (ret = setsockopt (desc->fd, SOL_SOCKET, SO_RCVBUF, &value, sizeof 
(value))))
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
+
+  return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
+}
+
+
+/**
  * Reset FD set
  * @param fds fd set
  */

Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c    2011-06-20 09:15:18 UTC (rev 15721)
+++ gnunet/src/util/server.c    2011-06-20 09:24:05 UTC (rev 15722)
@@ -1170,6 +1170,21 @@
 
 
 /**
+ * Disable the "CORK" feature for communication with the given client,
+ * forcing the OS to immediately flush the buffer on transmission
+ * instead of potentially buffering multiple messages.
+ *
+ * @param client handle to the client
+ * @return GNUNET_OK on success
+ */
+int
+GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client)
+{
+  return GNUNET_CONNECTION_disable_corking (client->connection);
+}
+
+
+/**
  * Notify us when the server has enough space to transmit
  * a message of the given size to the given client.
  *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]