[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27775 - libmicrohttpd/src/microspdy
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27775 - libmicrohttpd/src/microspdy |
Date: |
Sat, 6 Jul 2013 01:08:32 +0200 |
Author: andreyu
Date: 2013-07-06 01:08:31 +0200 (Sat, 06 Jul 2013)
New Revision: 27775
Modified:
libmicrohttpd/src/microspdy/io.c
libmicrohttpd/src/microspdy/io.h
libmicrohttpd/src/microspdy/io_openssl.c
libmicrohttpd/src/microspdy/io_openssl.h
libmicrohttpd/src/microspdy/io_raw.c
libmicrohttpd/src/microspdy/io_raw.h
libmicrohttpd/src/microspdy/session.c
libmicrohttpd/src/microspdy/structures.h
Log:
spdy: TCP_CORK added for io_raw
Modified: libmicrohttpd/src/microspdy/io.c
===================================================================
--- libmicrohttpd/src/microspdy/io.c 2013-07-05 18:27:31 UTC (rev 27774)
+++ libmicrohttpd/src/microspdy/io.c 2013-07-05 23:08:31 UTC (rev 27775)
@@ -64,6 +64,8 @@
session->fio_is_pending = &SPDYF_openssl_is_pending;
session->fio_recv = &SPDYF_openssl_recv;
session->fio_send = &SPDYF_openssl_send;
+ session->fio_before_write = &SPDYF_openssl_before_write;
+ session->fio_after_write = &SPDYF_openssl_after_write;
break;
case SPDY_IO_SUBSYSTEM_RAW:
@@ -72,6 +74,8 @@
session->fio_is_pending = &SPDYF_raw_is_pending;
session->fio_recv = &SPDYF_raw_recv;
session->fio_send = &SPDYF_raw_send;
+ session->fio_before_write = &SPDYF_raw_before_write;
+ session->fio_after_write = &SPDYF_raw_after_write;
break;
case SPDY_IO_SUBSYSTEM_NONE:
Modified: libmicrohttpd/src/microspdy/io.h
===================================================================
--- libmicrohttpd/src/microspdy/io.h 2013-07-05 18:27:31 UTC (rev 27774)
+++ libmicrohttpd/src/microspdy/io.h 2013-07-05 23:08:31 UTC (rev 27775)
@@ -163,6 +163,31 @@
/**
+ * Called just before frames are about to be processed and written
+ * to the socket.
+ *
+ * @param session
+ * @return SPDY_NO if writing must not happen in the call;
+ * SPDY_YES otherwise
+ */
+typedef int
+(*SPDYF_IOBeforeWrite) (struct SPDY_Session *session);
+
+
+/**
+ * Called just after frames have been processed and written
+ * to the socket.
+ *
+ * @param session
+ * @param was_written has the same value as the write function for the
+ * session will return
+ * @return returned value will be used by the write function to return
+ */
+typedef int
+(*SPDYF_IOAfterWrite) (struct SPDY_Session *session, int was_written);
+
+
+/**
* Sets callbacks for the daemon with regard to the IO subsystem.
*
* @param daemon
Modified: libmicrohttpd/src/microspdy/io_openssl.c
===================================================================
--- libmicrohttpd/src/microspdy/io_openssl.c 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/io_openssl.c 2013-07-05 23:08:31 UTC (rev
27775)
@@ -253,3 +253,21 @@
*/
return SSL_pending(session->io_context) > 0 ? SPDY_YES : SPDY_NO;
}
+
+
+int
+SPDYF_openssl_before_write(struct SPDY_Session *session)
+{
+ (void)session;
+
+ return SPDY_YES;
+}
+
+
+int
+SPDYF_openssl_after_write(struct SPDY_Session *session, int was_written)
+{
+ (void)session;
+
+ return was_written;
+}
Modified: libmicrohttpd/src/microspdy/io_openssl.h
===================================================================
--- libmicrohttpd/src/microspdy/io_openssl.h 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/io_openssl.h 2013-07-05 23:08:31 UTC (rev
27775)
@@ -139,4 +139,28 @@
int
SPDYF_openssl_is_pending(struct SPDY_Session *session);
+
+/**
+ * Nothing.
+ *
+ * @param session
+ * @return SPDY_NO if writing must not happen in the call;
+ * SPDY_YES otherwise
+ */
+int
+SPDYF_openssl_before_write(struct SPDY_Session *session);
+
+
+/**
+ * Nothing.
+ *
+ * @param session
+ * @param was_written has the same value as the write function for the
+ * session will return
+ * @return returned value will be used by the write function to return
+ */
+int
+SPDYF_openssl_after_write(struct SPDY_Session *session, int was_written);
+
+
#endif
Modified: libmicrohttpd/src/microspdy/io_raw.c
===================================================================
--- libmicrohttpd/src/microspdy/io_raw.c 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/io_raw.c 2013-07-05 23:08:31 UTC (rev
27775)
@@ -154,3 +154,31 @@
return SPDY_NO;
}
+
+
+int
+SPDYF_raw_before_write(struct SPDY_Session *session)
+{
+ int val = 1;
+ int ret;
+
+ ret = setsockopt(session->socket_fd, IPPROTO_TCP, TCP_CORK, &val,
(socklen_t)sizeof(val));
+ if(-1 == ret)
+ SPDYF_DEBUG("WARNING: Couldn't set the new connection to TCP_CORK");
+
+ return SPDY_YES;
+}
+
+
+int
+SPDYF_raw_after_write(struct SPDY_Session *session, int was_written)
+{
+ int val = 0;
+ int ret;
+
+ ret = setsockopt(session->socket_fd, IPPROTO_TCP, TCP_CORK, &val,
(socklen_t)sizeof(val));
+ if(-1 == ret)
+ SPDYF_DEBUG("WARNING: Couldn't unset the new connection to TCP_CORK");
+
+ return was_written;
+}
Modified: libmicrohttpd/src/microspdy/io_raw.h
===================================================================
--- libmicrohttpd/src/microspdy/io_raw.h 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/io_raw.h 2013-07-05 23:08:31 UTC (rev
27775)
@@ -132,4 +132,27 @@
int
SPDYF_raw_is_pending(struct SPDY_Session *session);
+
+/**
+ * Sets TCP_CORK.
+ *
+ * @param session
+ * @return SPDY_NO if writing must not happen in the call;
+ * SPDY_YES otherwise
+ */
+int
+SPDYF_raw_before_write(struct SPDY_Session *session);
+
+
+/**
+ * Unsets TCP_CORK.
+ *
+ * @param session
+ * @param was_written has the same value as the write function for the
+ * session will return
+ * @return returned value will be used by the write function to return
+ */
+int
+SPDYF_raw_after_write(struct SPDY_Session *session, int was_written);
+
#endif
Modified: libmicrohttpd/src/microspdy/session.c
===================================================================
--- libmicrohttpd/src/microspdy/session.c 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/session.c 2013-07-05 23:08:31 UTC (rev
27775)
@@ -868,6 +868,9 @@
if(SPDY_SESSION_STATUS_CLOSING == session->status)
return SPDY_NO;
+
+ if(SPDY_NO == session->fio_before_write(session))
+ return SPDY_NO;
for(i=0;
only_one_frame
@@ -935,7 +938,7 @@
//on respones with callbacks it is possible that their
is no
//data available
if(0 == session->write_buffer_size)//nothing to write
- {
+ {
if(response_queue !=
session->response_queue_head)
{
//the handler modified the queue
@@ -946,12 +949,12 @@
//no need to try the same frame again
break;
}
- }
+ }
}
session->last_activity = SPDYF_monotonic_time();
- //actual write to the TLS socket
+ //actual write to the IO
bytes_written = session->fio_send(session,
session->write_buffer + session->write_buffer_beginning,
session->write_buffer_offset -
session->write_buffer_beginning);
@@ -1021,8 +1024,8 @@
&& NULL == session->response_queue_head)
session->status = SPDY_SESSION_STATUS_CLOSING;
-
- return i>0 ? SPDY_YES : SPDY_NO;
+ //return i>0 ? SPDY_YES : SPDY_NO;
+ return session->fio_after_write(session, i>0);
}
Modified: libmicrohttpd/src/microspdy/structures.h
===================================================================
--- libmicrohttpd/src/microspdy/structures.h 2013-07-05 18:27:31 UTC (rev
27774)
+++ libmicrohttpd/src/microspdy/structures.h 2013-07-05 23:08:31 UTC (rev
27775)
@@ -684,6 +684,16 @@
SPDYF_IOIsPending fio_is_pending;
/**
+ * Function to call before writing set of frames.
+ */
+ SPDYF_IOBeforeWrite fio_before_write;
+
+ /**
+ * Function to call after writing set of frames.
+ */
+ SPDYF_IOAfterWrite fio_after_write;
+
+ /**
* Number of bytes that the lib must ignore immediately after they
* are read from the TLS socket without adding them to the read buf.
* This is needed, for instance, when receiving frame bigger than
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27775 - libmicrohttpd/src/microspdy,
gnunet <=