aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-20 09:24:05 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-20 09:24:05 +0000
commitfc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81 (patch)
treec787bb93154683716b891e0ef0b6590dad60d916 /src
parent5b3c889e3795aff706409921b622228a43d04205 (diff)
downloadgnunet-fc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81.tar.gz
gnunet-fc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81.zip
Mantis 1716:
Diffstat (limited to 'src')
-rw-r--r--src/arm/gnunet-service-arm.c4
-rw-r--r--src/include/gnunet_connection_lib.h15
-rw-r--r--src/include/gnunet_network_lib.h11
-rw-r--r--src/include/gnunet_server_lib.h12
-rw-r--r--src/util/connection.c17
-rw-r--r--src/util/network.c24
-rw-r--r--src/util/server.c15
7 files changed, 98 insertions, 0 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index e357668d3..c388d0c42 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -958,6 +958,10 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf)
958 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 958 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
959 _("Transmitting shutdown ACK.\n")); 959 _("Transmitting shutdown ACK.\n"));
960 960
961 /* Make the connection flushing for the purpose of ACK transmitting,
962 needed on W32 to ensure that the message is even received, harmless
963 on other platforms... */
964 GNUNET_break (GNUNET_OK == GNUNET_SERVER_client_disable_corking (client));
961 msg = (struct GNUNET_MessageHeader *) buf; 965 msg = (struct GNUNET_MessageHeader *) buf;
962 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK); 966 msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK);
963 msg->size = htons (sizeof (struct GNUNET_MessageHeader)); 967 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
diff --git a/src/include/gnunet_connection_lib.h b/src/include/gnunet_connection_lib.h
index 700fef3db..3184e821b 100644
--- a/src/include/gnunet_connection_lib.h
+++ b/src/include/gnunet_connection_lib.h
@@ -114,6 +114,21 @@ void
114GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock); 114GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock);
115 115
116/** 116/**
117 * Disable the "CORK" feature for communication with the given socket,
118 * forcing the OS to immediately flush the buffer on transmission
119 * instead of potentially buffering multiple messages. Essentially
120 * reduces the OS send buffers to zero.
121 * Used to make sure that the last messages sent through the connection
122 * reach the other side before the process is terminated.
123 *
124 * @param sock the connection to make flushing and blocking
125 * @return GNUNET_OK on success
126 */
127int
128GNUNET_CONNECTION_disable_corking (struct GNUNET_CONNECTION_Handle *sock);
129
130
131/**
117 * Create a socket handle by boxing an existing OS socket. The OS 132 * Create a socket handle by boxing an existing OS socket. The OS
118 * socket should henceforth be no longer used directly. 133 * socket should henceforth be no longer used directly.
119 * GNUNET_socket_destroy will close it. 134 * GNUNET_socket_destroy will close it.
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 34cb7bc32..1945d210f 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -240,6 +240,17 @@ int GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd,
240int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, 240int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
241 int how); 241 int how);
242 242
243/**
244 * Disable the "CORK" feature for communication with the given socket,
245 * forcing the OS to immediately flush the buffer on transmission
246 * instead of potentially buffering multiple messages. Essentially
247 * reduces the OS send buffers to zero.
248 *
249 * @param desc socket
250 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
251 */
252int GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
253
243 254
244/** 255/**
245 * Create a new socket. Configure it for non-blocking IO and 256 * Create a new socket. Configure it for non-blocking IO and
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h
index ca2041984..2bb530443 100644
--- a/src/include/gnunet_server_lib.h
+++ b/src/include/gnunet_server_lib.h
@@ -384,6 +384,18 @@ GNUNET_SERVER_ignore_shutdown (struct GNUNET_SERVER_Handle *h,
384 384
385 385
386/** 386/**
387 * Disable the "CORK" feature for communication with the given client,
388 * forcing the OS to immediately flush the buffer on transmission
389 * instead of potentially buffering multiple messages.
390 *
391 * @param client handle to the client
392 * @return GNUNET_OK on success
393 */
394int
395GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client);
396
397
398/**
387 * The tansmit context is the key datastructure for a conveniance API 399 * The tansmit context is the key datastructure for a conveniance API
388 * used for transmission of complex results to the client followed 400 * used for transmission of complex results to the client followed
389 * ONLY by signaling receive_done with success or error 401 * ONLY by signaling receive_done with success or error
diff --git a/src/util/connection.c b/src/util/connection.c
index 80f2cae7f..ef38d99a9 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -301,6 +301,23 @@ void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock)
301 sock->persist = GNUNET_YES; 301 sock->persist = GNUNET_YES;
302} 302}
303 303
304
305/**
306 * Disable the "CORK" feature for communication with the given socket,
307 * forcing the OS to immediately flush the buffer on transmission
308 * instead of potentially buffering multiple messages. Essentially
309 * reduces the OS send buffers to zero.
310 * Used to make sure that the last messages sent through the connection
311 * reach the other side before the process is terminated.
312 *
313 * @param sock the connection to make flushing and blocking
314 * @return GNUNET_OK on success
315 */
316int GNUNET_CONNECTION_disable_corking (struct GNUNET_CONNECTION_Handle *sock)
317{
318 return GNUNET_NETWORK_socket_disable_corking (sock->sock);
319}
320
304/** 321/**
305 * Create a socket handle by boxing an existing OS socket. The OS 322 * Create a socket handle by boxing an existing OS socket. The OS
306 * socket should henceforth be no longer used directly. 323 * socket should henceforth be no longer used directly.
diff --git a/src/util/network.c b/src/util/network.c
index 0446d649c..b0669b5b1 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -722,6 +722,30 @@ GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how)
722 722
723 723
724/** 724/**
725 * Disable the "CORK" feature for communication with the given socket,
726 * forcing the OS to immediately flush the buffer on transmission
727 * instead of potentially buffering multiple messages. Essentially
728 * reduces the OS send buffers to zero.
729 *
730 * @param desc socket
731 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
732 */
733int
734GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc)
735{
736 int value = 0;
737 int ret = 0;
738
739 if (0 != (ret = setsockopt (desc->fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof (value))))
740 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
741 if (0 != (ret = setsockopt (desc->fd, SOL_SOCKET, SO_RCVBUF, &value, sizeof (value))))
742 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
743
744 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
745}
746
747
748/**
725 * Reset FD set 749 * Reset FD set
726 * @param fds fd set 750 * @param fds fd set
727 */ 751 */
diff --git a/src/util/server.c b/src/util/server.c
index 33a824e7c..103ca24e7 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -1170,6 +1170,21 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client)
1170 1170
1171 1171
1172/** 1172/**
1173 * Disable the "CORK" feature for communication with the given client,
1174 * forcing the OS to immediately flush the buffer on transmission
1175 * instead of potentially buffering multiple messages.
1176 *
1177 * @param client handle to the client
1178 * @return GNUNET_OK on success
1179 */
1180int
1181GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client)
1182{
1183 return GNUNET_CONNECTION_disable_corking (client->connection);
1184}
1185
1186
1187/**
1173 * Notify us when the server has enough space to transmit 1188 * Notify us when the server has enough space to transmit
1174 * a message of the given size to the given client. 1189 * a message of the given size to the given client.
1175 * 1190 *