Remove redundant DCB state DCB_STATE_FREED, remove obsolete assertion from poll.c, tidy up.

This commit is contained in:
counterpoint
2015-08-25 09:11:44 +01:00
parent ae669c6f88
commit 12922225b8
4 changed files with 16 additions and 23 deletions

View File

@ -409,7 +409,6 @@ dcb_process_zombies(int threadid)
DCB *zombiedcb, *previousdcb; DCB *zombiedcb, *previousdcb;
DCB *listofdcb = NULL; DCB *listofdcb = NULL;
DCB *dcb = NULL; DCB *dcb = NULL;
bool succp = false;
/** /**
* Perform a dirty read to see if there is anything in the queue. * Perform a dirty read to see if there is anything in the queue.
@ -470,15 +469,14 @@ bool succp = false;
LOGIF(LD, (skygw_log_write_flush( LOGIF(LD, (skygw_log_write_flush(
LOGFILE_DEBUG, LOGFILE_DEBUG,
"%lu [dcb_process_zombies] Remove dcb " "%lu [%s] Remove dcb "
"%p fd %d in state %s from the " "%p fd %d in state %s from the "
"list of zombies.", "list of zombies.",
pthread_self(), pthread_self(),
__func__,
zombiedcb, zombiedcb,
zombiedcb->fd, zombiedcb->fd,
STRDCBSTATE(zombiedcb->state)))); STRDCBSTATE(zombiedcb->state))));
ss_info_dassert(zombiedcb->state == DCB_STATE_ZOMBIE,
"dcb not in DCB_STATE_ZOMBIE state.");
/*< /*<
* Move zombie dcb to linked list of victim dcbs. * Move zombie dcb to linked list of victim dcbs.
* The variable dcb is used to hold the last DCB * The variable dcb is used to hold the last DCB
@ -553,15 +551,16 @@ dcb_process_victim_queue(DCB *listofdcb)
dcb, dcb,
STRDCBSTATE(dcb->state)))); STRDCBSTATE(dcb->state))));
} }
if ((dcb->state == DCB_STATE_POLLING && !dcb_maybe_add_persistent(dcb)) else {
|| (dcb->state == DCB_STATE_LISTENING)) /* Must be DCB_STATE_POLLING */
{ if (dcb_maybe_add_persistent(dcb))
dcb_close_finish(dcb); {
/* Have taken DCB into persistent pool, no further killing */
continue;
}
} }
dcb_close_finish(dcb);
} }
/* If DCB was put into persistent queue, will no longer be flagged zombie */
if (!dcb->dcb_is_zombie) continue;
if (dcb->fd > 0) if (dcb->fd > 0)
{ {
@ -603,10 +602,10 @@ dcb_process_victim_queue(DCB *listofdcb)
&tls_log_info.li_sesid, &tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs))); &tls_log_info.li_enabled_logs)));
dcb->state = DCB_STATE_DISCONNECTED; dcb->state = DCB_STATE_DISCONNECTED;
nextdcb = dcb->memdata.next; nextdcb = dcb->memdata.next;
dcb_final_free(dcb); dcb_final_free(dcb);
dcb = nextdcb; dcb = nextdcb;
} }
/** Reset threads session data */ /** Reset threads session data */
LOGIF(LT, tls_log_info.li_sesid = 0); LOGIF(LT, tls_log_info.li_sesid = 0);
@ -732,7 +731,6 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
session->client, session->client,
session->client->fd))); session->client->fd)));
} }
ss_dassert(dcb->fd == DCBFD_CLOSED); /*< must be uninitialized at this point */
/** /**
* Successfully connected to backend. Assign file descriptor to dcb * Successfully connected to backend. Assign file descriptor to dcb
*/ */
@ -2281,8 +2279,6 @@ gw_dcb_state2string (int state)
return "DCB for listening socket"; return "DCB for listening socket";
case DCB_STATE_DISCONNECTED: case DCB_STATE_DISCONNECTED:
return "DCB socket closed"; return "DCB socket closed";
case DCB_STATE_FREED:
return "DCB memory could be freed";
case DCB_STATE_ZOMBIE: case DCB_STATE_ZOMBIE:
return "DCB Zombie"; return "DCB Zombie";
case DCB_STATE_UNDEFINED: case DCB_STATE_UNDEFINED:

View File

@ -866,7 +866,6 @@ unsigned long qtime;
ss_debug(spinlock_acquire(&dcb->dcb_initlock);) ss_debug(spinlock_acquire(&dcb->dcb_initlock);)
ss_dassert(dcb->state != DCB_STATE_ALLOC); ss_dassert(dcb->state != DCB_STATE_ALLOC);
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED); ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
ss_dassert(dcb->state != DCB_STATE_FREED);
ss_debug(spinlock_release(&dcb->dcb_initlock);) ss_debug(spinlock_release(&dcb->dcb_initlock);)
LOGIF(LD, (skygw_log_write( LOGIF(LD, (skygw_log_write(

View File

@ -179,7 +179,6 @@ typedef enum {
DCB_STATE_DISCONNECTED, /*< The socket is now closed */ DCB_STATE_DISCONNECTED, /*< The socket is now closed */
DCB_STATE_NOPOLLING, /*< Removed from poll mask */ DCB_STATE_NOPOLLING, /*< Removed from poll mask */
DCB_STATE_ZOMBIE, /*< DCB is no longer active, waiting to free it */ DCB_STATE_ZOMBIE, /*< DCB is no longer active, waiting to free it */
DCB_STATE_FREED /*< Memory freed */
} dcb_state_t; } dcb_state_t;
typedef enum { typedef enum {

View File

@ -206,9 +206,8 @@ typedef enum skygw_chk_t {
((s) == DCB_STATE_LISTENING ? "DCB_STATE_LISTENING" : \ ((s) == DCB_STATE_LISTENING ? "DCB_STATE_LISTENING" : \
((s) == DCB_STATE_DISCONNECTED ? "DCB_STATE_DISCONNECTED" : \ ((s) == DCB_STATE_DISCONNECTED ? "DCB_STATE_DISCONNECTED" : \
((s) == DCB_STATE_NOPOLLING ? "DCB_STATE_NOPOLLING" : \ ((s) == DCB_STATE_NOPOLLING ? "DCB_STATE_NOPOLLING" : \
((s) == DCB_STATE_FREED ? "DCB_STATE_FREED" : \ ((s) == DCB_STATE_ZOMBIE ? "DCB_STATE_ZOMBIE" : \
((s) == DCB_STATE_ZOMBIE ? "DCB_STATE_ZOMBIE" : \ ((s) == DCB_STATE_UNDEFINED ? "DCB_STATE_UNDEFINED" : "DCB_STATE_UNKNOWN"))))))))
((s) == DCB_STATE_UNDEFINED ? "DCB_STATE_UNDEFINED" : "DCB_STATE_UNKNOWN"))))))))
#define STRSESSIONSTATE(s) ((s) == SESSION_STATE_ALLOC ? "SESSION_STATE_ALLOC" : \ #define STRSESSIONSTATE(s) ((s) == SESSION_STATE_ALLOC ? "SESSION_STATE_ALLOC" : \
((s) == SESSION_STATE_READY ? "SESSION_STATE_READY" : \ ((s) == SESSION_STATE_READY ? "SESSION_STATE_READY" : \