strerror_r update
strerror_r update
This commit is contained in:
@ -544,14 +544,13 @@ char task_name[BLRM_TASK_NAME_LEN+1] = "";
|
||||
int mkdir_rval;
|
||||
mkdir_rval = mkdir(inst->binlogdir, 0700);
|
||||
if (mkdir_rval == -1) {
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : Service %s, Failed to create binlog directory '%s': [%d] %s",
|
||||
service->name,
|
||||
inst->binlogdir,
|
||||
errno,
|
||||
err_msg);
|
||||
strerror_r(errno, err_msg, sizeof(err_msg)));
|
||||
|
||||
free(inst);
|
||||
return NULL;
|
||||
@ -1402,7 +1401,7 @@ errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_
|
||||
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance;
|
||||
int error;
|
||||
socklen_t len;
|
||||
char msg[BLRM_STRERROR_R_MSG_SIZE + 1 + 5] = "";
|
||||
char msg[STRERROR_BUFLEN + 1 + 5] = "";
|
||||
char *errmsg;
|
||||
unsigned long mysql_errno;
|
||||
|
||||
@ -1427,8 +1426,8 @@ unsigned long mysql_errno;
|
||||
len = sizeof(error);
|
||||
if (router->master && getsockopt(router->master->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0 && error != 0)
|
||||
{
|
||||
strerror_r(error, msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
strcat(msg, " ");
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
sprintf(msg, "%s ", strerror_r(error, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
strcpy(msg, "");
|
||||
@ -1939,14 +1938,13 @@ int mkdir_rval = 0;
|
||||
|
||||
if (mkdir_rval == -1)
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,
|
||||
"Error : Service %s, Failed to create directory '%s': [%d] %s",
|
||||
service->name,
|
||||
path,
|
||||
errno,
|
||||
err_msg);
|
||||
strerror_r(errno, err_msg, sizeof(err_msg)));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -125,13 +125,11 @@ struct dirent *dp;
|
||||
root_len = strlen(router->fileroot);
|
||||
if ((dirp = opendir(path)) == NULL)
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1]="";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE];
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Unable to read the binlog directory %s, %s.",
|
||||
router->service->name, router->binlogdir,
|
||||
err_msg)));
|
||||
strerror_r(errno, err_msg, sizeof(err_msg)))));
|
||||
return 0;
|
||||
}
|
||||
while ((dp = readdir(dirp)) != NULL)
|
||||
@ -227,12 +225,11 @@ int fd;
|
||||
}
|
||||
else
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Failed to create binlog file %s, %s.",
|
||||
router->service->name, path, err_msg)));
|
||||
router->service->name, path, strerror_r(errno, err_msg, sizeof(err_msg)))));
|
||||
return 0;
|
||||
}
|
||||
fsync(fd);
|
||||
@ -306,14 +303,13 @@ int n;
|
||||
if ((n = pwrite(router->binlog_fd, buf, 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);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"%s: Failed to write binlog record at %d of %s, %s. "
|
||||
"Truncating to previous record.",
|
||||
router->service->name, hdr->next_pos - hdr->event_size,
|
||||
router->binlog_name,
|
||||
err_msg)));
|
||||
strerror_r(errno, err_msg, sizeof(err_msg)))));
|
||||
/* Remove any partual event that was written */
|
||||
ftruncate(router->binlog_fd, hdr->next_pos - hdr->event_size);
|
||||
return 0;
|
||||
@ -461,11 +457,9 @@ struct stat statb;
|
||||
break;
|
||||
case -1:
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Failed to read binlog file '%s'; (%s), event at %lu",
|
||||
file->binlogname, err_msg, pos);
|
||||
file->binlogname, strerror_r(errno, err_msg, sizeof(err_msg)), pos);
|
||||
|
||||
if (errno == EBADF)
|
||||
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Bad file descriptor for binlog file '%s', refcount %d, descriptor %d, event at %lu",
|
||||
@ -531,11 +525,9 @@ struct stat statb;
|
||||
break;
|
||||
case -1:
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Failed to reread header in binlog file '%s'; (%s), event at %lu",
|
||||
file->binlogname, err_msg, pos);
|
||||
file->binlogname, strerror_r(errno, err_msg, sizeof(err_msg)), pos);
|
||||
|
||||
if (errno == EBADF)
|
||||
snprintf(errmsg, BINLOG_ERROR_MSG_LEN, "Bad file descriptor rereading header for binlog file '%s', "
|
||||
@ -588,12 +580,10 @@ struct stat statb;
|
||||
{
|
||||
if (n == -1)
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
|
||||
char err_msg[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, err_msg, hdr->event_size - BINLOG_EVENT_HDR_LEN);
|
||||
pos, file->binlogname, strerror_r(errno, err_msg, sizeof(err_msg)), hdr->event_size - BINLOG_EVENT_HDR_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1587,7 +1577,7 @@ int rc;
|
||||
char path[(PATH_MAX - 15) + 1] = "";
|
||||
char filename[(PATH_MAX - 4) + 1] = "";
|
||||
char tmp_file[PATH_MAX + 1] = "";
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
|
||||
strncpy(path, router->binlogdir, (PATH_MAX - 15));
|
||||
|
||||
@ -1600,14 +1590,12 @@ char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
/* open file for writing */
|
||||
config_file = fopen(tmp_file,"wb");
|
||||
if (config_file == NULL) {
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror_r(errno, err_msg, sizeof(err_msg)), errno);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(chmod(tmp_file, S_IRUSR | S_IWUSR) < 0) {
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror_r(errno, err_msg, sizeof(err_msg)), errno);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -1627,14 +1615,12 @@ char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
rc = rename(tmp_file, filename);
|
||||
|
||||
if (rc == -1) {
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror_r(errno, err_msg, sizeof(err_msg)), errno);
|
||||
return 3;
|
||||
}
|
||||
|
||||
if(chmod(filename, S_IRUSR | S_IWUSR) < 0) {
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", err_msg, errno);
|
||||
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror_r(errno, err_msg, sizeof(err_msg)), errno);
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -1946,13 +1946,12 @@ int event_limit;
|
||||
break;
|
||||
case -1:
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Error: Reading saved events: failed to read binlog "
|
||||
"file %s at position %d"
|
||||
" (%s).", router->binlog_name,
|
||||
pos, err_msg)));
|
||||
pos, strerror_r(errno, err_msg, sizeof(err_msg)))));
|
||||
|
||||
if (errno == EBADF)
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
@ -2010,13 +2009,12 @@ int event_limit;
|
||||
{
|
||||
if (n == -1)
|
||||
{
|
||||
char err_msg[BLRM_STRERROR_R_MSG_SIZE+1] = "";
|
||||
strerror_r(errno, err_msg, BLRM_STRERROR_R_MSG_SIZE);
|
||||
char err_msg[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Error: Reading saved events: the event at %ld in %s. "
|
||||
"%s, expected %d bytes.",
|
||||
pos, router->binlog_name,
|
||||
err_msg, hdr->event_size - 19)));
|
||||
strerror_r(errno, err_msg, sizeof(err_msg)), hdr->event_size - 19)));
|
||||
} else {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Error: Reading saved events: short read when reading "
|
||||
|
@ -760,9 +760,8 @@ extern char *strcasestr();
|
||||
removed_cfg = unlink(path);
|
||||
|
||||
if (removed_cfg == -1) {
|
||||
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);
|
||||
char err_msg[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);
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, "%s: %s", router->service->name, error_string)));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user