From 5bd258ca5279a7bf54becb37a2f520e8fc6f4aaf Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Tue, 11 Aug 2009 21:29:51 +0200 Subject: [PATCH] Move the network related flags from network.h to connection.h since that is where they are used. --- src/network/connection.c | 8 ++++++++ src/network/connection.h | 16 ++++++++++++++++ src/network/network.h | 15 --------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/network/connection.c b/src/network/connection.c index 70326c9..bbcfdf1 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -155,6 +155,12 @@ void net_con_update(struct net_connection* con, int ev) void net_con_close(struct net_connection* con) { + if (net_con_flag_get(con, NET_CLEANUP)) + { + LOG_INFO("Running net_con_close, but we already have closed..."); + return; + } + if (event_pending(&con->event, EV_READ | EV_WRITE, 0)) { event_del(&con->event); @@ -163,6 +169,8 @@ void net_con_close(struct net_connection* con) net_con_clear_timeout(con); net_close(con->sd); con->sd = -1; + + net_con_flag_set(con, NET_CLEANUP); } #ifdef SSL_SUPPORT diff --git a/src/network/connection.h b/src/network/connection.h index 754c69d..a2f2e49 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -22,6 +22,22 @@ #include "uhub.h" +#define NET_WANT_READ 0x0001 +#define NET_WANT_WRITE 0x0002 +#define NET_WANT_ACCEPT 0x0008 +#define NET_WANT_SSL_READ 0x0010 +#define NET_WANT_SSL_WRITE 0x0020 +#define NET_WANT_SSL_ACCEPT 0x0040 +#define NET_WANT_SSL_CONNECT 0x0080 +#define NET_WANT_SSL_X509_LOOKUP 0x0100 +#define NET_CLEANUP 0x8000 + +#define NET_EVENT_TIMEOUT 0x0001 +#define NET_EVENT_READ 0x0002 +#define NET_EVENT_WRITE 0x0004 +#define NET_EVENT_SOCKERROR 0x1000 /* Socket error, closed */ +#define NET_EVENT_CLOSED 0x2000 /* Socket closed */ + struct net_connection; typedef void (*net_connection_cb)(struct net_connection*, int event, void* ptr); diff --git a/src/network/network.h b/src/network/network.h index 554a1bf..5db2124 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -32,21 +32,6 @@ struct net_statistics struct net_socket_t; -#define NET_WANT_READ 0x0001 -#define NET_WANT_WRITE 0x0002 -#define NET_WANT_ACCEPT 0x0008 -#define NET_WANT_SSL_READ 0x0010 -#define NET_WANT_SSL_WRITE 0x0020 -#define NET_WANT_SSL_ACCEPT 0x0040 -#define NET_WANT_SSL_CONNECT 0x0080 -#define NET_WANT_SSL_X509_LOOKUP 0x0100 - -#define NET_EVENT_TIMEOUT 0x0001 -#define NET_EVENT_READ 0x0002 -#define NET_EVENT_WRITE 0x0004 -#define NET_EVENT_SOCKERROR 0x1000 /* Socket error, closed */ -#define NET_EVENT_CLOSED 0x2000 /* Socket closed */ - /** * Initialize the socket monitor subsystem. * On some operating systems this will also involve loading the TCP/IP stack