diff options
author | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2010-12-26 23:28:58 +0300 |
---|---|---|
committer | ambrop7 <ambrop7@1a93d707-3861-5ebc-ad3b-9740d49b5140> | 2010-12-26 23:28:58 +0300 |
commit | feb875f9dc2a9ecbb041ae7bf1f4f668adf488dd (patch) | |
tree | ad943370c42b5477b6fef43b14e9b7d5a2ccf2aa /server_connection | |
parent | d2d023dec22fbab4bc2522c22564c1ecb42c8aec (diff) |
ServerConnection: use DebugError
Diffstat (limited to 'server_connection')
-rw-r--r-- | server_connection/ServerConnection.c | 32 | ||||
-rw-r--r-- | server_connection/ServerConnection.h | 3 |
2 files changed, 8 insertions, 27 deletions
diff --git a/server_connection/ServerConnection.c b/server_connection/ServerConnection.c index 66a4fd3..b100822 100644 --- a/server_connection/ServerConnection.c +++ b/server_connection/ServerConnection.c @@ -52,20 +52,7 @@ static void end_packet (ServerConnection *o, uint8_t type); void report_error (ServerConnection *o) { - ASSERT(!o->error) - - o->error = 1; - - #ifndef NDEBUG - DEAD_ENTER(o->dead) - #endif - - o->handler_error(o->user); - - #ifndef NDEBUG - ASSERT(DEAD_KILLED) - DEAD_LEAVE(o->dead); - #endif + DEBUGERROR(&o->d_err, o->handler_error(o->user)) } void connect_handler (ServerConnection *o, int event) @@ -522,9 +509,6 @@ int ServerConnection_Init ( o->handler_endclient = handler_endclient; o->handler_message = handler_message; - // init dead var - DEAD_INIT(o->dead); - // init socket if (BSocket_Init(&o->sock, o->reactor, addr.type, BSOCKET_TYPE_STREAM) < 0) { BLog(BLOG_ERROR, "BSocket_Init failed (%d)", BSocket_GetError(&o->sock)); @@ -545,10 +529,8 @@ int ServerConnection_Init ( // set state o->state = STATE_CONNECTING; - // set no error - o->error = 0; - DebugObject_Init(&o->d_obj); + DebugError_Init(&o->d_err); return 1; @@ -560,6 +542,7 @@ fail0: void ServerConnection_Free (ServerConnection *o) { + DebugError_Free(&o->d_err); DebugObject_Free(&o->d_obj); if (o->state > STATE_CONNECTING) { @@ -608,9 +591,6 @@ void ServerConnection_Free (ServerConnection *o) // free socket BSocket_Free(&o->sock); - - // free dead var - DEAD_KILL(o->dead); } int ServerConnection_IsReady (ServerConnection *o) @@ -622,12 +602,12 @@ int ServerConnection_IsReady (ServerConnection *o) int ServerConnection_StartMessage (ServerConnection *o, void **data, peerid_t peer_id, int len) { - ASSERT(!o->error) ASSERT(o->state == STATE_COMPLETE) ASSERT(o->output_local_packet_len == -1) ASSERT(len >= 0) ASSERT(len <= SC_MAX_MSGLEN) ASSERT(data || len == 0) + DebugError_AssertNoError(&o->d_err); DebugObject_Access(&o->d_obj); uint8_t *packet; @@ -647,9 +627,9 @@ int ServerConnection_StartMessage (ServerConnection *o, void **data, peerid_t pe void ServerConnection_EndMessage (ServerConnection *o) { - ASSERT(!o->error) ASSERT(o->state == STATE_COMPLETE) ASSERT(o->output_local_packet_len >= 0) + DebugError_AssertNoError(&o->d_err); DebugObject_Access(&o->d_obj); end_packet(o, SCID_OUTMSG); @@ -657,8 +637,8 @@ void ServerConnection_EndMessage (ServerConnection *o) PacketPassInterface * ServerConnection_GetSendInterface (ServerConnection *o) { - ASSERT(!o->error) ASSERT(o->state == STATE_COMPLETE) + DebugError_AssertNoError(&o->d_err); DebugObject_Access(&o->d_obj); return PacketPassPriorityQueueFlow_GetInput(&o->output_user_qflow); diff --git a/server_connection/ServerConnection.h b/server_connection/ServerConnection.h index 5373221..9712f5f 100644 --- a/server_connection/ServerConnection.h +++ b/server_connection/ServerConnection.h @@ -39,8 +39,8 @@ #include <cert.h> #include <keyhi.h> -#include <misc/dead.h> #include <misc/debug.h> +#include <misc/debugerror.h> #include <protocol/scproto.h> #include <protocol/msgproto.h> #include <system/DebugObject.h> @@ -201,6 +201,7 @@ typedef struct { BPending start_job; DebugObject d_obj; + DebugError d_err; } ServerConnection; /** |