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));
void
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.
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
+/**
+ * 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
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.
}
+/**
+ * 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
}
+/**
+ * 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.