[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7316 - in libmicrohttpd/src: daemon examples
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7316 - in libmicrohttpd/src: daemon examples |
Date: |
Mon, 23 Jun 2008 19:42:08 -0600 (MDT) |
Author: lv-426
Date: 2008-06-23 19:42:07 -0600 (Mon, 23 Jun 2008)
New Revision: 7316
Modified:
libmicrohttpd/src/daemon/Makefile.am
libmicrohttpd/src/daemon/connection.c
libmicrohttpd/src/daemon/connection.h
libmicrohttpd/src/daemon/daemon.c
libmicrohttpd/src/daemon/internal.h
libmicrohttpd/src/examples/Makefile.am
Log:
fixed some build issues
MHDS state machine
Modified: libmicrohttpd/src/daemon/Makefile.am
===================================================================
--- libmicrohttpd/src/daemon/Makefile.am 2008-06-23 21:23:01 UTC (rev
7315)
+++ libmicrohttpd/src/daemon/Makefile.am 2008-06-24 01:42:07 UTC (rev
7316)
@@ -1,9 +1,3 @@
-SUBDIRS = .
-
-if ENABLE_HTTPS
- SUBDIRS += https
-endif
-
AM_CPPFLAGS = -I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/daemon \
-I$(top_srcdir)/src/daemon/https/lgl \
@@ -24,6 +18,14 @@
lib_LTLIBRARIES = \
libmicrohttpd.la
+SUBDIRS =
+libmicrohttpd_la_LIBADD =
+
+if ENABLE_HTTPS
+SUBDIRS += https .
+libmicrohttpd_la_LIBADD += https/libhttps.la
+endif
+
libmicrohttpd_la_SOURCES = \
connection.c connection.h \
reason_phrase.c reason_phrase.h \
@@ -36,10 +38,6 @@
libmicrohttpd_la_LDFLAGS = \
-export-dynamic -version-info 4:3:0 $(retaincommand)
-if ENABLE_HTTPS
- libmicrohttpd_la_LIBADD = https/libhttps.la
-endif
-
check_PROGRAMS = \
postprocessor_test \
postprocessor_large_test \
Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c 2008-06-23 21:23:01 UTC (rev
7315)
+++ libmicrohttpd/src/daemon/connection.c 2008-06-24 01:42:07 UTC (rev
7316)
@@ -1477,10 +1477,19 @@
while (1)
{
+#if HAVE_MESSAGES
+ MHD_DLOG (connection->daemon, "MHDS reached case: %d, l: %d, f: %s\n",
+ connection->s_state, __LINE__, __FUNCTION__);
+#endif
switch (connection->s_state)
{
+ /* thest cases shouldn't occur */
case MHDS_CONNECTION_INIT:
- case MHDS_HANDSHAKE_COMPLETE:
+ case MHDS_HANDSHAKE_FAILED:
+ return MHD_NO;
+
+ case MHDS_REPLY_READY:
+ /* req read & another came in */
case MHDS_REQUEST_READ:
if (MHD_YES == connection->read_closed)
{
@@ -1488,19 +1497,16 @@
continue;
}
break;
- case MHDS_REQUEST_READING:
+ /* switch to reading state */
+ case MHDS_HANDSHAKE_COMPLETE:
+ case MHDS_REPLY_SENT:
+ connection->s_state = MHDS_REQUEST_READING;
do_read (connection);
break;
-
- /* thest cases shouldn't occur */
- case MHDS_REPLY_READY:
+ case MHDS_REQUEST_READING:
+ /* req comes in while sending previous reply - wait until reply sent
*/
case MHDS_REPLY_SENDING:
- case MHDS_HANDSHAKE_FAILED:
-#if HAVE_MESSAGES
- MHD_DLOG (connection->daemon, "MHDS reached case: %d\n",
- connection->s_state);
-#endif
- return MHD_NO;
+ break;
case MHD_CONNECTION_CLOSED:
if (connection->socket_fd != -1)
@@ -1752,26 +1758,41 @@
int
MHDS_connection_handle_write (struct MHD_Connection *connection)
{
+ connection->last_activity = time (NULL);
+
while (1)
{
+#if HAVE_MESSAGES
+ MHD_DLOG (connection->daemon, "MHDS reached case: %d, l: %d, f: %s\n",
+ connection->s_state, __LINE__, __FUNCTION__);
+#endif
switch (connection->s_state)
{
+ /* these cases shouldn't occur */
case MHDS_CONNECTION_INIT:
+ // TODO do we have to write back a responce ?
case MHDS_HANDSHAKE_FAILED:
- case MHDS_HANDSHAKE_COMPLETE:
- abort ();
+ /* we should first exit MHDS_REPLY_SENDING */
+ case MHDS_REQUEST_READING:
+ /* these should go through the idle state at first */
+ case MHDS_REQUEST_READ:
break;
case MHDS_CONNECTION_CLOSED:
+ if (connection->socket_fd != -1)
+ connection_close_error (connection);
+ return MHD_NO;
+ case MHDS_HANDSHAKE_COMPLETE:
+
+ case MHDS_REPLY_SENDING:
do_write (connection);
+ // TODO check write done
break;
case MHDS_REPLY_READY:
- return MHD_connection_handle_idle (connection);
-
+ /* switch to MHDS_REPLY_SENDING through idle */
break;
-
}
}
return MHD_YES;
@@ -2107,29 +2128,31 @@
}
+#if HTTPS_SUPPORT
int
MHDS_connection_handle_idle (struct MHD_Connection *connection)
{
unsigned int timeout;
const char *end;
char *line;
+ ssize_t msgLength;
while (1)
{
-#if DEBUG_STATES
- fprintf (stderr, "`%s' in state %u\n", __FUNCTION__, connection->state);
+#if HAVE_MESSAGES
+ MHD_DLOG (connection->daemon, "MHDS reached case: %d, l: %d, f: %s\n",
+ connection->s_state, __LINE__, __FUNCTION__);
#endif
switch (connection->s_state)
{
+ case MHDS_HANDSHAKE_FAILED:
+ connection->socket_fd = -1;
case MHDS_CONNECTION_INIT:
- break;
- case MHDS_REQUEST_READ:
- /* pipe data to HTTP state machine */
+ /* wait for request */
+ case MHDS_HANDSHAKE_COMPLETE:
- memcpy (connection->tls_session->internals.application_data_buffer.
- data, connection->read_buffer,
- connection->tls_session->internals.application_data_buffer.
- length);
+ case MHDS_REPLY_SENDING:
+ connection->s_state = MHDS_REPLY_SENT;
break;
case MHDS_REPLY_READY:
@@ -2137,8 +2160,27 @@
memcpy (connection->write_buffer,
connection->tls_session->internals.application_data_buffer.
data, connection->write_buffer_size);
+ connection->s_state = MHDS_REPLY_SENDING;
break;
+ case MHDS_REQUEST_READING:
+ // TODO mv handshake here
+ connection->s_state = MHDS_REQUEST_READ;
+
+ case MHDS_REQUEST_READ:
+ /* pipe data to HTTP state machine */
+
+ msgLength
+ =
+ connection->tls_session->internals.application_data_buffer.length;
+ memcpy (connection->tls_session->internals.application_data_buffer.
+ data, connection->read_buffer, msgLength);
+ connection->read_buffer_offset = msgLength;
+ /* pass connection to MHD */
+ MHD_connection_handle_idle (connection);
+
+ break;
+
case MHDS_CONNECTION_CLOSED:
if (connection->socket_fd != -1)
connection_close_error (connection);
@@ -2161,5 +2203,6 @@
}
return MHD_YES;
}
+#endif
/* end of connection.c */
Modified: libmicrohttpd/src/daemon/connection.h
===================================================================
--- libmicrohttpd/src/daemon/connection.h 2008-06-23 21:23:01 UTC (rev
7315)
+++ libmicrohttpd/src/daemon/connection.h 2008-06-24 01:42:07 UTC (rev
7316)
@@ -27,6 +27,7 @@
#ifndef CONNECTION_H
#define CONNECTION_H
+#include "config.h"
/**
* Obtain the select sets for this connection.
Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c 2008-06-23 21:23:01 UTC (rev 7315)
+++ libmicrohttpd/src/daemon/daemon.c 2008-06-24 01:42:07 UTC (rev 7316)
@@ -248,7 +248,7 @@
}
// printf ("TLS Handshake completed\n");
- con->state = MHDS_HANDSHAKE_COMPLETE;
+ con->s_state = MHDS_HANDSHAKE_COMPLETE;
MHD_handle_connection (data);
}
@@ -343,6 +343,8 @@
CLOSE (s);
return MHD_NO;
}
+
+ /* apply connection acceptance policy if present */
if ((daemon->apc != NULL)
&& (MHD_NO == daemon->apc (daemon->apc_cls, addr, addrlen)))
{
@@ -609,6 +611,8 @@
ds = daemon->socket_fd;
if (ds == -1)
return MHD_YES;
+
+ /* select connection thread handling type */
if (__FD_ISSET (ds, &rs))
MHD_accept_connection (daemon);
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
@@ -621,6 +625,7 @@
ds = pos->socket_fd;
if (ds != -1)
{
+ // TODO call con->read handler
if (FD_ISSET (ds, &rs))
MHD_connection_handle_read (pos);
if ((pos->socket_fd != -1) && (FD_ISSET (ds, &ws)))
Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2008-06-23 21:23:01 UTC (rev 7315)
+++ libmicrohttpd/src/daemon/internal.h 2008-06-24 01:42:07 UTC (rev 7316)
@@ -308,6 +308,8 @@
/* while receiving an HTTP request through the encrypted channel */
MHDS_REPLY_SENDING,
+
+ MHDS_REPLY_SENT,
MHDS_CONNECTION_CLOSED
};
Modified: libmicrohttpd/src/examples/Makefile.am
===================================================================
--- libmicrohttpd/src/examples/Makefile.am 2008-06-23 21:23:01 UTC (rev
7315)
+++ libmicrohttpd/src/examples/Makefile.am 2008-06-24 01:42:07 UTC (rev
7316)
@@ -12,7 +12,7 @@
fileserver_example_external_select
if ENABLE_HTTPS
- noinst_PROGRAMS += https_server_example
+noinst_PROGRAMS += https_server_example
endif
minimal_example_SOURCES = \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7316 - in libmicrohttpd/src: daemon examples,
gnunet <=