+ struct ServerConnection *sc = *httpSessionCache;
+ struct Session *s = NULL;
+ struct Session *t = NULL;
+ struct HTTP_Server_Plugin *plugin = NULL;
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, p->name,
+ "Disconnect for connection %p \n", sc);
+
+ if (sc == NULL)
+ return;
+
+ if (NULL == (s = server_lookup_session (p, sc)))
+ return;
+
+ GNUNET_assert (NULL != p);
+ for (t = p->head; t != NULL; t = t->next)
+ {
+ if (t == s)
+ break;
+ }
+ if (NULL == t)
+ return;
+
+ plugin = s->plugin;
+ if (sc->direction == _SEND)
+ {
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Peer `%s' connection %p, GET on address `%s' disconnected\n",
+ GNUNET_i2s (&s->target), s->server_send,
+ http_common_plugin_address_to_string (NULL, s->addr, s->addrlen));
+ s->server_send = NULL;
+ if (NULL != (s->server_recv))
+ {
+ s->server_recv->disconnect = GNUNET_YES;
+ GNUNET_assert (NULL != s->server_recv->mhd_conn);
+#if MHD_VERSION >= 0x00090E00
+ MHD_set_connection_option (s->server_recv->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ 1);
+#endif
+ server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_NO);
+ }
+ }
+ if (sc->direction == _RECEIVE)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Peer `%s' connection %p PUT on address `%s' disconnected\n",
+ GNUNET_i2s (&s->target), s->server_recv,
+ http_common_plugin_address_to_string (NULL, s->addr, s->addrlen));
+ s->server_recv = NULL;
+ /* Do not terminate session when PUT disconnects
+ if (NULL != (s->server_send))
+ {
+ s->server_send->disconnect = GNUNET_YES;
+ GNUNET_assert (NULL != s->server_send->mhd_conn);
+#if MHD_VERSION >= 0x00090E00
+ MHD_set_connection_option (s->server_send->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT,
+ 1);
+#endif
+ server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO);
+ }*/
+ if (s->msg_tk != NULL)
+ {
+ GNUNET_SERVER_mst_destroy (s->msg_tk);
+ s->msg_tk = NULL;
+ }
+ }
+
+ GNUNET_free (sc);
+ plugin->cur_connections--;
+
+ if ((s->server_send == NULL) && (s->server_recv == NULL))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Peer `%s' on address `%s' disconnected\n",
+ GNUNET_i2s (&s->target),
+ http_common_plugin_address_to_string (NULL, s->addr, s->addrlen));
+
+ if ((GNUNET_YES == s->session_passed) && (GNUNET_NO == s->session_ended))
+ {
+ /* Notify transport immediately that this session is invalid */
+ s->session_ended = GNUNET_YES;
+ plugin->env->session_end (plugin->env->cls, &s->target, s);
+ }
+ server_delete_session (s);
+ }
+