Added strerror_r and new constants

Added strerror_r and new constants
This commit is contained in:
MassimilianoPinto
2015-08-24 15:02:22 +02:00
parent 599e2fdc6c
commit 3fe0c074c5
5 changed files with 110 additions and 58 deletions

View File

@ -164,6 +164,18 @@
/* string len for COM_STATISTICS output */ /* string len for COM_STATISTICS output */
#define BLRM_COM_STATISTICS_SIZE 1000 #define BLRM_COM_STATISTICS_SIZE 1000
/* string len for strerror_r message */
#define BLRM_STRERROR_R_MSG_SIZE 128
/* string len for task message name */
#define BLRM_TASK_NAME_LEN 80
/* string len for temp binlog filename */
#define BLRM_BINLOG_NAME_STR_LEN 80
/* string len for temp binlog filename */
#define BLRM_SET_HEARTBEAT_QUERY_LEN 80
/** /**
* Some useful macros for examining the MySQL Response packets * Some useful macros for examining the MySQL Response packets
*/ */

View File

@ -45,6 +45,7 @@
* master_uuid, master_hostname, master_version * master_uuid, master_hostname, master_version
* If set those values are sent to slaves instead of * If set those values are sent to slaves instead of
* saved master responses * saved master responses
* 23/08/2015 Massimiliano Pinto Added strerror_r
* *
* @endverbatim * @endverbatim
*/ */
@ -192,13 +193,14 @@ static ROUTER *
createInstance(SERVICE *service, char **options) createInstance(SERVICE *service, char **options)
{ {
ROUTER_INSTANCE *inst; ROUTER_INSTANCE *inst;
char *value, *name; char *value;
int i; int i;
unsigned char *defuuid; unsigned char *defuuid;
char path[PATH_MAX+1] = ""; char path[PATH_MAX+1] = "";
char filename[PATH_MAX+1] = ""; char filename[PATH_MAX+1] = "";
int master_info = 0; int master_info = 0;
int rc = 0; int rc = 0;
char task_name[BLRM_TASK_NAME_LEN+1] = "";
if(service->credentials.name == NULL || if(service->credentials.name == NULL ||
service->credentials.authdata == NULL) service->credentials.authdata == NULL)
@ -491,12 +493,14 @@ int rc = 0;
int mkdir_rval; int mkdir_rval;
mkdir_rval = mkdir(inst->binlogdir, 0700); mkdir_rval = mkdir(inst->binlogdir, 0700);
if (mkdir_rval == -1) { if (mkdir_rval == -1) {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
skygw_log_write_flush(LOGFILE_ERROR, skygw_log_write_flush(LOGFILE_ERROR,
"Error : Service %s, Failed to create binlog directory '%s': [%d] %s", "Error : Service %s, Failed to create binlog directory '%s': [%d] %s",
service->name, service->name,
inst->binlogdir, inst->binlogdir,
errno, errno,
strerror(errno)); err_msg);
free(inst); free(inst);
return NULL; return NULL;
@ -634,12 +638,11 @@ int rc = 0;
*/ */
blr_init_cache(inst); blr_init_cache(inst);
if ((name = (char *)malloc(80)) != NULL) /*
{ * Add tasks for statistic computation
sprintf(name, "%s stats", service->name); */
hktask_add(name, stats_func, inst, BLR_STATS_FREQ); snprintf(task_name, BLRM_TASK_NAME_LEN, "%s stats", service->name);
free(name); hktask_add(task_name, stats_func, inst, BLR_STATS_FREQ);
}
/* Log whether the transaction safety option value is on*/ /* Log whether the transaction safety option value is on*/
if (inst->trx_safe) { if (inst->trx_safe) {
@ -1311,9 +1314,10 @@ errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_
{ {
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance; ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance;
int error; int error;
socklen_t len; socklen_t len;
char msg[85], *errmsg; char msg[BLRM_STRERROR_R_MSG_SIZE + 1 + 5] = "";
unsigned long mysql_errno; char *errmsg;
unsigned long mysql_errno;
if (action == ERRACT_RESET) if (action == ERRACT_RESET)
{ {
@ -1336,7 +1340,7 @@ unsigned long mysql_errno;
len = sizeof(error); len = sizeof(error);
if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0) if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0)
{ {
strerror_r(error, msg, 80); strerror_r(error, msg, BLRM_STRERROR_R_MSG_SIZE);
strcat(msg, " "); strcat(msg, " ");
} }
else else
@ -1840,12 +1844,14 @@ int mkdir_rval;
if (mkdir_rval == -1) if (mkdir_rval == -1)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
skygw_log_write(LOGFILE_ERROR, skygw_log_write(LOGFILE_ERROR,
"Error : Service %s, Failed to create directory '%s': [%d] %s", "Error : Service %s, Failed to create directory '%s': [%d] %s",
service->name, service->name,
path, path,
errno, errno,
strerror(errno)); err_msg);
return -1; return -1;
} }

View File

@ -32,6 +32,7 @@
* 29/06/2015 Massimiliano Pinto Addition of blr_file_write_master_config() * 29/06/2015 Massimiliano Pinto Addition of blr_file_write_master_config()
* Cache directory is now 'cache' under router->binlogdir * Cache directory is now 'cache' under router->binlogdir
* 05/08/2015 Massimiliano Pinto Initial implementation of transaction safety * 05/08/2015 Massimiliano Pinto Initial implementation of transaction safety
* 24/08/2015 Massimiliano Pinto Added strerror_r
* *
* @endverbatim * @endverbatim
*/ */
@ -117,10 +118,13 @@ struct dirent *dp;
root_len = strlen(router->fileroot); root_len = strlen(router->fileroot);
if ((dirp = opendir(path)) == NULL) if ((dirp = opendir(path)) == NULL)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1]="";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"%s: Unable to read the binlog directory %s, %s.", "%s: Unable to read the binlog directory %s, %s.",
router->service->name, router->binlogdir, router->service->name, router->binlogdir,
strerror(errno)))); err_msg)));
return 0; return 0;
} }
while ((dp = readdir(dirp)) != NULL) while ((dp = readdir(dirp)) != NULL)
@ -202,7 +206,7 @@ unsigned char magic[] = BINLOG_MAGIC;
static int static int
blr_file_create(ROUTER_INSTANCE *router, char *file) blr_file_create(ROUTER_INSTANCE *router, char *file)
{ {
char path[PATH_MAX + 1]; char path[PATH_MAX + 1] = "";
int fd; int fd;
strcpy(path, router->binlogdir); strcpy(path, router->binlogdir);
@ -215,9 +219,12 @@ int fd;
} }
else else
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"%s: Failed to create binlog file %s, %s.", "%s: Failed to create binlog file %s, %s.",
router->service->name, path, strerror(errno)))); router->service->name, path, err_msg)));
return 0; return 0;
} }
fsync(fd); fsync(fd);
@ -291,12 +298,14 @@ int n;
if ((n = pwrite(router->binlog_fd, buf, hdr->event_size, if ((n = pwrite(router->binlog_fd, buf, hdr->event_size,
hdr->next_pos - hdr->event_size)) != hdr->event_size) hdr->next_pos - hdr->event_size)) != hdr->event_size)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"%s: Failed to write binlog record at %d of %s, %s. " "%s: Failed to write binlog record at %d of %s, %s. "
"Truncating to previous record.", "Truncating to previous record.",
router->service->name, hdr->next_pos - hdr->event_size, router->service->name, hdr->next_pos - hdr->event_size,
router->binlog_name, router->binlog_name,
strerror(errno)))); err_msg)));
/* Remove any partual event that was written */ /* Remove any partual event that was written */
ftruncate(router->binlog_fd, hdr->next_pos - hdr->event_size); ftruncate(router->binlog_fd, hdr->next_pos - hdr->event_size);
return 0; return 0;
@ -429,19 +438,23 @@ struct stat statb;
case 0: case 0:
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
"Reached end of binlog file at %d.", "Reached end of binlog file at %d.",
pos))); pos)));
break; break;
case -1: case -1:
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Failed to read binlog file %s at position %d" "Failed to read binlog file %s at position %d"
" (%s).", file->binlogname, " (%s).", file->binlogname,
pos, strerror(errno)))); pos, err_msg)));
if (errno == EBADF) if (errno == EBADF)
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Bad file descriptor in read binlog for file %s" "Bad file descriptor in read binlog for file %s"
", reference count is %d, descriptor %d.", ", reference count is %d, descriptor %d.",
file->binlogname, file->refcnt, file->fd))); file->binlogname, file->refcnt, file->fd)));
break; break;
}
default: default:
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Short read when reading the header. " "Short read when reading the header. "
@ -495,19 +508,24 @@ struct stat statb;
case 0: case 0:
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
"Reached end of binlog file at %d.", "Reached end of binlog file at %d.",
pos))); pos)));
break; break;
case -1: case -1:
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Failed to read binlog file %s at position %d" "Failed to read binlog file %s at position %d"
" (%s).", file->binlogname, " (%s).", file->binlogname,
pos, strerror(errno)))); pos, err_msg)));
if (errno == EBADF) if (errno == EBADF)
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Bad file descriptor in read binlog for file %s" "Bad file descriptor in read binlog for file %s"
", reference count is %d, descriptor %d.", ", reference count is %d, descriptor %d.",
file->binlogname, file->refcnt, file->fd))); file->binlogname, file->refcnt, file->fd)));
break; break;
}
default: default:
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Short read when reading the header. " "Short read when reading the header. "
@ -554,11 +572,13 @@ struct stat statb;
{ {
if (n == -1) if (n == -1)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Error reading the event at %ld in %s. " "Error reading the event at %ld in %s. "
"%s, expected %d bytes.", "%s, expected %d bytes.",
pos, file->binlogname, pos, file->binlogname,
strerror(errno), hdr->event_size - 19))); err_msg, hdr->event_size - 19)));
} }
else else
{ {
@ -747,7 +767,7 @@ GWBUF *buf;
int int
blr_file_next_exists(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave) blr_file_next_exists(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
{ {
char *sptr, buf[80], bigbuf[PATH_MAX + 1]; char *sptr, buf[BLRM_BINLOG_NAME_STR_LEN], bigbuf[PATH_MAX + 1];
int filenum; int filenum;
if ((sptr = strrchr(slave->binlogfile, '.')) == NULL) if ((sptr = strrchr(slave->binlogfile, '.')) == NULL)
@ -795,7 +815,7 @@ blr_cache_read_master_data(ROUTER_INSTANCE *router)
int int
blr_file_get_next_binlogname(ROUTER_INSTANCE *router) blr_file_get_next_binlogname(ROUTER_INSTANCE *router)
{ {
char *sptr, buf[80], bigbuf[4096]; char *sptr;
int filenum; int filenum;
if ((sptr = strrchr(router->binlog_name, '.')) == NULL) if ((sptr = strrchr(router->binlog_name, '.')) == NULL)
@ -850,6 +870,7 @@ int rc;
char path[(PATH_MAX - 15) + 1] = ""; char path[(PATH_MAX - 15) + 1] = "";
char filename[(PATH_MAX - 4) + 1] = ""; char filename[(PATH_MAX - 4) + 1] = "";
char tmp_file[PATH_MAX + 1] = ""; char tmp_file[PATH_MAX + 1] = "";
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strncpy(path, router->binlogdir, (PATH_MAX - 15)); strncpy(path, router->binlogdir, (PATH_MAX - 15));
@ -862,12 +883,14 @@ char tmp_file[PATH_MAX + 1] = "";
/* open file for writing */ /* open file for writing */
config_file = fopen(tmp_file,"wb"); config_file = fopen(tmp_file,"wb");
if (config_file == NULL) { if (config_file == NULL) {
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror(errno), errno); strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
return 2; return 2;
} }
if(chmod(tmp_file, S_IRUSR | S_IWUSR) < 0) { if(chmod(tmp_file, S_IRUSR | S_IWUSR) < 0) {
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror(errno), errno); strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
return 2; return 2;
} }
@ -887,12 +910,14 @@ char tmp_file[PATH_MAX + 1] = "";
rc = rename(tmp_file, filename); rc = rename(tmp_file, filename);
if (rc == -1) { if (rc == -1) {
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror(errno), errno); strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
return 3; return 3;
} }
if(chmod(filename, S_IRUSR | S_IWUSR) < 0) { if(chmod(filename, S_IRUSR | S_IWUSR) < 0) {
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror(errno), errno); strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
return 3; return 3;
} }
@ -966,16 +991,21 @@ int event_error = 0;
break; break;
case -1: case -1:
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"*** ERROR: Failed to read binlog file %s at position %llu" "*** ERROR: Failed to read binlog file %s at position %llu"
" (%s).", router->binlog_name, " (%s).", router->binlog_name,
pos, strerror(errno)))); pos, err_msg)));
if (errno == EBADF) if (errno == EBADF)
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"*** ERROR: Bad file descriptor in read binlog for file %s" "*** ERROR: Bad file descriptor in read binlog for file %s"
", descriptor %d.", ", descriptor %d.",
router->binlog_name, router->binlog_fd))); router->binlog_name, router->binlog_fd)));
break; break;
}
default: default:
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"*** ERROR: Short read when reading the header. " "*** ERROR: Short read when reading the header. "
@ -1134,11 +1164,13 @@ int event_error = 0;
{ {
if (n == -1) if (n == -1)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error reading the event at %llu in %s. " "Error reading the event at %llu in %s. "
"%s, expected %d bytes.", "%s, expected %d bytes.",
pos, router->binlog_name, pos, router->binlog_name,
strerror(errno), hdr.event_size - 19))); err_msg, hdr.event_size - 19)));
} }
else else
{ {

View File

@ -41,6 +41,7 @@
* Server error code and msg are reported via SHOW SLAVE STATUS * Server error code and msg are reported via SHOW SLAVE STATUS
* 03/08/2015 Massimiliano Pinto Initial implementation of transaction safety * 03/08/2015 Massimiliano Pinto Initial implementation of transaction safety
* 13/08/2015 Massimiliano Pinto Addition of heartbeat check * 13/08/2015 Massimiliano Pinto Addition of heartbeat check
* 23/08/2015 Massimiliano Pinto Added strerror_r
* *
* @endverbatim * @endverbatim
*/ */
@ -325,6 +326,7 @@ void
blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf) blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
{ {
char query[128]; char query[128];
char task_name[BLRM_TASK_NAME_LEN + 1] = "";
atomic_add(&router->handling_threads, 1); atomic_add(&router->handling_threads, 1);
ss_dassert(router->handling_threads == 1); ss_dassert(router->handling_threads == 1);
@ -447,7 +449,7 @@ char query[128];
} }
{ {
char str[80]; char str[BLRM_SET_HEARTBEAT_QUERY_LEN];
sprintf(str, "SET @master_heartbeat_period = %lu000000000", router->heartbeat); sprintf(str, "SET @master_heartbeat_period = %lu000000000", router->heartbeat);
buf = blr_make_query(str); buf = blr_make_query(str);
} }
@ -645,22 +647,18 @@ char query[128];
router->service->dbref->server->port))); router->service->dbref->server->port)));
break; break;
case BLRM_BINLOGDUMP: case BLRM_BINLOGDUMP:
{ /**
char *name; * Main body, we have received a binlog record from the master
*/
// Main body, we have received a binlog record from the master
blr_handle_binlog_record(router, buf); blr_handle_binlog_record(router, buf);
// set heartbeat check task /**
if ((name = (char *)malloc(80)) != NULL) * Set heartbeat check task
{ */
sprintf(name, "%s heartbeat", router->service->name); snprintf(task_name, BLRM_TASK_NAME_LEN, "%s heartbeat", router->service->name);
hktask_add(name, blr_check_last_master_event, router, router->heartbeat); hktask_add(task_name, blr_check_last_master_event, router, router->heartbeat);
free(name);
}
break; break;
}
} }
if (router->reconnect_pending) if (router->reconnect_pending)
@ -1801,11 +1799,14 @@ int n;
"Reading saved events: reached end of binlog file at %d.", pos))); "Reading saved events: reached end of binlog file at %d.", pos)));
break; break;
case -1: case -1:
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Error: Reading saved events: failed to read binlog " "Error: Reading saved events: failed to read binlog "
"file %s at position %d" "file %s at position %d"
" (%s).", router->binlog_name, " (%s).", router->binlog_name,
pos, strerror(errno)))); pos, err_msg)));
if (errno == EBADF) if (errno == EBADF)
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
@ -1813,6 +1814,7 @@ int n;
", descriptor %d.", ", descriptor %d.",
router->binlog_name, router->binlog_fd))); router->binlog_name, router->binlog_fd)));
break; break;
}
default: default:
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Error: Reading saved events: short read when reading the header. " "Error: Reading saved events: short read when reading the header. "
@ -1861,11 +1863,13 @@ int n;
{ {
if (n == -1) if (n == -1)
{ {
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Error: Reading saved events: the event at %ld in %s. " "Error: Reading saved events: the event at %ld in %s. "
"%s, expected %d bytes.", "%s, expected %d bytes.",
pos, router->binlog_name, pos, router->binlog_name,
strerror(errno), hdr->event_size - 19))); err_msg, hdr->event_size - 19)));
} else { } else {
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR, LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
"Error: Reading saved events: short read when reading " "Error: Reading saved events: short read when reading "
@ -1956,7 +1960,7 @@ blr_check_last_master_event(void *inst) {
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)inst; ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)inst;
int master_check = 1; int master_check = 1;
int master_state = BLRM_UNCONNECTED; int master_state = BLRM_UNCONNECTED;
char *name = NULL; char task_name[BLRM_TASK_NAME_LEN + 1] = "";
spinlock_acquire(&router->lock); spinlock_acquire(&router->lock);
@ -1980,13 +1984,9 @@ char *name = NULL;
* when master state is back to BLRM_BINLOGDUMP * when master state is back to BLRM_BINLOGDUMP
* by blr_master_response() * by blr_master_response()
*/ */
if ((name = (char *)malloc(80)) != NULL) { snprintf(task_name, BLRM_TASK_NAME_LEN, "%s heartbeat", router->service->name);
sprintf(name, "%s heartbeat", router->service->name);
hktask_remove(name); hktask_remove(task_name);
free(name);
}
} }
} }

View File

@ -636,7 +636,9 @@ extern char *strcasestr();
removed_cfg = unlink(path); removed_cfg = unlink(path);
if (removed_cfg == -1) { if (removed_cfg == -1) {
snprintf(error_string, BINLOG_ERROR_MSG_LEN, "Error removing %s, %s, errno %u", path, strerror(errno), errno); char err_msg[BLRM_STRERROR_R_MSG_SIZE+1]="";
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
snprintf(error_string, BINLOG_ERROR_MSG_LEN, "Error removing %s, %s, errno %u", path, err_msg, errno);
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string))); LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string)));
} }
@ -1026,8 +1028,8 @@ static int
blr_slave_send_maxscale_variables(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave) blr_slave_send_maxscale_variables(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
{ {
GWBUF *pkt; GWBUF *pkt;
char name[80]; char name[40];
char version[40]; char version[80];
uint8_t *ptr; uint8_t *ptr;
int len, vers_len, seqno = 2; int len, vers_len, seqno = 2;