diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-20 09:24:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-20 09:24:05 +0000 |
commit | fc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81 (patch) | |
tree | c787bb93154683716b891e0ef0b6590dad60d916 /src/util | |
parent | 5b3c889e3795aff706409921b622228a43d04205 (diff) | |
download | gnunet-fc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81.tar.gz gnunet-fc3387a40578c2ec8d0dc28d9d4ff9c9998a6e81.zip |
Mantis 1716:
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/connection.c | 17 | ||||
-rw-r--r-- | src/util/network.c | 24 | ||||
-rw-r--r-- | src/util/server.c | 15 |
3 files changed, 56 insertions, 0 deletions
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 | */ | ||
316 | int 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 | */ | ||
733 | int | ||
734 | GNUNET_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 | */ | ||
1180 | int | ||
1181 | GNUNET_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 | * |