Hopefully final tidy up.
This commit is contained in:
parent
0c98a318dd
commit
09fdb0a2c2
@ -41,9 +41,9 @@
|
||||
* 30/10/14 Massimiliano Pinto Added disable_master_failback parameter
|
||||
* 07/11/14 Massimiliano Pinto Addition of monitor timeouts for connect/read/write
|
||||
* 20/02/15 Markus Mäkelä Added connection_timeout parameter for services
|
||||
* 05/03/15 Massimiliano Pinto Added notification_feedback support
|
||||
* 05/03/15 Massimiliano Pinto Added notification_feedback support
|
||||
* 20/04/15 Guillaume Lefranc Added available_when_donor parameter
|
||||
* 22/04/15 Martin Brampton Added disable_master_role_setting parameter
|
||||
* 22/04/15 Martin Brampton Added disable_master_role_setting parameter
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
@ -639,22 +639,9 @@ char *user;
|
||||
"%lu [dcb_connect] Failed to link to session, the "
|
||||
"session has been removed.\n",
|
||||
pthread_self())));
|
||||
dcb_final_free(dcb);
|
||||
dcb_close(dcb);
|
||||
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)));
|
||||
@ -663,10 +650,10 @@ char *user;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to find a reusable persistent connection.\n",
|
||||
pthread_self())));
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to find a reusable persistent connection.\n",
|
||||
pthread_self())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,7 +732,7 @@ char *user;
|
||||
|
||||
/** Copy status field to DCB */
|
||||
dcb->dcb_server_status = server->status;
|
||||
ss_debug(dcb->dcb_port = server->port;)
|
||||
dcb->dcb_port = server->port;
|
||||
|
||||
/**
|
||||
* backend_dcb is connected to backend server, and once backend_dcb
|
||||
@ -760,9 +747,9 @@ char *user;
|
||||
rc = poll_add_dcb(dcb);
|
||||
|
||||
if (rc == DCBFD_CLOSED) {
|
||||
dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
}
|
||||
/**
|
||||
* The dcb will be addded into poll set by dcb->func.connect
|
||||
@ -2025,6 +2012,7 @@ dcb_close(DCB *dcb)
|
||||
* Add DCB to persistent pool if it qualifies, close otherwise
|
||||
*
|
||||
* @param dcb The DCB to go to persistent pool or be closed
|
||||
* @return bool - whether the DCB was added to the pool
|
||||
*
|
||||
*/
|
||||
static bool
|
||||
@ -2114,7 +2102,9 @@ printDCB(DCB *dcb)
|
||||
if (dcb->remote)
|
||||
printf("\tConnected to: %s\n", dcb->remote);
|
||||
if (dcb->user)
|
||||
printf("\tUsername to: %s\n", dcb->user);
|
||||
printf("\tUsername: %s\n", dcb->user);
|
||||
if (dcb->protoname)
|
||||
printf("\tProtocol: %s\n", dcb->protoname);
|
||||
if (dcb->writeq)
|
||||
printf("\tQueued write data: %d\n",gwbuf_length(dcb->writeq));
|
||||
char *statusname = server_status(dcb->server);
|
||||
@ -2196,6 +2186,9 @@ dprintOneDCB(DCB *pdcb, DCB *dcb)
|
||||
if (dcb->user)
|
||||
dcb_printf(pdcb, "\tUsername: %s\n",
|
||||
dcb->user);
|
||||
if (dcb->protoname)
|
||||
dcb_printf(pdcb, "\tProtocol: %s\n",
|
||||
dcb->protoname);
|
||||
if (dcb->writeq)
|
||||
dcb_printf(pdcb, "\tQueued write data: %d\n",
|
||||
gwbuf_length(dcb->writeq));
|
||||
@ -2225,7 +2218,7 @@ dprintOneDCB(DCB *pdcb, DCB *dcb)
|
||||
char buff[20];
|
||||
struct tm * timeinfo;
|
||||
timeinfo = localtime (&dcb->persistentstart);
|
||||
strftime(buff, sizeof(buff), "%b %d %H:%M", timeinfo);
|
||||
strftime(buff, sizeof(buff), "%b %d %H:%M:%S", timeinfo);
|
||||
dcb_printf(pdcb, "\t\tAdded to persistent pool: %s", buff);
|
||||
}
|
||||
}
|
||||
@ -2256,7 +2249,7 @@ DCB *dcb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diagnotic routine to print DCB data in a tabular form.
|
||||
* Diagnostic routine to print DCB data in a tabular form.
|
||||
*
|
||||
* @param pdcb DCB to print results to
|
||||
*/
|
||||
@ -2339,6 +2332,9 @@ dprintDCB(DCB *pdcb, DCB *dcb)
|
||||
if (dcb->user)
|
||||
dcb_printf(pdcb, "\tUsername: %s\n",
|
||||
dcb->user);
|
||||
if (dcb->protoname)
|
||||
dcb_printf(pdcb, "\tProtocol: %s\n",
|
||||
dcb->protoname);
|
||||
dcb_printf(pdcb, "\tOwning Session: %p\n", dcb->session);
|
||||
if (dcb->writeq)
|
||||
dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq));
|
||||
@ -2396,7 +2392,7 @@ dprintDCB(DCB *pdcb, DCB *dcb)
|
||||
char buff[20];
|
||||
struct tm * timeinfo;
|
||||
timeinfo = localtime (&dcb->persistentstart);
|
||||
strftime(buff, sizeof(buff), "%b %d %H:%M", timeinfo);
|
||||
strftime(buff, sizeof(buff), "%b %d %H:%M:%S", timeinfo);
|
||||
dcb_printf(pdcb, "\t\tAdded to persistent pool: %s", buff);
|
||||
}
|
||||
}
|
||||
@ -3069,6 +3065,9 @@ dcb_null_auth(DCB *dcb, SERVER *server, SESSION *session, GWBUF *buf)
|
||||
* Check persistent pool for expiry or excess size and count
|
||||
*
|
||||
* @param dcb The DCB being closed.
|
||||
* @param cleanall Boolean, if true the whole pool is cleared for the
|
||||
* server related to the given DCB
|
||||
* @return A count of the DCBs remaining in the pool
|
||||
*/
|
||||
int
|
||||
dcb_persistent_clean_count(DCB *dcb, bool cleanall)
|
||||
@ -3083,15 +3082,16 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
|
||||
|
||||
CHK_SERVER(server);
|
||||
spinlock_acquire(&server->persistlock);
|
||||
persistentdcb = server->persistent;
|
||||
persistentdcb = server->persistent;
|
||||
while (persistentdcb) {
|
||||
CHK_DCB(persistentdcb);
|
||||
nextdcb = persistentdcb->nextpersistent;
|
||||
nextdcb = persistentdcb->nextpersistent;
|
||||
if (cleanall
|
||||
|| persistentdcb-> dcb_errhandle_called
|
||||
|| count >= server->persistpoolmax
|
||||
|| time(NULL) - persistentdcb->persistentstart > server->persistmaxtime)
|
||||
|| persistentdcb-> dcb_errhandle_called
|
||||
|| count >= server->persistpoolmax
|
||||
|| (time(NULL) - persistentdcb->persistentstart) > server->persistmaxtime)
|
||||
{
|
||||
/* Remove from persistent pool */
|
||||
if (previousdcb) {
|
||||
previousdcb->nextpersistent = nextdcb;
|
||||
}
|
||||
@ -3099,6 +3099,7 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
|
||||
{
|
||||
server->persistent = nextdcb;
|
||||
}
|
||||
/* Add removed DCBs to disposal list for processing outside spinlock */
|
||||
persistentdcb->nextpersistent = disposals;
|
||||
disposals = persistentdcb;
|
||||
atomic_add(&server->stats.n_persistent, -1);
|
||||
|
@ -141,8 +141,9 @@ SERVER *server;
|
||||
/**
|
||||
* Get a DCB from the persistent connection pool, if possible
|
||||
*
|
||||
* @param server The server to set the name on
|
||||
* @param user The name of the user needing the connection
|
||||
* @param server The server to set the name on
|
||||
* @param user The name of the user needing the connection
|
||||
* @param protocol The name of the protocol needed for the connection
|
||||
*/
|
||||
DCB *
|
||||
server_get_persistent(SERVER *server, char *user, const char *protocol)
|
||||
@ -154,7 +155,12 @@ server_get_persistent(SERVER *server, char *user, const char *protocol)
|
||||
spinlock_acquire(&server->persistlock);
|
||||
dcb = server->persistent;
|
||||
while (dcb) {
|
||||
if (dcb->user && dcb->protoname && !dcb-> dcb_errhandle_called && 0 == strcmp(dcb->user, user) && 0 == strcmp(dcb->protoname, protocol))
|
||||
if (dcb->user
|
||||
&& dcb->protoname
|
||||
&& !dcb-> dcb_errhandle_called
|
||||
&& !(dcb->flags & DCBF_HUNG)
|
||||
&& 0 == strcmp(dcb->user, user)
|
||||
&& 0 == strcmp(dcb->protoname, protocol))
|
||||
{
|
||||
if (NULL == previous)
|
||||
{
|
||||
@ -171,21 +177,22 @@ server_get_persistent(SERVER *server, char *user, const char *protocol)
|
||||
atomic_add(&server->stats.n_current, 1);
|
||||
return dcb;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [server_get_persistent] Rejected dcb "
|
||||
"%p from pool, user %s looking for %s, protocol %s "
|
||||
"looking for %s, error handle called %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->user ? dcb->user : "NULL",
|
||||
user,
|
||||
dcb->protoname ? dcb->protoname : "NULL",
|
||||
protocol,
|
||||
dcb-> dcb_errhandle_called ? "true" : "false")));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [server_get_persistent] Rejected dcb "
|
||||
"%p from pool, user %s looking for %s, protocol %s "
|
||||
"looking for %s, hung flag %s, error handle called %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->user ? dcb->user : "NULL",
|
||||
user,
|
||||
dcb->protoname ? dcb->protoname : "NULL",
|
||||
protocol,
|
||||
(dcb->flags & DCBF_HUNG) ? "true" : "false",
|
||||
dcb-> dcb_errhandle_called ? "true" : "false")));
|
||||
}
|
||||
previous = dcb;
|
||||
dcb = dcb->nextpersistent;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
*
|
||||
* Date Who Description
|
||||
* 10/06/13 Mark Riddoch Initial implementation
|
||||
* 23/06/15 Martin Brampton Alternative for C++
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <pthread.h>
|
||||
|
||||
#include <memlog.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#define BINLOG_FNAMELEN 16
|
||||
#define BLR_PROTOCOL "MySQLBackend"
|
||||
|
@ -126,6 +126,7 @@ startMonitor(void *arg,void* opt)
|
||||
handle->shutdown = 0;
|
||||
handle->id = MONITOR_DEFAULT_ID;
|
||||
handle->master = NULL;
|
||||
handle->script = NULL;
|
||||
memset(handle->events,false,sizeof(handle->events));
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
* 27/09/2013 Massimiliano Pinto Changed in gw_read_backend_event the check for dcb_read(), now is if rc < 0
|
||||
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
|
||||
* 10/11/2014 Massimiliano Pinto Client charset is passed to backend
|
||||
* 19/06/2015 Martin Brampton Persistent connection handling
|
||||
*
|
||||
*/
|
||||
#include <modinfo.h>
|
||||
|
@ -38,6 +38,7 @@
|
||||
* 13/10/2014 Massimiliano Pinto Added: dbname authentication check
|
||||
* 10/11/2014 Massimiliano Pinto Added: client charset added to protocol struct
|
||||
* 29/05/2015 Markus Makela Added SSL support
|
||||
* 11/06/2015 Martin Brampton COM_QUIT suppressed for persistent connections
|
||||
*/
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
@ -210,9 +210,8 @@ int fd;
|
||||
close(router->binlog_fd);
|
||||
spinlock_acquire(&router->binlog_lock);
|
||||
strncpy(router->binlog_name, file,BINLOG_FNAMELEN);
|
||||
blr_file_add_magic(router, fd);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
router->binlog_fd = fd;
|
||||
spinlock_release(&router->binlog_lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -254,12 +253,13 @@ int fd;
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: binlog file %s has an invalid length %d.",
|
||||
router->service->name, path, router->binlog_position)));
|
||||
close(fd);
|
||||
close(fd);
|
||||
spinlock_release(&router->binlog_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
spinlock_release(&router->binlog_lock);
|
||||
router->binlog_fd = fd;
|
||||
spinlock_release(&router->binlog_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1693,6 +1693,9 @@ uint32_t chksum;
|
||||
|
||||
binlognamelen = strlen(slave->binlogfile);
|
||||
len = 19 + 8 + 4 + binlognamelen;
|
||||
/* no slave crc, remove 4 bytes */
|
||||
if (slave->nocrc)
|
||||
len -= 4;
|
||||
|
||||
// Build a fake rotate event
|
||||
resp = gwbuf_alloc(len + 5);
|
||||
@ -1711,17 +1714,19 @@ uint32_t chksum;
|
||||
memcpy(ptr, slave->binlogfile, binlognamelen);
|
||||
ptr += binlognamelen;
|
||||
|
||||
/*
|
||||
* Now add the CRC to the fake binlog rotate event.
|
||||
*
|
||||
* The algorithm is first to compute the checksum of an empty buffer
|
||||
* and then the checksum of the event portion of the message, ie we do not
|
||||
* include the length, sequence number and ok byte that makes up the first
|
||||
* 5 bytes of the message. We also do not include the 4 byte checksum itself.
|
||||
*/
|
||||
chksum = crc32(0L, NULL, 0);
|
||||
chksum = crc32(chksum, GWBUF_DATA(resp) + 5, hdr.event_size - 4);
|
||||
encode_value(ptr, chksum, 32);
|
||||
if (!slave->nocrc) {
|
||||
/*
|
||||
* Now add the CRC to the fake binlog rotate event.
|
||||
*
|
||||
* The algorithm is first to compute the checksum of an empty buffer
|
||||
* and then the checksum of the event portion of the message, ie we do not
|
||||
* include the length, sequence number and ok byte that makes up the first
|
||||
* 5 bytes of the message. We also do not include the 4 byte checksum itself.
|
||||
*/
|
||||
chksum = crc32(0L, NULL, 0);
|
||||
chksum = crc32(chksum, GWBUF_DATA(resp) + 5, hdr.event_size - 4);
|
||||
encode_value(ptr, chksum, 32);
|
||||
}
|
||||
|
||||
slave->dcb->func.write(slave->dcb, resp);
|
||||
return 1;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* 29/05/14 Mark Riddoch Add Filter support
|
||||
* 16/10/14 Mark Riddoch Add show eventq
|
||||
* 05/03/15 Massimiliano Pinto Added enable/disable feedback
|
||||
* 27/05/15 Martin Brampton Add show persistent [server]
|
||||
* 27/05/15 Martin Brampton Add show persistent [server]
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
@ -67,6 +67,7 @@
|
||||
* 06/03/2014 Massimiliano Pinto Server connection counter is now updated in closeSession
|
||||
* 24/06/2014 Massimiliano Pinto New rules for selecting the Master server
|
||||
* 27/06/2014 Mark Riddoch Addition of server weighting
|
||||
* 11/06/2015 Martin Brampton Remove decrement n_current (moved to dcb.c)
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
@ -1,2 +1,2 @@
|
||||
add_library(utils skygw_utils.cc)
|
||||
add_library(utils skygw_utils.cc ../server/core/atomic.c)
|
||||
target_link_libraries(utils stdc++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user