#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_http_server_done
#endif
-#define TESTING GNUNET_NO
-
-#if TESTING
-#define TIMEOUT_LOG GNUNET_ERROR_TYPE_ERROR
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
-#define HTTP_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-#else
-#define HTTP_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
-#define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
-#define TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
-#endif
-
#define HTTP_ERROR_RESPONSE "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested URL was not found on this server.<P><HR><ADDRESS></ADDRESS></BODY></HTML>"
#define _RECEIVE 0
#define _SEND 1
*/
void *addr;
-
/**
* Address length
*/
*/
struct GNUNET_NAT_Handle *nat;
- /**
- * Server semi connections
- * A full session consists of 2 semi-connections: send and receive
- * If not both directions are established the server keeps this sessions here
- */
- //struct Session *server_semi_head;
-
- //struct Session *server_semi_tail;
-
/**
* List of own addresses
*/
}
GNUNET_assert (NULL != session->server_send);
+ if (GNUNET_YES == session->server_send->disconnect)
+ return GNUNET_SYSERR;
+
/* create new message and schedule */
bytes_sent = sizeof (struct HTTP_Message) + msgbuf_size;
msg = GNUNET_malloc (bytes_sent);
struct HTTP_Server_Plugin *plugin = s->plugin;
server_stop_session_timeout(s);
+ if (GNUNET_YES == s->session_passed)
+ plugin->env->session_end (plugin->env->cls, &s->target, s);
+
GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
struct HTTP_Message *msg = s->msg_head;
struct HTTP_Message *tmp = NULL;
GNUNET_free_non_null (s->server_recv);
GNUNET_free_non_null (s->server_send);
GNUNET_free (s);
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Session %p destroyed\n", s);
}
if (url_len < 105)
{
- GNUNET_break (0);
goto error; /* too short */
}
hash_start = strrchr (url, '/');
if (NULL == hash_start)
{
- GNUNET_break (0);
goto error; /* '/' delimiter not found */
}
if (hash_start >= url_end)
{
- GNUNET_break (0);
goto error; /* mal formed */
}
hash_start++;
goto error; /* ';' delimiter not found */
if (hash_end >= url_end)
{
- GNUNET_break (0);
goto error; /* mal formed */
}
if (hash_start >= hash_end)
{
- GNUNET_break (0);
goto error; /* mal formed */
}
if ((strlen(hash_start) - strlen(hash_end)) != 103)
{
- GNUNET_break (0);
goto error; /* invalid hash length */
}
hash[103] = '\0';
if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((const char *) hash, &(target.hashPubKey)))
{
- GNUNET_break (0);
goto error; /* mal formed */
}
if (hash_end >= url_end)
{
- GNUNET_break (0);
goto error; /* mal formed */
}
"Peer `%s' on address `%s' disconnected\n",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL, s->addr, s->addrlen));
- if (s->msg_tk != NULL)
- {
- GNUNET_SERVER_mst_destroy (s->msg_tk);
- s->msg_tk = NULL;
- }
- GNUNET_CONTAINER_DLL_remove(plugin->head, plugin->tail, s);
- server_stop_session_timeout (s);
- if (GNUNET_YES == s->session_passed)
- plugin->env->session_end (plugin->env->cls, &s->target, s);
- GNUNET_free (s->addr);
- GNUNET_free (s);
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Session %p destroyed\n", s);
+ server_delete_session (s);
}
}
{
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct HTTP_Server_Plugin *plugin = api->cls;
+ struct Session *pos;
+ struct Session *next;
if (GNUNET_SCHEDULER_NO_TASK != plugin->notify_ext_task)
{
server_stop (plugin);
+ next = plugin->head;
+ while (NULL != (pos = next))
+ {
+ next = pos->next;
+ GNUNET_CONTAINER_DLL_remove( plugin->head, plugin->tail, pos);
+ server_delete_session (pos);
+ }
+
/* Clean up */
GNUNET_free_non_null (plugin->external_hostname);
GNUNET_free_non_null (plugin->ext_addr);