Merge branch 'develop' into MXS-1075

This commit is contained in:
MassimilianoPinto
2017-03-09 15:08:04 +01:00
55 changed files with 809 additions and 668 deletions

View File

@ -699,12 +699,11 @@ createInstance(SERVICE *service, char **options)
mkdir_rval = mkdir(inst->binlogdir, 0700);
if (mkdir_rval == -1)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("Service %s, Failed to create binlog directory '%s': [%d] %s",
service->name,
inst->binlogdir,
errno,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
free_instance(inst);
return NULL;
@ -1840,8 +1839,7 @@ errorReply(MXS_ROUTER *instance,
getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 &&
error != 0)
{
char errbuf[MXS_STRERROR_BUFLEN];
sprintf(msg, "%s ", strerror_r(error, errbuf, sizeof(errbuf)));
sprintf(msg, "%s ", mxs_strerror(error));
}
else
{
@ -2678,10 +2676,9 @@ int blr_parse_key_file(ROUTER_INSTANCE *router)
if (!file)
{
char errbuf[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to open KEY file '%s': %s",
router->encryption.key_management_filename,
strerror_r(errno, errbuf, sizeof(errbuf)));
mxs_strerror(errno));
return -1;
}

View File

@ -308,10 +308,9 @@ blr_file_init(ROUTER_INSTANCE *router)
root_len = strlen(router->fileroot);
if ((dirp = opendir(path)) == NULL)
{
char err_msg[BLRM_STRERROR_R_MSG_SIZE];
MXS_ERROR("%s: Unable to read the binlog directory %s, %s.",
router->service->name, router->binlogdir,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
return 0;
}
while ((dp = readdir(dirp)) != NULL)
@ -434,20 +433,20 @@ blr_file_create(ROUTER_INSTANCE *router, char *file)
else
{
MXS_ERROR("%s: Failed to write magic string to created binlog file %s, %s.",
router->service->name, path, strerror_r(errno, err_msg, sizeof(err_msg)));
router->service->name, path, mxs_strerror(errno));
close(fd);
if (!unlink(path))
{
MXS_ERROR("%s: Failed to delete file %s, %s.",
router->service->name, path, strerror_r(errno, err_msg, sizeof(err_msg)));
router->service->name, path, mxs_strerror(errno));
}
}
}
else
{
MXS_ERROR("%s: Failed to create binlog file %s, %s.",
router->service->name, path, strerror_r(errno, err_msg, sizeof(err_msg)));
router->service->name, path, mxs_strerror(errno));
}
return created;
@ -578,19 +577,18 @@ blr_write_binlog_record(ROUTER_INSTANCE *router, REP_HEADER *hdr, uint32_t size,
/* Check write operation result*/
if (n != size)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
"Truncating to previous record.",
router->service->name, router->binlog_position,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
/* Remove any partial event that was written */
if (ftruncate(router->binlog_fd, router->binlog_position))
{
MXS_ERROR("%s: Failed to truncate binlog record at %lu of %s, %s. ",
router->service->name, router->binlog_position,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
}
return 0;
}
@ -837,9 +835,8 @@ blr_read_binlog(ROUTER_INSTANCE *router,
break;
case -1:
{
char err_msg[MXS_STRERROR_BUFLEN];
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Failed to read binlog file '%s'; (%s), event at %lu",
file->binlogname, strerror_r(errno, err_msg, sizeof(err_msg)), pos);
file->binlogname, mxs_strerror(errno), pos);
if (errno == EBADF)
{
@ -900,10 +897,9 @@ blr_read_binlog(ROUTER_INSTANCE *router,
break;
case -1:
{
char err_msg[MXS_STRERROR_BUFLEN];
snprintf(errmsg, BINLOG_ERROR_MSG_LEN,
"Failed to reread header in binlog file '%s'; (%s), event at %lu",
file->binlogname, strerror_r(errno, err_msg, sizeof(err_msg)), pos);
file->binlogname, mxs_strerror(errno), pos);
if (errno == EBADF)
{
@ -984,13 +980,12 @@ blr_read_binlog(ROUTER_INSTANCE *router,
if (n == -1)
{
char err_msg[MXS_STRERROR_BUFLEN];
snprintf(errmsg, BINLOG_ERROR_MSG_LEN,
"Error reading the binlog event at %lu in binlog file '%s';"
"(%s), expected %d bytes.",
pos,
file->binlogname,
strerror_r(errno, err_msg, sizeof(err_msg)),
mxs_strerror(errno),
hdr->event_size - BINLOG_EVENT_HDR_LEN);
}
else
@ -1200,9 +1195,8 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
}
if (write(fd, GWBUF_DATA(buf), GWBUF_LENGTH(buf)) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to write cached response: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
errno, mxs_strerror(errno));
}
close(fd);
@ -1258,9 +1252,8 @@ blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
}
if (read(fd, GWBUF_DATA(buf), statb.st_size) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to read cached response: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
errno, mxs_strerror(errno));
}
close(fd);
return buf;
@ -1439,10 +1432,9 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
break;
case -1:
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to read binlog file %s at position %llu"
" (%s).", router->binlog_name, pos,
strerror_r(errno, err, sizeof(err)));
mxs_strerror(errno));
if (errno == EBADF)
{
@ -1658,11 +1650,10 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
{
if (n == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Error reading the event at %llu in %s. "
"%s, expected %d bytes.",
pos, router->binlog_name,
strerror_r(errno, err, sizeof(err)),
mxs_strerror(errno),
hdr.event_size - BINLOG_EVENT_HDR_LEN);
}
else
@ -2467,7 +2458,6 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
char filename[len + sizeof('/') + sizeof(MASTER_INI)]; // sizeof includes NULL
char tmp_file[len + sizeof('/') + sizeof(MASTER_INI) + sizeof('.') + sizeof(TMP)];
char err_msg[MXS_STRERROR_BUFLEN];
char *ssl_ca;
char *ssl_cert;
char *ssl_key;
@ -2481,7 +2471,7 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
if (config_file == NULL)
{
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u",
strerror_r(errno, err_msg, sizeof(err_msg)), errno);
mxs_strerror(errno), errno);
return 2;
}
@ -2489,7 +2479,7 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
{
fclose(config_file);
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u",
strerror_r(errno, err_msg, sizeof(err_msg)), errno);
mxs_strerror(errno), errno);
return 2;
}
@ -2541,14 +2531,14 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
if (rc == -1)
{
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u",
strerror_r(errno, err_msg, sizeof(err_msg)), errno);
mxs_strerror(errno), errno);
return 3;
}
if (chmod(filename, S_IRUSR | S_IWUSR) < 0)
{
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u",
strerror_r(errno, err_msg, sizeof(err_msg)), errno);
mxs_strerror(errno), errno);
return 3;
}
@ -2748,12 +2738,11 @@ blr_write_special_event(ROUTER_INSTANCE *router, uint32_t file_offset, uint32_t
/* Write the event */
if ((n = pwrite(router->binlog_fd, new_event, event_size, router->last_written)) != event_size)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("%s: Failed to write %s special binlog record at %lu of %s, %s. "
"Truncating to previous record.",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
/* Remove any partial event that was written */
if (ftruncate(router->binlog_fd, router->binlog_position))
@ -2761,7 +2750,7 @@ blr_write_special_event(ROUTER_INSTANCE *router, uint32_t file_offset, uint32_t
MXS_ERROR("%s: Failed to truncate %s special binlog record at %lu of %s, %s. ",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
}
MXS_FREE(new_event);
return 0;

View File

@ -2038,11 +2038,10 @@ GWBUF
break;
case -1:
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("Reading saved events: failed to read binlog "
"file %s at position %llu"
" (%s).", router->binlog_name,
pos, strerror_r(errno, err_msg, sizeof(err_msg)));
pos, mxs_strerror(errno));
if (errno == EBADF)
{
@ -2098,11 +2097,10 @@ GWBUF
{
if (n == -1)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("Reading saved events: the event at %llu in %s. "
"%s, expected %d bytes.",
pos, router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)), hdr->event_size - 19);
mxs_strerror(errno), hdr->event_size - 19);
}
else
{
@ -2350,12 +2348,11 @@ blr_write_data_into_binlog(ROUTER_INSTANCE *router, uint32_t data_len, uint8_t *
if ((n = pwrite(router->binlog_fd, buf, data_len,
router->last_written)) != data_len)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
"Truncating to previous record.",
router->service->name, router->binlog_position,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
/* Remove any partial event that was written */
if (ftruncate(router->binlog_fd, router->binlog_position))
@ -2363,7 +2360,7 @@ blr_write_data_into_binlog(ROUTER_INSTANCE *router, uint32_t data_len, uint8_t *
MXS_ERROR("%s: Failed to truncate binlog record at %lu of %s, %s. ",
router->service->name, router->last_written,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
mxs_strerror(errno));
}
return 0;
}

View File

@ -936,10 +936,9 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
if (removed_cfg == -1)
{
char err_msg[MXS_STRERROR_BUFLEN];
snprintf(error_string, BINLOG_ERROR_MSG_LEN,
"Error removing %s, %s, errno %u", path,
strerror_r(errno, err_msg, sizeof(err_msg)), errno);
mxs_strerror(errno), errno);
MXS_ERROR("%s: %s", router->service->name, error_string);
}
@ -3782,9 +3781,8 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
/* Truncate previous binlog file to last_safe pos */
if (truncate(file, router->last_safe_pos) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to truncate file: %d, %s",
errno, strerror_r(errno, err, sizeof(err)));
errno, mxs_strerror(errno));
}
/* Log it */