mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
Added debug print for connection add/close
This commit is contained in:
@@ -526,6 +526,11 @@
|
||||
/* # define mhd_DEBUG_SUSPEND_RESUME 1 */
|
||||
#endif
|
||||
|
||||
#ifndef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
/* Use debug-print for adding and closing of the connections */
|
||||
/* # define mhd_DEBUG_CONN_ADD_CLOSE 1 */
|
||||
#endif
|
||||
|
||||
#ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT
|
||||
# define MHD_AUTH_DIGEST_DEF_TIMEOUT 90
|
||||
#endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#include "sys_sockets_headers.h"
|
||||
#include "sys_ip_headers.h"
|
||||
|
||||
#ifdef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
# include <stdio.h>
|
||||
#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
|
||||
#include <string.h>
|
||||
#ifdef MHD_SUPPORT_EPOLL
|
||||
# include <sys/epoll.h>
|
||||
@@ -280,6 +283,7 @@ new_connection_prepare_ (struct MHD_Daemon *restrict daemon,
|
||||
|
||||
|
||||
/**
|
||||
* Internal (inner) function.
|
||||
* Finally insert the new connection to the list of connections
|
||||
* served by the daemon and start processing.
|
||||
* @remark To be called only from thread that process
|
||||
@@ -287,11 +291,12 @@ new_connection_prepare_ (struct MHD_Daemon *restrict daemon,
|
||||
*
|
||||
* @param daemon daemon that manages the connection
|
||||
* @param connection the newly created connection
|
||||
* @return #MHD_YES on success, #MHD_NO on error
|
||||
* @return #MHD_SC_OK on success,
|
||||
* error code otherwise
|
||||
*/
|
||||
static enum MHD_StatusCode
|
||||
new_connection_process_ (struct MHD_Daemon *restrict daemon,
|
||||
struct MHD_Connection *restrict connection)
|
||||
new_connection_process_inner (struct MHD_Daemon *restrict daemon,
|
||||
struct MHD_Connection *restrict connection)
|
||||
{
|
||||
enum MHD_StatusCode res;
|
||||
mhd_assert (connection->daemon == daemon);
|
||||
@@ -437,6 +442,41 @@ new_connection_process_ (struct MHD_Daemon *restrict daemon,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finally insert the new connection to the list of connections
|
||||
* served by the daemon and start processing.
|
||||
* @remark To be called only from thread that process
|
||||
* daemon's select()/poll()/etc.
|
||||
*
|
||||
* @param daemon daemon that manages the connection
|
||||
* @param connection the newly created connection
|
||||
* @return #MHD_SC_OK on success,
|
||||
* error code otherwise
|
||||
*/
|
||||
static enum MHD_StatusCode
|
||||
new_connection_process_ (struct MHD_Daemon *restrict daemon,
|
||||
struct MHD_Connection *restrict connection)
|
||||
{
|
||||
enum MHD_StatusCode res;
|
||||
|
||||
res = new_connection_process_inner (daemon,
|
||||
connection);
|
||||
#ifdef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
if (MHD_SC_OK == res)
|
||||
fprintf (stderr,
|
||||
"&&& Added new connection, FD: %llu\n",
|
||||
(unsigned long long) connection->sk.fd);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"&&& Failed add connection, FD: %llu -> %u\n",
|
||||
(unsigned long long) connection->sk.fd,
|
||||
(unsigned int) res);
|
||||
#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The given client socket will be managed (and closed!) by MHD after
|
||||
* this call and must no longer be used directly by the application
|
||||
@@ -1061,6 +1101,11 @@ mhd_conn_close_final (struct MHD_Connection *restrict c)
|
||||
if (NULL != c->sk.addr.data)
|
||||
free (c->sk.addr.data);
|
||||
mhd_socket_close (c->sk.fd);
|
||||
#ifdef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
fprintf (stderr,
|
||||
"&&& Closed connection, FD: %llu\n",
|
||||
(unsigned long long) c->sk.fd);
|
||||
#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
|
||||
|
||||
free (c);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include "mhd_assert.h"
|
||||
#include "mhd_unreachable.h"
|
||||
|
||||
#ifdef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
# include <stdio.h>
|
||||
#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
|
||||
#include <string.h>
|
||||
#include "extr_events_funcs.h"
|
||||
#ifdef MHD_SUPPORT_EPOLL
|
||||
@@ -1025,7 +1028,11 @@ MHD_INTERNAL
|
||||
MHD_FN_PAR_NONNULL_ (1) void
|
||||
mhd_conn_pre_clean (struct MHD_Connection *restrict c)
|
||||
{
|
||||
// TODO: support suspended connections
|
||||
#ifdef mhd_DEBUG_CONN_ADD_CLOSE
|
||||
fprintf (stderr,
|
||||
"&&& Closing connection, FD: %llu\n",
|
||||
(unsigned long long) c->sk.fd);
|
||||
#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
|
||||
|
||||
mhd_assert (c->dbg.closing_started);
|
||||
mhd_assert (! c->dbg.pre_cleaned);
|
||||
|
||||
Reference in New Issue
Block a user