commit dfdbf7ebaddb3b777718a4a91b54e1b829804bf8
parent 9f6372506d35dc824693c2136116383b90d3959e
Author: Andrey Uzunov <andrey.uzunov@gmail.com>
Date: Fri, 5 Jul 2013 17:30:18 +0000
spdy: NO_DELAY flag added to the daemon to set TCP_NODELAY on sockets
Diffstat:
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/include/microspdy.h b/src/include/microspdy.h
@@ -399,6 +399,12 @@ enum SPDY_DAEMON_FLAG
* starting daemon will fail.
*/
SPDY_DAEMON_FLAG_ONLY_IPV6 = 1,
+
+ /**
+ * All sessions' sockets will be set with TCP_NODELAY if the flag is
+ * used. Option considered only by SPDY_IO_SUBSYSTEM_RAW.
+ */
+ SPDY_DAEMON_FLAG_NO_DELAY = 2,
};
diff --git a/src/microspdy/io_raw.c b/src/microspdy/io_raw.c
@@ -26,6 +26,8 @@
#include "internal.h"
#include "session.h"
#include "io_raw.h"
+//TODO put in in the right place
+#include <netinet/tcp.h>
void
@@ -60,14 +62,21 @@ int
SPDYF_raw_new_session(struct SPDY_Session *session)
{
int fd_flags;
+ int val = 1;
+ int ret;
//setting the socket to be non-blocking
fd_flags = fcntl (session->socket_fd, F_GETFL);
if ( -1 == fd_flags
|| 0 != fcntl (session->socket_fd, F_SETFL, fd_flags | O_NONBLOCK))
- {
SPDYF_DEBUG("WARNING: Couldn't set the new connection to be non-blocking");
- }
+
+ if(SPDY_DAEMON_FLAG_NO_DELAY & session->daemon->flags)
+ {
+ ret = setsockopt(session->socket_fd, IPPROTO_TCP, TCP_NODELAY, &val, (socklen_t)sizeof(val));
+ if(-1 == ret)
+ SPDYF_DEBUG("WARNING: Couldn't set the new connection to TCP_NODELAY");
+ }
return SPDY_YES;
}
diff --git a/src/testspdy/test_notls.c b/src/testspdy/test_notls.c
@@ -852,6 +852,7 @@ parentproc( int port)
NULL,
NULL,&session_closed_handler,&standard_request_handler,NULL,CLS,
SPDY_DAEMON_OPTION_IO_SUBSYSTEM, SPDY_IO_SUBSYSTEM_RAW,
+ SPDY_DAEMON_OPTION_FLAGS, SPDY_DAEMON_FLAG_NO_DELAY,
SPDY_DAEMON_OPTION_END);
if(NULL==daemon){