Try out some more changes.

This commit is contained in:
counterpoint
2015-05-27 16:41:06 +01:00
parent 6c5e6a5959
commit 23e9a7b4e2
3 changed files with 36 additions and 4 deletions

View File

@ -660,6 +660,16 @@ char *user;
return NULL;
}
dcb->dcb_server_status = server->status;
dcb->state = DCB_STATE_ALLOC;
if (poll_add_dcb(dcb))
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [dcb_connect] Failed to add DCB %p to polling.\n",
pthread_self(), dcb)));
dcb_final_free(dcb);
return NULL;
}
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [dcb_connect] Reusing a persistent connection, dcb %p\n", pthread_self(), dcb)));
@ -1293,8 +1303,33 @@ dcb_close(DCB *dcb)
spinlock_acquire(&dcb->server->persistlock);
dcb->nextpersistent = dcb->server->persistent;
dcb->server->persistent = dcb;
if (poll_remove_dcb(dcb))
{
/* Error */
return;
}
dcb->session = NULL;
spinlock_release(&dcb->server->persistlock);
atomic_add(&dcb->server->stats.n_persistent, 1);
spinlock_acquire(&dcb->session->ses_lock);
/**
* If session->state is STOPPING, start closing client session.
* Otherwise only this backend connection is closed.
*/
if (session != NULL &&
session->state == SESSION_STATE_STOPPING &&
session->client != NULL &&
session->client->state == DCB_STATE_POLLING)
{
spinlock_release(&session->ses_lock);
/** Close client DCB */
dcb_close(session->client);
}
else
{
spinlock_release(&session->ses_lock);
}
return;
}
@ -1423,8 +1458,6 @@ DCB *dcb;
void
dprintOneDCB(DCB *pdcb, DCB *dcb)
{
DCB *dcb;
dcb_printf(pdcb, "DCB: %p\n", (void *)dcb);
dcb_printf(pdcb, "\tDCB state: %s\n",
gw_dcb_state2string(dcb->state));

View File

@ -19,7 +19,6 @@
*/
#include <spinlock.h>
#include <buffer.h>
#include <server.h>
#include <modinfo.h>
#include <gwbitmask.h>
#include <skygw_utils.h>

View File

@ -183,7 +183,7 @@ extern void printAllServers();
extern void dprintAllServers(DCB *);
extern void dprintAllServersJson(DCB *);
extern void dprintServer(DCB *, SERVER *);
extern void dprintPersistentDCBs(DCB *, SERVER *)
extern void dprintPersistentDCBs(DCB *, SERVER *);
extern void dListServers(DCB *);
extern char *server_status(SERVER *);
extern void server_set_status(SERVER *, int);