[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11303 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11303 - gnunet/src/transport |
Date: |
Tue, 11 May 2010 14:41:40 +0200 |
Author: wachs
Date: 2010-05-11 14:41:40 +0200 (Tue, 11 May 2010)
New Revision: 11303
Modified:
gnunet/src/transport/plugin_transport_http.c
Log:
Added MHD_OPTION_NOTIFY_COMPLETED Handler
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2010-05-11 12:17:30 UTC
(rev 11302)
+++ gnunet/src/transport/plugin_transport_http.c 2010-05-11 12:41:40 UTC
(rev 11303)
@@ -168,7 +168,91 @@
static CURLM *multi_handle;
+
/**
+ * Finds a http session in our linked list using peer identity as a key
+ * @param peer peeridentity
+ * @return http session corresponding to peer identity
+ */
+static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
+{
+ struct Session * cur;
+ GNUNET_HashCode hc_peer;
+ GNUNET_HashCode hc_current;
+
+ cur = plugin->sessions;
+ hc_peer = peer->hashPubKey;
+ while (cur != NULL)
+ {
+ hc_current = cur->sender.hashPubKey;
+ if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
+ return cur;
+ cur = plugin->sessions->next;
+ }
+ return NULL;
+}
+
+#if 0
+/**
+ * Finds a http session in our linked list using peer identity as a key
+ * @param peer peeridentity
+ * @return http session corresponding to peer identity
+ */
+static struct Session * find_session_by_ip( struct sockaddr_in * addr )
+{
+ /*
+ struct Session * cur;
+
+ cur = plugin->sessions;
+ while (cur != NULL)
+ {
+ hc_current = cur->sender.hashPubKey;
+ if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
+ return cur;
+ cur = plugin->sessions->next;
+ }
+ */
+ return NULL;
+}
+#endif
+
+/**
+ * Creates a http session in our linked list by peer identity
+ * Only peer is set here, all other fields have to be set by calling method
+ * @param peer peeridentity
+ * @return created http session
+ */
+static struct Session * create_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
+{
+ struct Session * cur;
+ struct Session * last_in_list;
+ /* Create a new session object */
+ cur = GNUNET_malloc (sizeof (struct Session));
+ memcpy( &(cur->sender), peer, sizeof( struct GNUNET_PeerIdentity ) );
+
+ cur->next = NULL;
+
+ /* Insert into linked list */
+ last_in_list = plugin->sessions;
+ while (last_in_list->next != NULL)
+ {
+ last_in_list = last_in_list->next;
+ }
+ last_in_list->next = cur;
+
+ return cur;
+}
+
+/**
+ * Callback called by MHD when a connection is terminated
+ */
+static void requestCompletedCallback (void *cls, struct MHD_Connection *
connection, void **httpSessionCache)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection was terminated\n");
+ return;
+}
+
+/**
* Check if we are allowed to connect to the given IP.
*/
static int
@@ -179,10 +263,14 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Incoming IPv4 connection \n");
if (addr->sa_family == AF_INET6)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Incoming IPv6 connection \n");
- /* Currently all incoming connections are accepted, so nothing more to do
here */
+
+
+
+
return MHD_YES;
}
+
/**
* Process GET or PUT request received via MHD. For
* GET, queue response that will send back our pending
@@ -199,6 +287,8 @@
const char *upload_data,
size_t * upload_data_size, void **httpSessionCache)
{
+ //struct Session * http_session;
+
struct MHD_Response *response;
unsigned int have;
@@ -207,8 +297,12 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New request \n",method);
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Already known request \n",method);
- /* Find out if session exists, otherwise create one */
+ /* Find out if session exists, otherwise create one */
+ //struct sockaddr_in * test = session->addr;
+ //http_session = find_session_by_ip ( test );
+
+
/* Is it a PUT or a GET request */
if ( 0 == strcmp (MHD_HTTP_METHOD_PUT, method) )
{
@@ -230,53 +324,11 @@
//GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# GET
requests"), 1, GNUNET_NO);
}
-
-
-
-
return MHD_YES;
}
-/**
- * Finds a http session in our linked list using peer identity as a key
- * @param peer peeridentity
- * @return http session corresponding to peer identity
- */
-static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
-{
- struct Session * cur;
- GNUNET_HashCode hc_peer;
- GNUNET_HashCode hc_current;
- cur = plugin->sessions;
- hc_peer = peer->hashPubKey;
- while (cur != NULL)
- {
- hc_current = cur->sender.hashPubKey;
- if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
- return cur;
- cur = plugin->sessions->next;
- }
- return NULL;
-}
/**
- * Creates a http session in our linked list by peer identity
- * @param peer peeridentity
- * @return created http session
- */
-static struct Session * create_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
-{
- struct Session * cur;
-
- /* Create a new session object */
- cur = GNUNET_malloc (sizeof (struct Session));
-
- /* Insert into linked list */
-
- return cur;
-}
-
-/**
* Call MHD to process pending requests and then go back
* and schedule the next run.
*/
@@ -631,6 +683,7 @@
MHD_OPTION_PER_IP_CONNECTION_LIMIT,
(unsigned int) 1,
MHD_OPTION_CONNECTION_TIMEOUT,
(unsigned int) 16,
MHD_OPTION_CONNECTION_MEMORY_LIMIT,
(size_t) (16 * 1024),
+ MHD_OPTION_NOTIFY_COMPLETED,
&requestCompletedCallback, NULL,
MHD_OPTION_END);
http_daemon_v4 = MHD_start_daemon (MHD_NO_FLAG,
port,
@@ -640,6 +693,7 @@
MHD_OPTION_PER_IP_CONNECTION_LIMIT,
(unsigned int) 1,
MHD_OPTION_CONNECTION_TIMEOUT,
(unsigned int) 16,
MHD_OPTION_CONNECTION_MEMORY_LIMIT,
(size_t) (16 * 1024),
+ MHD_OPTION_NOTIFY_COMPLETED,
&requestCompletedCallback, NULL,
MHD_OPTION_END);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11303 - gnunet/src/transport,
gnunet <=