log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed. Changed log manager parameters to match with the current implementation. List of arguments: "-h - help\n" "-a <debug prefix> ............(\"skygw_debug\")\n" "-b <debug suffix> ............(\".log\")\n" "-c <trace prefix> ............(\"skygw_trace\")\n" "-d <trace suffix> ............(\".log\")\n" "-e <message prefix> ............(\"skygw_msg\")\n" "-f <message suffix> ............(\".log\")\n" "-g <error prefix> ............(\"skygw_err\")\n" "-i <error suffix> ............(\".log\")\n" "-j <log path> ............(\"/tmp\")\n" "-s <shmem log file ids> ........(no default)\n"; dcb.c dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it. gateway.c Renamed shutdown_gateway to shutdown_server (Bug #131) Call skygw_logmanager_init so that trace and debug logs are written to shared memory. poll.c dcb.h Removed some dead code and references to unneeded mutexes. debugcmd.c Added enable/disable log command for debug log. skygw_utils.cc skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -27,13 +27,10 @@ typedef enum {
|
|||||||
LOGFILE_FIRST = LOGFILE_ERROR,
|
LOGFILE_FIRST = LOGFILE_ERROR,
|
||||||
LOGFILE_MESSAGE = 2,
|
LOGFILE_MESSAGE = 2,
|
||||||
LOGFILE_TRACE = 4,
|
LOGFILE_TRACE = 4,
|
||||||
LOGFILE_LAST = LOGFILE_TRACE
|
LOGFILE_DEBUG = 8,
|
||||||
|
LOGFILE_LAST = LOGFILE_DEBUG
|
||||||
} logfile_id_t;
|
} logfile_id_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* This is for the future where LOGFILE_DEBUG has separate file.
|
|
||||||
*/
|
|
||||||
#define LOGFILE_DEBUG LOGFILE_TRACE
|
|
||||||
|
|
||||||
typedef enum { FILEWRITER_INIT, FILEWRITER_RUN, FILEWRITER_DONE }
|
typedef enum { FILEWRITER_INIT, FILEWRITER_RUN, FILEWRITER_DONE }
|
||||||
filewriter_state_t;
|
filewriter_state_t;
|
||||||
|
@ -106,10 +106,6 @@ if ((rval = calloc(1, sizeof(DCB))) == NULL)
|
|||||||
rval->dcb_chk_tail = CHK_NUM_DCB;
|
rval->dcb_chk_tail = CHK_NUM_DCB;
|
||||||
#endif
|
#endif
|
||||||
rval->dcb_role = role;
|
rval->dcb_role = role;
|
||||||
simple_mutex_init(&rval->dcb_write_lock, "DCB write mutex");
|
|
||||||
simple_mutex_init(&rval->dcb_read_lock, "DCB read mutex");
|
|
||||||
rval->dcb_write_active = false;
|
|
||||||
rval->dcb_read_active = false;
|
|
||||||
spinlock_init(&rval->dcb_initlock);
|
spinlock_init(&rval->dcb_initlock);
|
||||||
spinlock_init(&rval->writeqlock);
|
spinlock_init(&rval->writeqlock);
|
||||||
spinlock_init(&rval->delayqlock);
|
spinlock_init(&rval->delayqlock);
|
||||||
@ -169,7 +165,13 @@ dcb_add_to_zombieslist(DCB *dcb)
|
|||||||
spinlock_release(&zombiespin);
|
spinlock_release(&zombiespin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if 1
|
||||||
|
/**
|
||||||
|
* Add closing dcb to the top of the list.
|
||||||
|
*/
|
||||||
|
dcb->memdata.next = zombies;
|
||||||
|
zombies = dcb;
|
||||||
|
#else
|
||||||
if (zombies == NULL) {
|
if (zombies == NULL) {
|
||||||
zombies = dcb;
|
zombies = dcb;
|
||||||
} else {
|
} else {
|
||||||
@ -199,6 +201,7 @@ dcb_add_to_zombieslist(DCB *dcb)
|
|||||||
ptr->memdata.next = dcb;
|
ptr->memdata.next = dcb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Set state which indicates that it has been added to zombies
|
* Set state which indicates that it has been added to zombies
|
||||||
* list.
|
* list.
|
||||||
@ -319,7 +322,7 @@ bool succp = false;
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Remove the DCB from the zombie queue
|
* Remove the DCB from the zombie queue
|
||||||
* and call the final free routine for the
|
* and call the final free routine for the
|
||||||
* DCB
|
* DCB
|
||||||
*
|
*
|
||||||
* ptr is the DCB we are processing
|
* ptr is the DCB we are processing
|
||||||
@ -334,7 +337,7 @@ bool succp = false;
|
|||||||
else
|
else
|
||||||
lptr->memdata.next = tptr;
|
lptr->memdata.next = tptr;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_process_zombies] Remove dcb %p fd %d "
|
"%lu [dcb_process_zombies] Remove dcb %p fd %d "
|
||||||
"in state %s from zombies list.",
|
"in state %s from zombies list.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -389,7 +392,7 @@ bool succp = false;
|
|||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
else {
|
else {
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_process_zombies] Closed socket "
|
"%lu [dcb_process_zombies] Closed socket "
|
||||||
"%d on dcb %p.",
|
"%d on dcb %p.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -454,7 +457,7 @@ int rc;
|
|||||||
if (!session_link_dcb(session, dcb))
|
if (!session_link_dcb(session, dcb))
|
||||||
{
|
{
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_connect] Failed to link to session, the "
|
"%lu [dcb_connect] Failed to link to session, the "
|
||||||
"session has been removed.",
|
"session has been removed.",
|
||||||
pthread_self());
|
pthread_self());
|
||||||
@ -465,7 +468,7 @@ int rc;
|
|||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_connect] Failed to connect to server %s:%d, "
|
"%lu [dcb_connect] Failed to connect to server %s:%d, "
|
||||||
"from backend dcb %p, client dcp %p fd %d.",
|
"from backend dcb %p, client dcp %p fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -479,7 +482,7 @@ int rc;
|
|||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_connect] Connected to server %s:%d, "
|
"%lu [dcb_connect] Connected to server %s:%d, "
|
||||||
"from backend dcb %p, client dcp %p fd %d.",
|
"from backend dcb %p, client dcp %p fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -621,7 +624,7 @@ int eno = 0;
|
|||||||
goto return_n;
|
goto return_n;
|
||||||
}
|
}
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_read] Read %d bytes from dcb %p in state %s "
|
"%lu [dcb_read] Read %d bytes from dcb %p in state %s "
|
||||||
"fd %d.",
|
"fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -671,7 +674,7 @@ dcb_write(DCB *dcb, GWBUF *queue)
|
|||||||
dcb->writeq = gwbuf_append(dcb->writeq, queue);
|
dcb->writeq = gwbuf_append(dcb->writeq, queue);
|
||||||
dcb->stats.n_buffered++;
|
dcb->stats.n_buffered++;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_write] Append to writequeue. %d writes "
|
"%lu [dcb_write] Append to writequeue. %d writes "
|
||||||
"buffered for dcb %p in state %s fd %d",
|
"buffered for dcb %p in state %s fd %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -722,7 +725,7 @@ dcb_write(DCB *dcb, GWBUF *queue)
|
|||||||
|
|
||||||
if (saved_errno == EPIPE) {
|
if (saved_errno == EPIPE) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_write] Write to dcb "
|
"%lu [dcb_write] Write to dcb "
|
||||||
"%p in state %s fd %d failed "
|
"%p in state %s fd %d failed "
|
||||||
"due errno %d, %s",
|
"due errno %d, %s",
|
||||||
@ -754,7 +757,7 @@ dcb_write(DCB *dcb, GWBUF *queue)
|
|||||||
*/
|
*/
|
||||||
queue = gwbuf_consume(queue, w);
|
queue = gwbuf_consume(queue, w);
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
"%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
||||||
"state %s fd %d",
|
"state %s fd %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -853,7 +856,7 @@ int saved_errno = 0;
|
|||||||
*/
|
*/
|
||||||
dcb->writeq = gwbuf_consume(dcb->writeq, w);
|
dcb->writeq = gwbuf_consume(dcb->writeq, w);
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_drain_writeq] Wrote %d Bytes to dcb %p "
|
"%lu [dcb_drain_writeq] Wrote %d Bytes to dcb %p "
|
||||||
"in state %s fd %d",
|
"in state %s fd %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -902,8 +905,8 @@ dcb_close(DCB *dcb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ss_dassert(dcb->state == DCB_STATE_POLLING ||
|
ss_dassert(dcb->state == DCB_STATE_POLLING ||
|
||||||
dcb->state == DCB_STATE_NOPOLLING ||
|
dcb->state == DCB_STATE_NOPOLLING ||
|
||||||
dcb->state == DCB_STATE_ZOMBIE);
|
dcb->state == DCB_STATE_ZOMBIE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop dcb's listening and modify state accordingly.
|
* Stop dcb's listening and modify state accordingly.
|
||||||
@ -915,7 +918,7 @@ dcb_close(DCB *dcb)
|
|||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_close] Removed dcb %p in state %s from "
|
"%lu [dcb_close] Removed dcb %p in state %s from "
|
||||||
"poll set.",
|
"poll set.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -1262,7 +1265,7 @@ static bool dcb_set_state_nomutex(
|
|||||||
|
|
||||||
if (succp) {
|
if (succp) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [dcb_set_state_nomutex] dcb %p fd %d %s -> %s",
|
"%lu [dcb_set_state_nomutex] dcb %p fd %d %s -> %s",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
dcb,
|
dcb,
|
||||||
|
@ -112,24 +112,23 @@ static void sighup_handler (int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sigterm_handler (int i) {
|
static void sigterm_handler (int i) {
|
||||||
extern void shutdown_gateway();
|
extern void shutdown_server();
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Signal SIGTERM %i received ...Exiting!", i);
|
"MaxScale received signal SIGTERM. Exiting.");
|
||||||
shutdown_gateway();
|
shutdown_server();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigint_handler (int i)
|
sigint_handler (int i)
|
||||||
{
|
{
|
||||||
extern void shutdown_gateway();
|
extern void shutdown_server();
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Signal SIGINT %i received ...Exiting!",
|
"MaxScale received signal SIGINT. Shutting down.");
|
||||||
i);
|
shutdown_server();
|
||||||
shutdown_gateway();
|
|
||||||
fprintf(stderr, "\n\nShutting down MaxScale\n\n");
|
fprintf(stderr, "\n\nShutting down MaxScale\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,15 +484,17 @@ main(int argc, char **argv)
|
|||||||
if (home)
|
if (home)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *argv[4];
|
char *argv[6];
|
||||||
|
|
||||||
sprintf(buf, "%s/log", home);
|
sprintf(buf, "%s/log", home);
|
||||||
mkdir(buf, 0777);
|
mkdir(buf, 0777);
|
||||||
argv[0] = "MaxScale";
|
argv[0] = "MaxScale";
|
||||||
argv[1] = "-g";
|
argv[1] = "-j";
|
||||||
argv[2] = buf;
|
argv[2] = buf;
|
||||||
argv[3] = NULL;
|
argv[3] = "-s"; /**<! store to shared memory.. */
|
||||||
skygw_logmanager_init(3, argv);
|
argv[4] = "LOGFILE_DEBUG,LOGFILE_TRACE"; /**<! ..these logs */
|
||||||
|
argv[5] = NULL;
|
||||||
|
skygw_logmanager_init(5, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cnf_file == NULL) {
|
if (cnf_file == NULL) {
|
||||||
@ -614,10 +615,10 @@ main(int argc, char **argv)
|
|||||||
} // End of main
|
} // End of main
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the gateway
|
* Shutdown MaxScale server
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
shutdown_gateway()
|
shutdown_server()
|
||||||
{
|
{
|
||||||
poll_shutdown();
|
poll_shutdown();
|
||||||
log_flush_shutdown();
|
log_flush_shutdown();
|
||||||
@ -638,6 +639,7 @@ static void log_flush_cb(
|
|||||||
skygw_log_flush(LOGFILE_ERROR);
|
skygw_log_flush(LOGFILE_ERROR);
|
||||||
skygw_log_flush(LOGFILE_MESSAGE);
|
skygw_log_flush(LOGFILE_MESSAGE);
|
||||||
skygw_log_flush(LOGFILE_TRACE);
|
skygw_log_flush(LOGFILE_TRACE);
|
||||||
|
skygw_log_flush(LOGFILE_DEBUG);
|
||||||
usleep(timeout_ms*1000);
|
usleep(timeout_ms*1000);
|
||||||
}
|
}
|
||||||
skygw_log_write(LOGFILE_MESSAGE, "Finished MaxScale log flusher.");
|
skygw_log_write(LOGFILE_MESSAGE, "Finished MaxScale log flusher.");
|
||||||
|
@ -343,9 +343,9 @@ poll_waitevents(void *arg)
|
|||||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||||
ss_dassert(dcb->state != DCB_STATE_FREED);
|
ss_dassert(dcb->state != DCB_STATE_FREED);
|
||||||
ss_debug(spinlock_release(&dcb->dcb_initlock);)
|
ss_debug(spinlock_release(&dcb->dcb_initlock);)
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_TRACE,
|
||||||
"%lu [poll_waitevents] event %d dcb %p "
|
"%lu [poll_waitevents] event %d dcb %p "
|
||||||
"role %s",
|
"role %s",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -388,7 +388,7 @@ poll_waitevents(void *arg)
|
|||||||
eno = gw_getsockerrno(dcb->fd);
|
eno = gw_getsockerrno(dcb->fd);
|
||||||
|
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"EPOLLHUP on dcb %p, fd %d. "
|
"EPOLLHUP on dcb %p, fd %d. "
|
||||||
"Errno %d, %s.",
|
"Errno %d, %s.",
|
||||||
@ -406,25 +406,13 @@ poll_waitevents(void *arg)
|
|||||||
eno = gw_getsockerrno(dcb->fd);
|
eno = gw_getsockerrno(dcb->fd);
|
||||||
|
|
||||||
if (eno == 0) {
|
if (eno == 0) {
|
||||||
#if 0
|
atomic_add(
|
||||||
simple_mutex_lock(
|
&pollStats.n_write,
|
||||||
&dcb->dcb_write_lock,
|
1);
|
||||||
true);
|
|
||||||
ss_info_dassert(
|
|
||||||
!dcb->dcb_write_active,
|
|
||||||
"Write already active");
|
|
||||||
dcb->dcb_write_active = TRUE;
|
|
||||||
#endif
|
|
||||||
atomic_add(&pollStats.n_write, 1);
|
|
||||||
dcb->func.write_ready(dcb);
|
dcb->func.write_ready(dcb);
|
||||||
#if 0
|
|
||||||
dcb->dcb_write_active = FALSE;
|
|
||||||
simple_mutex_unlock(
|
|
||||||
&dcb->dcb_write_lock);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"EPOLLOUT due %d, %s. "
|
"EPOLLOUT due %d, %s. "
|
||||||
"dcb %p, fd %i",
|
"dcb %p, fd %i",
|
||||||
@ -437,13 +425,6 @@ poll_waitevents(void *arg)
|
|||||||
}
|
}
|
||||||
if (ev & EPOLLIN)
|
if (ev & EPOLLIN)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
simple_mutex_lock(&dcb->dcb_read_lock,
|
|
||||||
true);
|
|
||||||
ss_info_dassert(!dcb->dcb_read_active,
|
|
||||||
"Read already active");
|
|
||||||
dcb->dcb_read_active = TRUE;
|
|
||||||
#endif
|
|
||||||
if (dcb->state == DCB_STATE_LISTENING)
|
if (dcb->state == DCB_STATE_LISTENING)
|
||||||
{
|
{
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
@ -468,11 +449,6 @@ poll_waitevents(void *arg)
|
|||||||
atomic_add(&pollStats.n_read, 1);
|
atomic_add(&pollStats.n_read, 1);
|
||||||
dcb->func.read(dcb);
|
dcb->func.read(dcb);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
dcb->dcb_read_active = FALSE;
|
|
||||||
simple_mutex_unlock(
|
|
||||||
&dcb->dcb_read_lock);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} /**< for */
|
} /**< for */
|
||||||
no_op = FALSE;
|
no_op = FALSE;
|
||||||
|
@ -156,11 +156,7 @@ typedef struct dcb {
|
|||||||
#endif
|
#endif
|
||||||
dcb_role_t dcb_role;
|
dcb_role_t dcb_role;
|
||||||
SPINLOCK dcb_initlock;
|
SPINLOCK dcb_initlock;
|
||||||
simple_mutex_t dcb_read_lock;
|
int fd; /**< The descriptor */
|
||||||
simple_mutex_t dcb_write_lock;
|
|
||||||
int fd; /**< The descriptor */
|
|
||||||
bool dcb_read_active;
|
|
||||||
bool dcb_write_active;
|
|
||||||
dcb_state_t state; /**< Current descriptor state */
|
dcb_state_t state; /**< Current descriptor state */
|
||||||
char *remote; /**< Address of remote end */
|
char *remote; /**< Address of remote end */
|
||||||
void *protocol; /**< The protocol specific state */
|
void *protocol; /**< The protocol specific state */
|
||||||
|
@ -253,7 +253,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
|||||||
backend_protocol->state = MYSQL_IDLE;
|
backend_protocol->state = MYSQL_IDLE;
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_read_backend_event] "
|
"%lu [gw_read_backend_event] "
|
||||||
"gw_receive_backend_auth succeed. "
|
"gw_receive_backend_auth succeed. "
|
||||||
"dcb %p fd %d, user %s.",
|
"dcb %p fd %d, user %s.",
|
||||||
@ -265,7 +265,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
|||||||
default:
|
default:
|
||||||
ss_dassert(receive_rc == 0);
|
ss_dassert(receive_rc == 0);
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_read_backend_event] "
|
"%lu [gw_read_backend_event] "
|
||||||
"gw_receive_backend_auth read "
|
"gw_receive_backend_auth read "
|
||||||
"successfully "
|
"successfully "
|
||||||
@ -436,7 +436,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
|||||||
"Writing to backend failed due invalid Maxscale "
|
"Writing to backend failed due invalid Maxscale "
|
||||||
"state.");
|
"state.");
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_write_backend_event] Write to backend "
|
"%lu [gw_write_backend_event] Write to backend "
|
||||||
"dcb %p fd %d "
|
"dcb %p fd %d "
|
||||||
"failed due invalid state %s.",
|
"failed due invalid state %s.",
|
||||||
@ -454,7 +454,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
} else {
|
} else {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_write_backend_event] Dcb %p in state %s "
|
"%lu [gw_write_backend_event] Dcb %p in state %s "
|
||||||
"but there's nothing to write either.",
|
"but there's nothing to write either.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -474,7 +474,7 @@ static int gw_write_backend_event(DCB *dcb) {
|
|||||||
rc = 1;
|
rc = 1;
|
||||||
return_rc:
|
return_rc:
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_write_backend_event] "
|
"%lu [gw_write_backend_event] "
|
||||||
"wrote to dcb %p fd %d, return %d",
|
"wrote to dcb %p fd %d, return %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -508,7 +508,7 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
|||||||
gwbuf_consume(queue, GWBUF_LENGTH(queue));
|
gwbuf_consume(queue, GWBUF_LENGTH(queue));
|
||||||
|
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_MySQLWrite_backend] Write to backend failed. "
|
"%lu [gw_MySQLWrite_backend] Write to backend failed. "
|
||||||
"Backend dcb %p fd %d is %s.",
|
"Backend dcb %p fd %d is %s.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -602,7 +602,7 @@ static int gw_error_backend_event(DCB *dcb) {
|
|||||||
* rsession should never be NULL here.
|
* rsession should never be NULL here.
|
||||||
*/
|
*/
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_error_backend_event] "
|
"%lu [gw_error_backend_event] "
|
||||||
"Call closeSession for backend "
|
"Call closeSession for backend "
|
||||||
"session.",
|
"session.",
|
||||||
@ -641,7 +641,7 @@ static int gw_create_backend_connection(
|
|||||||
|
|
||||||
if (protocol == NULL) {
|
if (protocol == NULL) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_create_backend_connection] Failed to create "
|
"%lu [gw_create_backend_connection] Failed to create "
|
||||||
"protocol object for backend connection.",
|
"protocol object for backend connection.",
|
||||||
pthread_self());
|
pthread_self());
|
||||||
@ -664,7 +664,7 @@ static int gw_create_backend_connection(
|
|||||||
protocol->fd = fd;
|
protocol->fd = fd;
|
||||||
protocol->state = MYSQL_CONNECTED;
|
protocol->state = MYSQL_CONNECTED;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_create_backend_connection] Established "
|
"%lu [gw_create_backend_connection] Established "
|
||||||
"connection to %s:%i, protocol fd %d client "
|
"connection to %s:%i, protocol fd %d client "
|
||||||
"fd %d.",
|
"fd %d.",
|
||||||
@ -680,7 +680,7 @@ static int gw_create_backend_connection(
|
|||||||
protocol->state = MYSQL_PENDING_CONNECT;
|
protocol->state = MYSQL_PENDING_CONNECT;
|
||||||
protocol->fd = fd;
|
protocol->fd = fd;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_create_backend_connection] Connection "
|
"%lu [gw_create_backend_connection] Connection "
|
||||||
"pending to %s:%i, protocol fd %d client fd %d.",
|
"pending to %s:%i, protocol fd %d client fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -694,7 +694,7 @@ static int gw_create_backend_connection(
|
|||||||
ss_dassert(fd == -1);
|
ss_dassert(fd == -1);
|
||||||
ss_dassert(protocol->state == MYSQL_ALLOC);
|
ss_dassert(protocol->state == MYSQL_ALLOC);
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_create_backend_connection] Connection "
|
"%lu [gw_create_backend_connection] Connection "
|
||||||
"failed to %s:%i, protocol fd %d client fd %d.",
|
"failed to %s:%i, protocol fd %d client fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
|
@ -977,7 +977,7 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
listener->stats.n_accepts++;
|
listener->stats.n_accepts++;
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_MySQLAccept] Accepted fd %d.",
|
"%lu [gw_MySQLAccept] Accepted fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
c_sock);
|
c_sock);
|
||||||
@ -1046,7 +1046,7 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_MySQLAccept] Added dcb %p for fd "
|
"%lu [gw_MySQLAccept] Added dcb %p for fd "
|
||||||
"%d to epoll set.",
|
"%d to epoll set.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
|
@ -328,7 +328,7 @@ int gw_receive_backend_auth(
|
|||||||
(uint8_t *)calloc(1, GWBUF_LENGTH(head)+1);
|
(uint8_t *)calloc(1, GWBUF_LENGTH(head)+1);
|
||||||
memcpy(tmpbuf, ptr, GWBUF_LENGTH(head));
|
memcpy(tmpbuf, ptr, GWBUF_LENGTH(head));
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_receive_backend_auth] Invalid "
|
"%lu [gw_receive_backend_auth] Invalid "
|
||||||
"authentication message from backend dcb %p "
|
"authentication message from backend dcb %p "
|
||||||
"fd %d, ptr[4] = %p, msg %s.",
|
"fd %d, ptr[4] = %p, msg %s.",
|
||||||
@ -358,7 +358,7 @@ int gw_receive_backend_auth(
|
|||||||
*/
|
*/
|
||||||
rc = 0;
|
rc = 0;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_receive_backend_auth] Read zero bytes from "
|
"%lu [gw_receive_backend_auth] Read zero bytes from "
|
||||||
"backend dcb %p fd %d in state %s. n %d, head %p, len %d",
|
"backend dcb %p fd %d in state %s. n %d, head %p, len %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -374,7 +374,7 @@ int gw_receive_backend_auth(
|
|||||||
ss_dassert(n < 0 && head == NULL);
|
ss_dassert(n < 0 && head == NULL);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_receive_backend_auth] Reading from backend dcb %p "
|
"%lu [gw_receive_backend_auth] Reading from backend dcb %p "
|
||||||
"fd %d in state %s failed. n %d, head %p, len %d",
|
"fd %d in state %s failed. n %d, head %p, len %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -672,7 +672,7 @@ int gw_do_connect_to_backend(
|
|||||||
}
|
}
|
||||||
*fd = so;
|
*fd = so;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [gw_do_connect_to_backend] Connected to backend server "
|
"%lu [gw_do_connect_to_backend] Connected to backend server "
|
||||||
"%s:%d, fd %d.",
|
"%s:%d, fd %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
|
@ -114,7 +114,7 @@ struct subcommand showoptions[] = {
|
|||||||
{0, 0, 0} }
|
{0, 0, 0} }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void shutdown_gateway();
|
extern void shutdown_maxscale();
|
||||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||||
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
|
|
||||||
@ -122,16 +122,37 @@ static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
|||||||
* The subcommands of the shutdown command
|
* The subcommands of the shutdown command
|
||||||
*/
|
*/
|
||||||
struct subcommand shutdownoptions[] = {
|
struct subcommand shutdownoptions[] = {
|
||||||
{ "maxscale", 0, shutdown_gateway, "Shutdown the MaxScale gateway",
|
{ "maxscale",
|
||||||
{0, 0, 0} },
|
0,
|
||||||
{ "monitor", 1, shutdown_monitor, "Shutdown a monitor, e.g. shutdown monitor 0x48381e0",
|
shutdown_maxscale,
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
"Shutdown MaxScale",
|
||||||
{ "service", 1, shutdown_service, "Shutdown a service, e.g. shutdown service 0x4838320",
|
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{0, 0, 0}
|
||||||
{ NULL, 0, NULL, NULL,
|
},
|
||||||
{0, 0, 0} }
|
{
|
||||||
|
"monitor",
|
||||||
|
1,
|
||||||
|
shutdown_monitor,
|
||||||
|
"Shutdown a monitor, e.g. shutdown monitor 0x48381e0",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"service",
|
||||||
|
1,
|
||||||
|
shutdown_service,
|
||||||
|
"Shutdown a service, e.g. shutdown service 0x4838320",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
{0, 0, 0}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void restart_service(DCB *dcb, SERVICE *service);
|
static void restart_service(DCB *dcb, SERVICE *service);
|
||||||
static void restart_monitor(DCB *dcb, MONITOR *monitor);
|
static void restart_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
/**
|
/**
|
||||||
@ -216,8 +237,8 @@ struct subcommand disableoptions[] = {
|
|||||||
"log",
|
"log",
|
||||||
1,
|
1,
|
||||||
disable_log_action,
|
disable_log_action,
|
||||||
"Disable Log for MaxScale, Options: trace | error | message E.g. "
|
"Disable Log for MaxScale, Options: debug | trace | error | message "
|
||||||
"disable log trace",
|
"E.g. disable log debug",
|
||||||
{ARG_TYPE_STRING, 0, 0}
|
{ARG_TYPE_STRING, 0, 0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -726,7 +747,9 @@ static void enable_log_action(DCB *dcb, char *arg1) {
|
|||||||
logfile_id_t type;
|
logfile_id_t type;
|
||||||
int max_len = strlen("message");
|
int max_len = strlen("message");
|
||||||
|
|
||||||
if (strncmp(arg1, "trace", max_len) == 0) {
|
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||||
|
type = LOGFILE_DEBUG;
|
||||||
|
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||||
type = LOGFILE_TRACE;
|
type = LOGFILE_TRACE;
|
||||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||||
type = LOGFILE_ERROR;
|
type = LOGFILE_ERROR;
|
||||||
@ -748,7 +771,9 @@ static void disable_log_action(DCB *dcb, char *arg1) {
|
|||||||
logfile_id_t type;
|
logfile_id_t type;
|
||||||
int max_len = strlen("message");
|
int max_len = strlen("message");
|
||||||
|
|
||||||
if (strncmp(arg1, "trace", max_len) == 0) {
|
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||||
|
type = LOGFILE_DEBUG;
|
||||||
|
} else if (strncmp(arg1, "trace", max_len) == 0) {
|
||||||
type = LOGFILE_TRACE;
|
type = LOGFILE_TRACE;
|
||||||
} else if (strncmp(arg1, "error", max_len) == 0) {
|
} else if (strncmp(arg1, "error", max_len) == 0) {
|
||||||
type = LOGFILE_ERROR;
|
type = LOGFILE_ERROR;
|
||||||
|
@ -282,7 +282,7 @@ BACKEND *candidate = NULL;
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [newSession] new router session with session "
|
"%lu [newSession] new router session with session "
|
||||||
"%p, and inst %p.",
|
"%p, and inst %p.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -322,7 +322,7 @@ int i;
|
|||||||
for (i = 0; inst->servers[i]; i++) {
|
for (i = 0; inst->servers[i]; i++) {
|
||||||
if(inst->servers[i]) {
|
if(inst->servers[i]) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [newSession] Examine server in port %d with "
|
"%lu [newSession] Examine server in port %d with "
|
||||||
"%d connections. Status is %d, "
|
"%d connections. Status is %d, "
|
||||||
"inst->bitvalue is %d",
|
"inst->bitvalue is %d",
|
||||||
@ -383,7 +383,7 @@ int i;
|
|||||||
atomic_add(&candidate->current_connection_count, 1);
|
atomic_add(&candidate->current_connection_count, 1);
|
||||||
client_rses->backend = candidate;
|
client_rses->backend = candidate;
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [newSession] Selected server in port %d. "
|
"%lu [newSession] Selected server in port %d. "
|
||||||
"Connections : %d\n",
|
"Connections : %d\n",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
@ -465,7 +465,7 @@ static void freeSession(
|
|||||||
spinlock_release(&router->lock);
|
spinlock_release(&router->lock);
|
||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_DEBUG,
|
||||||
"%lu [freeSession] Unlinked router_client_session %p from "
|
"%lu [freeSession] Unlinked router_client_session %p from "
|
||||||
"router %p and from server on port %d. Connections : %d. ",
|
"router %p and from server on port %d. Connections : %d. ",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
|
@ -547,14 +547,16 @@ static int routeQuery(
|
|||||||
"%s.",
|
"%s.",
|
||||||
STRPACKETTYPE(packet_type),
|
STRPACKETTYPE(packet_type),
|
||||||
STRQTYPE(qtype),
|
STRQTYPE(qtype),
|
||||||
querystr,
|
(querystr == NULL ? "(empty)" : querystr),
|
||||||
(rses_is_closed ? "Router was closed" :
|
(rses_is_closed ? "Router was closed" :
|
||||||
"Router has no backend servers where to route to"));
|
"Router has no backend servers where to route to"));
|
||||||
|
|
||||||
goto return_ret;
|
goto return_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
skygw_log_write(LOGFILE_TRACE, "String\t\"%s\"", querystr);
|
skygw_log_write(LOGFILE_TRACE,
|
||||||
|
"String\t\"%s\"",
|
||||||
|
querystr == NULL ? "(empty)" : querystr);
|
||||||
skygw_log_write(LOGFILE_TRACE,
|
skygw_log_write(LOGFILE_TRACE,
|
||||||
"Packet type\t%s",
|
"Packet type\t%s",
|
||||||
STRPACKETTYPE(packet_type));
|
STRPACKETTYPE(packet_type));
|
||||||
@ -590,7 +592,7 @@ static int routeQuery(
|
|||||||
case QUERY_TYPE_SESSION_WRITE:
|
case QUERY_TYPE_SESSION_WRITE:
|
||||||
skygw_log_write(LOGFILE_TRACE,
|
skygw_log_write(LOGFILE_TRACE,
|
||||||
"%lu [routeQuery:rwsplit] Query type\t%s, "
|
"%lu [routeQuery:rwsplit] Query type\t%s, "
|
||||||
"routing to All servers.",
|
"routing to all servers.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
STRQTYPE(qtype));
|
STRQTYPE(qtype));
|
||||||
/**
|
/**
|
||||||
@ -865,8 +867,8 @@ static bool search_backend_servers(
|
|||||||
if (be != NULL) {
|
if (be != NULL) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_TRACE,
|
||||||
"%lu [search_backend_servers] Examine server %s:%d "
|
"%lu [search_backend_servers] Examine server "
|
||||||
"with %d connections. Status is %d, "
|
"%s:%d with %d connections. Status is %d, "
|
||||||
"router->bitvalue is %d",
|
"router->bitvalue is %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
be->backend_server->name,
|
be->backend_server->name,
|
||||||
@ -931,7 +933,8 @@ static bool search_backend_servers(
|
|||||||
succp = false;
|
succp = false;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Couldn't find suitable Slave from %d candidates.",
|
"Error : Couldn't find suitable Slave from %d "
|
||||||
|
"candidates.",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,7 +942,8 @@ static bool search_backend_servers(
|
|||||||
succp = false;
|
succp = false;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Couldn't find suitable Master from %d candidates.",
|
"Error : Couldn't find suitable Master from %d "
|
||||||
|
"candidates.",
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#define __USE_UNIX98 1
|
#define __USE_UNIX98 1
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -120,16 +121,19 @@ typedef enum skygw_chk_t {
|
|||||||
} skygw_chk_t;
|
} skygw_chk_t;
|
||||||
|
|
||||||
# define STRBOOL(b) ((b) ? "true" : "false")
|
# define STRBOOL(b) ((b) ? "true" : "false")
|
||||||
|
|
||||||
# define STRQTYPE(t) ((t) == QUERY_TYPE_WRITE ? "QUERY_TYPE_WRITE" : \
|
# define STRQTYPE(t) ((t) == QUERY_TYPE_WRITE ? "QUERY_TYPE_WRITE" : \
|
||||||
((t) == QUERY_TYPE_READ ? "QUERY_TYPE_READ" : \
|
((t) == QUERY_TYPE_READ ? "QUERY_TYPE_READ" : \
|
||||||
((t) == QUERY_TYPE_SESSION_WRITE ? "QUERY_TYPE_SESSION_WRITE" : \
|
((t) == QUERY_TYPE_SESSION_WRITE ? "QUERY_TYPE_SESSION_WRITE" : \
|
||||||
((t) == QUERY_TYPE_UNKNOWN ? "QUERY_TYPE_UNKNWON" : \
|
((t) == QUERY_TYPE_UNKNOWN ? "QUERY_TYPE_UNKNWON" : \
|
||||||
((t) == QUERY_TYPE_LOCAL_READ ? "QUERY_TYPE_LOCAL_READ" : \
|
((t) == QUERY_TYPE_LOCAL_READ ? "QUERY_TYPE_LOCAL_READ" : \
|
||||||
"Unknown query type")))))
|
"Unknown query type")))))
|
||||||
|
|
||||||
#define STRLOGID(i) ((i) == LOGFILE_TRACE ? "LOGFILE_TRACE" : \
|
#define STRLOGID(i) ((i) == LOGFILE_TRACE ? "LOGFILE_TRACE" : \
|
||||||
((i) == LOGFILE_MESSAGE ? "LOGFILE_MESSAGE" : \
|
((i) == LOGFILE_MESSAGE ? "LOGFILE_MESSAGE" : \
|
||||||
((i) == LOGFILE_ERROR ? "LOGFILE_ERROR" : \
|
((i) == LOGFILE_ERROR ? "LOGFILE_ERROR" : \
|
||||||
"Unknown logfile type")))
|
((i) == LOGFILE_DEBUG ? "LOGFILE_DEBUG" : \
|
||||||
|
"Unknown logfile type"))))
|
||||||
|
|
||||||
#define STRPACKETTYPE(p) ((p) == COM_INIT_DB ? "COM_INIT_DB" : \
|
#define STRPACKETTYPE(p) ((p) == COM_INIT_DB ? "COM_INIT_DB" : \
|
||||||
((p) == COM_CREATE_DB ? "COM_CREATE_DB" : \
|
((p) == COM_CREATE_DB ? "COM_CREATE_DB" : \
|
||||||
@ -285,11 +289,11 @@ typedef enum skygw_chk_t {
|
|||||||
ss_info_dassert((n->slnode_chk_top == CHK_NUM_SLIST_NODE && \
|
ss_info_dassert((n->slnode_chk_top == CHK_NUM_SLIST_NODE && \
|
||||||
n->slnode_chk_tail == CHK_NUM_SLIST_NODE), \
|
n->slnode_chk_tail == CHK_NUM_SLIST_NODE), \
|
||||||
"Single-linked list node under- or overflow"); \
|
"Single-linked list node under- or overflow"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHK_SLIST_CURSOR(c) { \
|
#define CHK_SLIST_CURSOR(c) { \
|
||||||
ss_info_dassert(c->slcursor_chk_top == CHK_NUM_SLIST_CURSOR && \
|
ss_info_dassert(c->slcursor_chk_top == CHK_NUM_SLIST_CURSOR && \
|
||||||
c->slcursor_chk_tail == CHK_NUM_SLIST_CURSOR, \
|
c->slcursor_chk_tail == CHK_NUM_SLIST_CURSOR, \
|
||||||
"List cursor under- or overflow"); \
|
"List cursor under- or overflow"); \
|
||||||
ss_info_dassert(c->slcursor_list != NULL, \
|
ss_info_dassert(c->slcursor_list != NULL, \
|
||||||
"List cursor doesn't have list"); \
|
"List cursor doesn't have list"); \
|
||||||
@ -297,34 +301,35 @@ typedef enum skygw_chk_t {
|
|||||||
(c->slcursor_pos == NULL && \
|
(c->slcursor_pos == NULL && \
|
||||||
c->slcursor_list->slist_head == NULL), \
|
c->slcursor_list->slist_head == NULL), \
|
||||||
"List cursor doesn't have position"); \
|
"List cursor doesn't have position"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHK_QUERY_TEST(q) { \
|
#define CHK_QUERY_TEST(q) { \
|
||||||
ss_info_dassert(q->qt_chk_top == CHK_NUM_QUERY_TEST && \
|
ss_info_dassert(q->qt_chk_top == CHK_NUM_QUERY_TEST && \
|
||||||
q->qt_chk_tail == CHK_NUM_QUERY_TEST, \
|
q->qt_chk_tail == CHK_NUM_QUERY_TEST, \
|
||||||
"Query test under- or overflow."); \
|
"Query test under- or overflow."); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHK_LOGFILE(lf) { \
|
#define CHK_LOGFILE(lf) { \
|
||||||
ss_info_dassert(lf->lf_chk_top == CHK_NUM_LOGFILE && \
|
ss_info_dassert(lf->lf_chk_top == CHK_NUM_LOGFILE && \
|
||||||
lf->lf_chk_tail == CHK_NUM_LOGFILE, \
|
lf->lf_chk_tail == CHK_NUM_LOGFILE, \
|
||||||
"Logfile struct under- or overflow"); \
|
"Logfile struct under- or overflow"); \
|
||||||
ss_info_dassert(lf->lf_logpath != NULL && \
|
ss_info_dassert(lf->lf_filepath != NULL && \
|
||||||
lf->lf_name_prefix != NULL && \
|
lf->lf_name_prefix != NULL && \
|
||||||
lf->lf_name_suffix != NULL && \
|
lf->lf_name_suffix != NULL && \
|
||||||
lf->lf_full_name != NULL, \
|
lf->lf_full_file_name != NULL, \
|
||||||
"NULL in name variable\n"); \
|
"NULL in name variable\n"); \
|
||||||
ss_info_dassert(lf->lf_id >= LOGFILE_FIRST && \
|
ss_info_dassert(lf->lf_id >= LOGFILE_FIRST && \
|
||||||
lf->lf_id <= LOGFILE_LAST, \
|
lf->lf_id <= LOGFILE_LAST, \
|
||||||
"Invalid logfile id\n"); \
|
"Invalid logfile id\n"); \
|
||||||
|
ss_debug( \
|
||||||
(lf->lf_chk_top != CHK_NUM_LOGFILE || \
|
(lf->lf_chk_top != CHK_NUM_LOGFILE || \
|
||||||
lf->lf_chk_tail != CHK_NUM_LOGFILE ? \
|
lf->lf_chk_tail != CHK_NUM_LOGFILE ? \
|
||||||
false : \
|
false : \
|
||||||
(lf->lf_logpath == NULL || \
|
(lf->lf_filepath == NULL || \
|
||||||
lf->lf_name_prefix == NULL || \
|
lf->lf_name_prefix == NULL || \
|
||||||
lf->lf_name_suffix == NULL || \
|
lf->lf_name_suffix == NULL || \
|
||||||
lf->lf_full_name == NULL ? false : true)); \
|
lf->lf_full_file_name == NULL ? false : true));) \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHK_FILEWRITER(fwr) { \
|
#define CHK_FILEWRITER(fwr) { \
|
||||||
ss_info_dassert(fwr->fwr_chk_top == CHK_NUM_FILEWRITER && \
|
ss_info_dassert(fwr->fwr_chk_top == CHK_NUM_FILEWRITER && \
|
||||||
|
@ -279,8 +279,9 @@ mlist_node_t* mlist_detach_nodes(
|
|||||||
* @return Address of mlist_t struct.
|
* @return Address of mlist_t struct.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @details Cursor must protect its reads with read lock, and after acquiring
|
* @details Cursor must protect its reads with read lock, and after
|
||||||
* read lock reader must check whether the list is deleted (mlist_deleted).
|
* acquiring read lock reader must check whether the list is deleted
|
||||||
|
* (mlist_deleted).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
mlist_t* mlist_init(
|
mlist_t* mlist_init(
|
||||||
@ -1240,8 +1241,10 @@ simple_mutex_t* simple_mutex_init(
|
|||||||
sm = (simple_mutex_t *)calloc(1, sizeof(simple_mutex_t));
|
sm = (simple_mutex_t *)calloc(1, sizeof(simple_mutex_t));
|
||||||
}
|
}
|
||||||
ss_dassert(sm != NULL);
|
ss_dassert(sm != NULL);
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
sm->sm_chk_top = CHK_NUM_SIMPLE_MUTEX;
|
sm->sm_chk_top = CHK_NUM_SIMPLE_MUTEX;
|
||||||
sm->sm_chk_tail = CHK_NUM_SIMPLE_MUTEX;
|
sm->sm_chk_tail = CHK_NUM_SIMPLE_MUTEX;
|
||||||
|
#endif
|
||||||
sm->sm_name = name;
|
sm->sm_name = name;
|
||||||
|
|
||||||
/** Create pthread mutex */
|
/** Create pthread mutex */
|
||||||
@ -1746,8 +1749,8 @@ return_succp:
|
|||||||
}
|
}
|
||||||
|
|
||||||
skygw_file_t* skygw_file_init(
|
skygw_file_t* skygw_file_init(
|
||||||
char* fname)
|
char* fname,
|
||||||
|
char* symlinkname)
|
||||||
{
|
{
|
||||||
skygw_file_t* file;
|
skygw_file_t* file;
|
||||||
|
|
||||||
@ -1780,16 +1783,46 @@ skygw_file_t* skygw_file_init(
|
|||||||
setvbuf(file->sf_file, NULL, _IONBF, 0);
|
setvbuf(file->sf_file, NULL, _IONBF, 0);
|
||||||
|
|
||||||
if (!file_write_header(file)) {
|
if (!file_write_header(file)) {
|
||||||
|
int eno = errno;
|
||||||
|
errno = 0;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"* Writing header of log file %s failed.\n",
|
"* Writing header of log file %s failed due %d, %s.\n",
|
||||||
file->sf_fname);
|
file->sf_fname,
|
||||||
perror("SkyGW file open\n");
|
eno,
|
||||||
|
strerror(eno));
|
||||||
free(file);
|
free(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
goto return_file;
|
goto return_file;
|
||||||
}
|
}
|
||||||
CHK_FILE(file);
|
CHK_FILE(file);
|
||||||
ss_dfprintf(stderr, "Opened %s\n", file->sf_fname);
|
ss_dfprintf(stderr, "Opened %s\n", file->sf_fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create symlink to newly created file if name was provided.
|
||||||
|
*/
|
||||||
|
if (symlinkname != NULL)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
unlink(symlinkname);
|
||||||
|
rc = symlink(fname, symlinkname);
|
||||||
|
|
||||||
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
int eno = errno;
|
||||||
|
errno = 0;
|
||||||
|
fprintf(stderr,
|
||||||
|
"failed to create symlink %s -> "
|
||||||
|
"%s due %d, %s. Exiting.",
|
||||||
|
fname,
|
||||||
|
symlinkname,
|
||||||
|
eno,
|
||||||
|
strerror(eno));
|
||||||
|
free(file);
|
||||||
|
file = NULL;
|
||||||
|
goto return_file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return_file:
|
return_file:
|
||||||
return file;
|
return file;
|
||||||
|
@ -145,7 +145,7 @@ EXTERN_C_BLOCK_END
|
|||||||
/** Skygw thread routines */
|
/** Skygw thread routines */
|
||||||
|
|
||||||
/** Skygw file routines */
|
/** Skygw file routines */
|
||||||
skygw_file_t* skygw_file_init(char* fname);
|
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
|
||||||
void skygw_file_done(skygw_file_t* file);
|
void skygw_file_done(skygw_file_t* file);
|
||||||
bool skygw_file_write(
|
bool skygw_file_write(
|
||||||
skygw_file_t* file,
|
skygw_file_t* file,
|
||||||
|
Reference in New Issue
Block a user