LOGIF and skygw_write_log removed from server/core/*.c

LOGIF and skygw_write_log removed from server/core/*.c and
replaced with calls to MXS_(ERROR|WARNING|NOTICE|INFO|DEBUG).
This is a mechanism change, no updating of the actual message
has been performed.

Currently this causes a very small performance hit, since the
check whether the priority is enabled or not is performed in
the function that is called and not before the function is called.
Once all LOGIFs and skygw_write_logs have been replaced, the
behaviour will be altered back to what it was.
This commit is contained in:
Johan Wikman 2015-11-15 19:37:15 +02:00
parent 1f15843d61
commit 44df53d846
19 changed files with 1367 additions and 1992 deletions

View File

@ -159,19 +159,13 @@ char fname[1024], *home, *cpasswd;
fname[1023] = '\0';
if (users == NULL)
{
LOGIF(LM,
(skygw_log_write(LOGFILE_MESSAGE,
"Create initial password file.")));
MXS_NOTICE("Create initial password file.");
if ((users = users_alloc()) == NULL)
return ADMIN_ERR_NOMEM;
if ((fp = fopen(fname, "w")) == NULL)
{
LOGIF(LE,
(skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to create password file %s.",
fname)));
MXS_ERROR("Unable to create password file %s.", fname);
return ADMIN_ERR_PWDFILEOPEN;
}
fclose(fp);
@ -184,10 +178,7 @@ char fname[1024], *home, *cpasswd;
users_add(users, uname, cpasswd);
if ((fp = fopen(fname, "a")) == NULL)
{
LOGIF(LE,
(skygw_log_write_flush(LOGFILE_ERROR,
"Error : Unable to append to password file %s.",
fname)));
MXS_ERROR("Unable to append to password file %s.", fname);
return ADMIN_ERR_FILEAPPEND;
}
fprintf(fp, "%s:%s\n", uname, cpasswd);
@ -219,19 +210,14 @@ char* admin_remove_user(
int n_deleted;
if (!admin_search_user(uname)) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Couldn't find user %s. Removing user failed",
uname)));
return ADMIN_ERR_USERNOTFOUND;
MXS_ERROR("Couldn't find user %s. Removing user failed.", uname);
return ADMIN_ERR_USERNOTFOUND;
}
if (admin_verify(uname, passwd) == 0) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Authentication failed, wrong user/password "
"combination. Removing user failed.")));
return ADMIN_ERR_AUTHENTICATION;
MXS_ERROR("Authentication failed, wrong user/password "
"combination. Removing user failed.");
return ADMIN_ERR_AUTHENTICATION;
}
@ -239,11 +225,9 @@ char* admin_remove_user(
n_deleted = users_delete(users, uname);
if (n_deleted == 0) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Deleting the only user is forbidden. Add new "
"user before deleting the one.")));
return ADMIN_ERR_DELLASTUSER;
MXS_ERROR("Deleting the only user is forbidden. Add new "
"user before deleting the one.");
return ADMIN_ERR_DELLASTUSER;
}
/**
* Open passwd file and remove user from the file.
@ -258,13 +242,11 @@ char* admin_remove_user(
if ((fp = fopen(fname, "r")) == NULL)
{
int err = errno;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to open password file %s : errno %d.\n"
"Removing user from file failed; it must be done "
"manually.",
fname,
err)));
MXS_ERROR("Unable to open password file %s : errno %d.\n"
"Removing user from file failed; it must be done "
"manually.",
fname,
err);
return ADMIN_ERR_PWDFILEOPEN;
}
/**
@ -273,13 +255,11 @@ char* admin_remove_user(
if ((fp_tmp = fopen(fname_tmp, "w")) == NULL)
{
int err = errno;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to open tmp file %s : errno %d.\n"
"Removing user from passwd file failed; it must be done "
"manually.",
fname_tmp,
err)));
MXS_ERROR("Unable to open tmp file %s : errno %d.\n"
"Removing user from passwd file failed; it must be done "
"manually.",
fname_tmp,
err);
fclose(fp);
return ADMIN_ERR_TMPFILEOPEN;
}
@ -289,13 +269,11 @@ char* admin_remove_user(
*/
if (fgetpos(fp, &rpos) != 0) {
int err = errno;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to process passwd file %s : errno %d.\n"
"Removing user from file failed, and must be done "
"manually.",
fname,
err)));
MXS_ERROR("Unable to process passwd file %s : errno %d.\n"
"Removing user from file failed, and must be done "
"manually.",
fname,
err);
fclose(fp);
fclose(fp_tmp);
unlink(fname_tmp);
@ -309,26 +287,21 @@ char* admin_remove_user(
* Unmatching lines are copied to tmp file.
*/
if (strncmp(uname, fusr, strlen(uname)+1) != 0) {
if(fsetpos(fp, &rpos) != 0){ /** one step back */
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to set stream position. ")));
}
fgets(line, LINELEN, fp);
fputs(line, fp_tmp);
if(fsetpos(fp, &rpos) != 0){ /** one step back */
MXS_ERROR("Unable to set stream position. ");
}
fgets(line, LINELEN, fp);
fputs(line, fp_tmp);
}
if (fgetpos(fp, &rpos) != 0) {
int err = errno;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to process passwd file %s : "
"errno %d.\n"
"Removing user from file failed, and must be "
"done manually.",
fname,
err)));
MXS_ERROR("Unable to process passwd file %s : "
"errno %d.\n"
"Removing user from file failed, and must be "
"done manually.",
fname,
err);
fclose(fp);
fclose(fp_tmp);
unlink(fname_tmp);
@ -341,14 +314,12 @@ char* admin_remove_user(
*/
if (rename(fname_tmp, fname)) {
int err = errno;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to rename new passwd file %s : errno "
"%d.\n"
"Rename it to %s manually.",
fname_tmp,
err,
fname)));
MXS_ERROR("Unable to rename new passwd file %s : errno "
"%d.\n"
"Rename it to %s manually.",
fname_tmp,
err,
fname);
unlink(fname_tmp);
fclose(fp_tmp);
return ADMIN_ERR_PWDFILEACCESS;

View File

@ -124,10 +124,8 @@ retblock:
if (rval == NULL)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
}
#if defined(BUFFER_TRACE)
else
@ -299,10 +297,8 @@ GWBUF *rval;
{
ss_dassert(rval != NULL);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
return NULL;
}
@ -367,10 +363,8 @@ GWBUF *gwbuf_clone_portion(
{
ss_dassert(clonebuf != NULL);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
return NULL;
}
atomic_add(&buf->sbuf->refcount, 1);
@ -625,10 +619,8 @@ void gwbuf_add_buffer_object(
if (newb == NULL)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
return;
}
newb->bo_id = id;
@ -716,10 +708,8 @@ BUF_PROPERTY *prop;
{
ss_dassert(prop != NULL);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
return 0;
}
prop->name = strdup(name);

View File

@ -152,8 +152,8 @@ char* config_clean_string_list(char* str)
{
PCRE2_UCHAR errbuf[STRERROR_BUFLEN];
pcre2_get_error_message(re_err, errbuf, sizeof(errbuf));
skygw_log_write(LE, "[%s] Error: Regular expression compilation failed at %d: %s",
__FUNCTION__, err_offset, errbuf);
MXS_ERROR("[%s] Regular expression compilation failed at %d: %s",
__FUNCTION__, err_offset, errbuf);
pcre2_code_free(re);
free(dest);
return NULL;
@ -188,7 +188,7 @@ char* config_clean_string_list(char* str)
}
else
{
skygw_log_write(LE, "[%s] Error: Memory allocation failed.", __FUNCTION__);
MXS_ERROR("[%s] Memory allocation failed.", __FUNCTION__);
}
return dest;
@ -254,7 +254,7 @@ handler(void *userdata, const char *section, const char *name, const char *value
if ((tmp = realloc(p1->value, sizeof(char) * (paramlen))) == NULL)
{
skygw_log_write(LE, "[%s] Error: Memory allocation failed.", __FUNCTION__);
MXS_ERROR("[%s] Memory allocation failed.", __FUNCTION__);
return 0;
}
strcat(tmp, ",");
@ -262,7 +262,7 @@ handler(void *userdata, const char *section, const char *name, const char *value
if ((p1->value = config_clean_string_list(tmp)) == NULL)
{
p1->value = tmp;
skygw_log_write(LE, "[%s] Error: Cleaning configuration parameter failed.", __FUNCTION__);
MXS_ERROR("[%s] Cleaning configuration parameter failed.", __FUNCTION__);
return 0;
}
free(tmp);
@ -366,7 +366,7 @@ config_load(char *file)
"Error: Failed to parse configuration file. Memory allocation failed.");
}
skygw_log_write(LE, errorbuffer);
MXS_ERROR("%s", errorbuffer);
return 0;
}
@ -443,7 +443,7 @@ process_config_context(CONFIG_CONTEXT *context)
if ((monitorhash = hashtable_alloc(5, simple_str_hash, strcmp)) == NULL)
{
skygw_log_write(LOGFILE_ERROR, "Error: Failed to allocate, monitor configuration check hashtable.");
MXS_ERROR("Failed to allocate, monitor configuration check hashtable.");
return 0;
}
hashtable_memory_fns(monitorhash, (HASHMEMORYFN)strdup, NULL, (HASHMEMORYFN)free, NULL);
@ -458,10 +458,7 @@ process_config_context(CONFIG_CONTEXT *context)
char *type = config_get_value(obj->parameters, "type");
if (type == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Configuration object '%s' has no type.",
obj->object)));
MXS_ERROR("Configuration object '%s' has no type.", obj->object);
error_count++;
}
else if (!strcmp(type, "service"))
@ -543,13 +540,11 @@ process_config_context(CONFIG_CONTEXT *context)
if (obj->element == NULL) /*< if module load failed */
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Reading configuration "
"for router service '%s' failed. "
"Router %s is not loaded.",
obj->object,
obj->object)));
MXS_ERROR("Reading configuration "
"for router service '%s' failed. "
"Router %s is not loaded.",
obj->object,
obj->object);
obj = obj->next;
continue; /*< process next obj */
}
@ -584,50 +579,50 @@ process_config_context(CONFIG_CONTEXT *context)
if (ssl_cert == NULL)
{
error_count++;
skygw_log_write(LE, "Error: Server certificate missing for service '%s'."
"Please provide the path to the server certificate by adding "
"the ssl_cert=<path> parameter", obj->object);
MXS_ERROR("Server certificate missing for service '%s'."
"Please provide the path to the server certificate by adding "
"the ssl_cert=<path> parameter", obj->object);
}
if (ssl_ca_cert == NULL)
{
error_count++;
skygw_log_write(LE, "Error: CA Certificate missing for service '%s'."
"Please provide the path to the certificate authority "
"certificate by adding the ssl_ca_cert=<path> parameter",
obj->object);
MXS_ERROR("CA Certificate missing for service '%s'."
"Please provide the path to the certificate authority "
"certificate by adding the ssl_ca_cert=<path> parameter",
obj->object);
}
if (ssl_key == NULL)
{
error_count++;
skygw_log_write(LE, "Error: Server private key missing for service '%s'. "
"Please provide the path to the server certificate key by "
"adding the ssl_key=<path> parameter",
obj->object);
MXS_ERROR("Server private key missing for service '%s'. "
"Please provide the path to the server certificate key by "
"adding the ssl_key=<path> parameter",
obj->object);
}
if (access(ssl_ca_cert, F_OK) != 0)
{
skygw_log_write(LE, "Error: Certificate authority file for service '%s' "
"not found: %s",
obj->object, ssl_ca_cert);
MXS_ERROR("Certificate authority file for service '%s' "
"not found: %s",
obj->object, ssl_ca_cert);
error_count++;
}
if (access(ssl_cert, F_OK) != 0)
{
skygw_log_write(LE, "Error: Server certificate file for service '%s' not found: %s",
obj->object,
ssl_cert);
MXS_ERROR("Server certificate file for service '%s' not found: %s",
obj->object,
ssl_cert);
error_count++;
}
if (access(ssl_key, F_OK) != 0)
{
skygw_log_write(LE, "Error: Server private key file for service '%s' not found: %s",
obj->object,
ssl_key);
MXS_ERROR("Server private key file for service '%s' not found: %s",
obj->object,
ssl_key);
error_count++;
}
@ -635,8 +630,8 @@ process_config_context(CONFIG_CONTEXT *context)
{
if (serviceSetSSL(obj->element, ssl) != 0)
{
skygw_log_write(LE, "Error: Unknown parameter for service '%s': %s",
obj->object, ssl);
MXS_ERROR("Unknown parameter for service '%s': %s",
obj->object, ssl);
error_count++;
}
else
@ -646,9 +641,9 @@ process_config_context(CONFIG_CONTEXT *context)
{
if (serviceSetSSLVersion(obj->element, ssl_version) != 0)
{
skygw_log_write(LE, "Error: Unknown parameter value for "
"'ssl_version' for service '%s': %s",
obj->object, ssl_version);
MXS_ERROR("Unknown parameter value for "
"'ssl_version' for service '%s': %s",
obj->object, ssl_version);
error_count++;
}
}
@ -656,9 +651,9 @@ process_config_context(CONFIG_CONTEXT *context)
{
if (serviceSetSSLVerifyDepth(obj->element, atoi(ssl_cert_verify_depth)) != 0)
{
skygw_log_write(LE, "Error: Invalid parameter value for "
"'ssl_cert_verify_depth' for service '%s': %s",
obj->object, ssl_cert_verify_depth);
MXS_ERROR("Invalid parameter value for "
"'ssl_cert_verify_depth' for service '%s': %s",
obj->object, ssl_cert_verify_depth);
error_count++;
}
}
@ -716,12 +711,10 @@ process_config_context(CONFIG_CONTEXT *context)
}
else if (user && auth == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Service '%s' has a "
"user defined but no "
"corresponding password.",
obj->object)));
MXS_ERROR("Service '%s' has a "
"user defined but no "
"corresponding password.",
obj->object);
}
/** Read, validate and set max_slave_connections */
if (max_slave_conn_str != NULL)
@ -747,17 +740,15 @@ process_config_context(CONFIG_CONTEXT *context)
if (!succp)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"* Warning : invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is either <int> for slave connection "
"count or\n\t<int>%% for specifying the "
"maximum percentage of available the "
"slaves that will be connected.",
((SERVICE*)obj->element)->name,
param->name,
param->value)));
MXS_WARNING("Invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is either <int> for slave connection "
"count or\n\t<int>%% for specifying the "
"maximum percentage of available the "
"slaves that will be connected.",
((SERVICE*)obj->element)->name,
param->name,
param->value);
}
}
/** Read, validate and set max_slave_replication_lag */
@ -786,15 +777,13 @@ process_config_context(CONFIG_CONTEXT *context)
if (!succp)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"* Warning : invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is <int> for maximum "
"slave replication lag.",
((SERVICE*)obj->element)->name,
param->name,
param->value)));
MXS_WARNING("Invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is <int> for maximum "
"slave replication lag.",
((SERVICE*)obj->element)->name,
param->name,
param->value);
}
}
/** Parameters for rwsplit router only */
@ -829,21 +818,17 @@ process_config_context(CONFIG_CONTEXT *context)
{
if(param)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"* Warning : invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is [master|all] for "
"use sql variables in.",
((SERVICE*)obj->element)->name,
param->name,
param->value)));
MXS_WARNING("Invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is [master|all] for "
"use sql variables in.",
((SERVICE*)obj->element)->name,
param->name,
param->value);
}
else
{
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
"Error : parameter was NULL")));
MXS_ERROR("Parameter was NULL");
}
}
}
@ -852,11 +837,7 @@ process_config_context(CONFIG_CONTEXT *context)
else
{
obj->element = NULL;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : No router defined for service "
"'%s'\n",
obj->object)));
MXS_ERROR("No router defined for service '%s'.", obj->object);
error_count++;
}
}
@ -884,14 +865,12 @@ process_config_context(CONFIG_CONTEXT *context)
else
{
obj->element = NULL;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Server '%s' is missing a "
"required configuration parameter. A "
"server must "
"have address, port and protocol "
"defined.",
obj->object)));
MXS_ERROR("Server '%s' is missing a "
"required configuration parameter. A "
"server must "
"have address, port and protocol "
"defined.",
obj->object);
error_count++;
}
@ -901,11 +880,9 @@ process_config_context(CONFIG_CONTEXT *context)
}
else if (monuser && monpw == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Server '%s' has a monitoruser"
"defined but no corresponding password.",
obj->object)));
MXS_ERROR("Server '%s' has a monitoruser"
"defined but no corresponding password.",
obj->object);
}
if (obj->element)
@ -945,11 +922,9 @@ process_config_context(CONFIG_CONTEXT *context)
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Filter '%s' has no module "
"defined defined to load.",
obj->object)));
MXS_ERROR("Filter '%s' has no module "
"defined defined to load.",
obj->object);
error_count++;
}
@ -1023,25 +998,21 @@ process_config_context(CONFIG_CONTEXT *context)
if (!found)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Unable to find "
"server '%s' that is "
"configured as part of "
"service '%s'.",
s, obj->object)));
MXS_ERROR("Unable to find "
"server '%s' that is "
"configured as part of "
"service '%s'.",
s, obj->object);
}
s = strtok_r(NULL, ",", &lasts);
}
}
else if (servers == NULL && !isInternalService(router))
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Warning: The service '%s' is missing a "
"definition of the servers that provide "
"the service.",
obj->object)));
MXS_WARNING("The service '%s' is missing a "
"definition of the servers that provide "
"the service.",
obj->object);
}
if (roptions && obj->element)
@ -1099,12 +1070,10 @@ process_config_context(CONFIG_CONTEXT *context)
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Listener '%s', "
"service '%s' not found. "
"Listener will not execute for socket %s.",
obj->object, service, socket)));
MXS_ERROR("Listener '%s', "
"service '%s' not found. "
"Listener will not execute for socket %s.",
obj->object, service, socket);
error_count++;
}
}
@ -1123,25 +1092,21 @@ process_config_context(CONFIG_CONTEXT *context)
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Listener '%s', "
"service '%s' not found. "
"Listener will not execute.",
obj->object, service)));
MXS_ERROR("Listener '%s', "
"service '%s' not found. "
"Listener will not execute.",
obj->object, service);
error_count++;
}
}
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Listener '%s' is missing a "
"required "
"parameter. A Listener must have a "
"service, port and protocol defined.",
obj->object)));
MXS_ERROR("Listener '%s' is missing a "
"required "
"parameter. A Listener must have a "
"service, port and protocol defined.",
obj->object);
error_count++;
}
}
@ -1200,9 +1165,9 @@ process_config_context(CONFIG_CONTEXT *context)
}
else
{
skygw_log_write(LOGFILE_ERROR, "Warning: Monitor '%s' "
"missing monitor_interval parameter, "
"default value of 10000 miliseconds.", obj->object);
MXS_WARNING("Monitor '%s' "
"missing monitor_interval parameter, "
"default value of 10000 miliseconds.", obj->object);
}
/* set timeouts */
@ -1232,10 +1197,9 @@ process_config_context(CONFIG_CONTEXT *context)
found = 1;
if (hashtable_add(monitorhash, obj1->object, "") == 0)
{
skygw_log_write(LOGFILE_ERROR,
"Warning: Multiple monitors are monitoring server [%s]. "
"This will cause undefined behavior.",
obj1->object);
MXS_WARNING("Multiple monitors are monitoring server [%s]. "
"This will cause undefined behavior.",
obj1->object);
}
monitorAddServer(obj->element, obj1->element);
}
@ -1243,14 +1207,11 @@ process_config_context(CONFIG_CONTEXT *context)
}
if (!found)
{
LOGIF(LE,
(skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Unable to find "
MXS_ERROR("Unable to find "
"server '%s' that is "
"configured in the "
"monitor '%s'.",
s, obj->object)));
s, obj->object);
}
s = strtok_r(NULL, ",", &lasts);
@ -1264,32 +1225,26 @@ process_config_context(CONFIG_CONTEXT *context)
}
else if (obj->element && user)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR, "Error: "
"Monitor '%s' defines a "
"username with no password.",
obj->object)));
MXS_ERROR("Monitor '%s' defines a "
"username with no password.",
obj->object);
error_count++;
}
}
else
{
obj->element = NULL;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Monitor '%s' is missing a "
"require module parameter.",
obj->object)));
MXS_ERROR("Monitor '%s' is missing a "
"require module parameter.",
obj->object);
error_count++;
}
}
else if (strcmp(type, "server") != 0 && strcmp(type, "filter") != 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Configuration object '%s' has an "
"invalid type specified.",
obj->object)));
MXS_ERROR("Configuration object '%s' has an "
"invalid type specified.",
obj->object);
error_count++;
}
@ -1305,12 +1260,10 @@ process_config_context(CONFIG_CONTEXT *context)
if (error_count)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : %d errors where encountered processing the "
"configuration file '%s'.",
error_count,
config_file)));
MXS_ERROR("%d errors where encountered processing the "
"configuration file '%s'.",
error_count,
config_file);
return 0;
}
@ -1628,7 +1581,7 @@ handle_global_item(const char *name, const char *value)
}
else
{
skygw_log_write(LE, "Warning: Invalid value for 'threads': %s.", value);
MXS_WARNING("Invalid value for 'threads': %s.", value);
return 0;
}
}
@ -1654,7 +1607,7 @@ handle_global_item(const char *name, const char *value)
}
else
{
skygw_log_write(LE, "Invalid timeout value for 'auth_connect_timeout': %s", value);
MXS_WARNING("Invalid timeout value for 'auth_connect_timeout': %s", value);
}
}
else if (strcmp(name, "auth_read_timeout") == 0)
@ -1667,7 +1620,7 @@ handle_global_item(const char *name, const char *value)
}
else
{
skygw_log_write(LE, "Invalid timeout value for 'auth_read_timeout': %s", value);
MXS_ERROR("Invalid timeout value for 'auth_read_timeout': %s", value);
}
}
else if (strcmp(name, "auth_write_timeout") == 0)
@ -1680,7 +1633,7 @@ handle_global_item(const char *name, const char *value)
}
else
{
skygw_log_write(LE, "Invalid timeout value for 'auth_write_timeout': %s", value);
MXS_ERROR("Invalid timeout value for 'auth_write_timeout': %s", value);
}
}
else
@ -1834,11 +1787,7 @@ process_config_update(CONFIG_CONTEXT *context)
char *type = config_get_value(obj->parameters, "type");
if (type == NULL)
{
LOGIF(LE,
(skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Configuration object %s has no type.",
obj->object)));
MXS_ERROR("Configuration object %s has no type.", obj->object);
}
else if (!strcmp(type, "service"))
{
@ -1963,17 +1912,15 @@ process_config_update(CONFIG_CONTEXT *context)
if (!succp && param != NULL)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"* Warning : invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is either <int> for slave connection "
"count or\n\t<int>%% for specifying the "
"maximum percentage of available the "
"slaves that will be connected.",
((SERVICE*)obj->element)->name,
param->name,
param->value)));
MXS_WARNING("Invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is either <int> for slave connection "
"count or\n\t<int>%% for specifying the "
"maximum percentage of available the "
"slaves that will be connected.",
((SERVICE*)obj->element)->name,
param->name,
param->value);
}
}
/** Read, validate and set max_slave_replication_lag */
@ -2003,22 +1950,19 @@ process_config_update(CONFIG_CONTEXT *context)
if (!succp)
{
if(param){
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"* Warning : invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is <int> for maximum "
"slave replication lag.",
((SERVICE*)obj->element)->name,
param->name,
param->value)));
if (param)
{
MXS_WARNING("Invalid value type "
"for parameter \'%s.%s = %s\'\n\tExpected "
"type is <int> for maximum "
"slave replication lag.",
((SERVICE*)obj->element)->name,
param->name,
param->value);
}
else
{
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
"Error : parameter was NULL")));
MXS_ERROR("Parameter was NULL");
}
}
}
@ -2074,11 +2018,7 @@ process_config_update(CONFIG_CONTEXT *context)
else
{
obj->element = NULL;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : No router defined for service "
"'%s'.",
obj->object)));
MXS_ERROR("No router defined for service '%s'.", obj->object);
}
}
else if (!strcmp(type, "server"))
@ -2123,14 +2063,12 @@ process_config_update(CONFIG_CONTEXT *context)
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Server '%s' is missing a "
"required "
"configuration parameter. A server must "
"have address, port and protocol "
"defined.",
obj->object)));
MXS_ERROR("Server '%s' is missing a "
"required "
"configuration parameter. A server must "
"have address, port and protocol "
"defined.",
obj->object);
}
}
obj = obj->next;
@ -2181,13 +2119,11 @@ process_config_update(CONFIG_CONTEXT *context)
}
if (!found)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Unable to find "
"server '%s' that is "
"configured as part of "
"service '%s'.",
s, obj->object)));
MXS_ERROR("Unable to find "
"server '%s' that is "
"configured as part of "
"service '%s'.",
s, obj->object);
}
s = strtok_r(NULL, ",", &lasts);
}
@ -2261,11 +2197,7 @@ process_config_update(CONFIG_CONTEXT *context)
strcmp(type, "monitor") != 0 &&
strcmp(type, "filter") != 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Configuration object %s has an invalid "
"type specified.",
obj->object)));
MXS_ERROR("Configuration object %s has an invalid type specified.", obj->object);
}
obj = obj->next;
}
@ -2389,14 +2321,12 @@ check_config_objects(CONFIG_CONTEXT *context)
if (found == 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unexpected parameter "
"'%s' for object '%s' of type "
"'%s'.",
params->name,
obj->object,
type)));
MXS_ERROR("Unexpected parameter "
"'%s' for object '%s' of type "
"'%s'.",
params->name,
obj->object,
type);
}
params = params->next;
}
@ -2472,7 +2402,7 @@ config_truth_value(char *str)
{
return 0;
}
skygw_log_write(LOGFILE_ERROR, "Error: Not a boolean value: %s", str);
MXS_ERROR("Not a boolean value: %s", str);
return -1;
}
@ -2745,32 +2675,26 @@ config_enable_feedback_task(void)
/* Add the task to the tasl list */
if (hktask_add("send_feedback", module_feedback_send, cfg, cfg->feedback_frequency))
{
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Notification service feedback task started: URL=%s, User-Info=%s, "
"Frequency %u seconds",
cfg->feedback_url,
cfg->feedback_user_info,
cfg->feedback_frequency)));
MXS_NOTICE("Notification service feedback task started: URL=%s, User-Info=%s, "
"Frequency %u seconds",
cfg->feedback_url,
cfg->feedback_user_info,
cfg->feedback_frequency);
}
}
else
{
if (enable_set)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Notification service feedback cannot start: feedback_enable=1 but"
" some required parameters are not set: %s%s%s",
url_set == 0 ? "feedback_url is not set" : "",
(user_info_set == 0 && url_set == 0) ? ", " : "",
user_info_set == 0 ? "feedback_user_info is not set" : "")));
MXS_ERROR("Notification service feedback cannot start: feedback_enable=1 but"
" some required parameters are not set: %s%s%s",
url_set == 0 ? "feedback_url is not set" : "",
(user_info_set == 0 && url_set == 0) ? ", " : "",
user_info_set == 0 ? "feedback_user_info is not set" : "");
}
else
{
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"Notification service feedback is not enabled")));
MXS_INFO("Notification service feedback is not enabled.");
}
}
}
@ -2795,7 +2719,7 @@ void config_add_param(CONFIG_CONTEXT* obj, char* key, char* value)
if (nptr == NULL)
{
skygw_log_write(LOGFILE_ERROR, "Memory allocation failed when adding configuration parameters");
MXS_ERROR("Memory allocation failed when adding configuration parameters.");
return;
}
@ -2858,8 +2782,7 @@ bool config_has_duplicate_sections(const char* config)
if (hashtable_add(hash, section, "") == 0)
{
skygw_log_write(LE, "Error: Duplicate section found: %s",
section);
MXS_ERROR("Duplicate section found: %s", section);
rval = true;
}
}
@ -2869,15 +2792,15 @@ bool config_has_duplicate_sections(const char* config)
else
{
char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, "Error: Failed to open file '%s': %s", config,
strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to open file '%s': %s", config,
strerror_r(errno, errbuf, sizeof(errbuf)));
rval = true;
}
}
else
{
skygw_log_write(LE, "Error: Failed to allocate enough memory when checking"
" for duplicate sections in configuration file.");
MXS_ERROR("Failed to allocate enough memory when checking"
" for duplicate sections in configuration file.");
rval = true;
}
@ -2926,9 +2849,9 @@ int maxscale_getline(char** dest, int* size, FILE* file)
}
else
{
skygw_log_write(LE, "Error: Failed to reallocate memory from %d"
" bytes to %d bytes when reading from file.",
*size, *size * 2);
MXS_ERROR("Failed to reallocate memory from %d"
" bytes to %d bytes when reading from file.",
*size, *size * 2);
destptr[offset - 1] = '\0';
*dest = destptr;
return -1;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -94,12 +94,12 @@ EXTERNCMD* externcmd_allocate(char* argstr)
{
if (access(cmd->argv[0], F_OK) != 0)
{
skygw_log_write(LE, "Cannot find file: %s", cmd->argv[0]);
MXS_ERROR("Cannot find file: %s", cmd->argv[0]);
}
else
{
skygw_log_write(LE, "Cannot execute file '%s'. Missing "
"execution permissions.", cmd->argv[0]);
MXS_ERROR("Cannot execute file '%s'. Missing "
"execution permissions.", cmd->argv[0]);
}
externcmd_free(cmd);
cmd = NULL;
@ -152,8 +152,8 @@ int externcmd_execute(EXTERNCMD* cmd)
if (pid < 0)
{
char errbuf[STRERROR_BUFLEN];
skygw_log_write(LOGFILE_ERROR, "Failed to execute command '%s', fork failed: [%d] %s",
cmd->argv[0], errno, strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to execute command '%s', fork failed: [%d] %s",
cmd->argv[0], errno, strerror_r(errno, errbuf, sizeof(errbuf)));
rval = -1;
}
else if (pid == 0)
@ -166,7 +166,7 @@ int externcmd_execute(EXTERNCMD* cmd)
{
cmd->child = pid;
cmd->n_exec++;
LOGIF(LD, skygw_log_write(LD, "[monitor_exec_cmd] Forked child process %d : %s.", pid, cmd));
MXS_DEBUG("[monitor_exec_cmd] Forked child process %d : %s.", pid, cmd);
}
return rval;
@ -274,11 +274,11 @@ bool externcmd_can_execute(const char* argstr)
}
else if (access(command, F_OK) == 0)
{
skygw_log_write(LE, "The executable cannot be executed: %s", command);
MXS_ERROR("The executable cannot be executed: %s", command);
}
else
{
skygw_log_write(LE, "The executable cannot be found: %s", command);
MXS_ERROR("The executable cannot be found: %s", command);
}
free(command);
}

View File

@ -345,12 +345,10 @@ DOWNSTREAM *me;
if ((me = (DOWNSTREAM *)calloc(1, sizeof(DOWNSTREAM))) == NULL)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation for filter session failed "
"due to %d,%s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Memory allocation for filter session failed "
"due to %d,%s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
return NULL;
}

View File

@ -292,9 +292,7 @@ static void maxscale_ssl_id(CRYPTO_THREADID* id)
*/
static void sighup_handler (int i)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Refreshing configuration following SIGHUP\n")));
MXS_NOTICE("Refreshing configuration following SIGHUP\n");
config_reload();
}
@ -304,18 +302,14 @@ static void sighup_handler (int i)
*/
static void sigusr1_handler (int i)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Log file flush following reception of SIGUSR1\n")));
MXS_NOTICE("Log file flush following reception of SIGUSR1\n");
mxs_log_rotate();
}
static void sigterm_handler (int i) {
extern void shutdown_server();
skygw_log_write_flush(
LOGFILE_ERROR,
"MaxScale received signal SIGTERM. Exiting.");
MXS_ERROR("MaxScale received signal SIGTERM. Exiting.");
mxs_log_flush_sync();
shutdown_server();
}
@ -325,9 +319,7 @@ sigint_handler (int i)
{
extern void shutdown_server();
skygw_log_write_flush(
LOGFILE_ERROR,
"MaxScale received signal SIGINT. Shutting down.");
MXS_ERROR("MaxScale received signal SIGINT. Shutting down.");
mxs_log_flush_sync();
shutdown_server();
fprintf(stderr, "\n\nShutting down MaxScale\n\n");
@ -342,28 +334,33 @@ sigchld_handler (int i)
if ((child = wait(&exit_status)) == -1)
{
char errbuf[STRERROR_BUFLEN];
skygw_log_write_flush(LE, "Error: failed to wait child process: %d %s",
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to wait child process: %d %s",
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
}
else
{
if (WIFEXITED(exit_status))
{
skygw_log_write_flush(WEXITSTATUS(exit_status) != 0 ? LE : LT,
"Child process %d exited with status %d",
child, WEXITSTATUS(exit_status));
if (WEXITSTATUS(exit_status) != 0)
{
MXS_ERROR("Child process %d exited with status %d",
child, WEXITSTATUS(exit_status));
}
else
{
MXS_INFO("Child process %d exited with status %d",
child, WEXITSTATUS(exit_status));
}
}
else if (WIFSIGNALED(exit_status))
{
skygw_log_write_flush((LE|LT),
"Child process %d was stopped by signal %d.",
child, WTERMSIG(exit_status));
MXS_ERROR("Child process %d was stopped by signal %d.",
child, WTERMSIG(exit_status));
}
else
{
skygw_log_write_flush((LE|LT),
"Child process %d did not exit normally. Exit status: %d",
child, exit_status);
MXS_ERROR("Child process %d did not exit normally. Exit status: %d",
child, exit_status);
}
}
}
@ -383,13 +380,11 @@ sigfatal_handler(int i)
GATEWAY_CONF* cnf = config_get_global_options();
fprintf(stderr, "\n\nMaxScale "MAXSCALE_VERSION" received fatal signal %d\n", i);
skygw_log_write_flush(
LOGFILE_ERROR,
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i);
MXS_ERROR("Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i);
skygw_log_write_flush(LE, "Commit ID: %s System name: %s "
"Release string: %s Embedded library version: %s",
maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
MXS_ERROR("Commit ID: %s System name: %s "
"Release string: %s Embedded library version: %s",
maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
{
void *addrs[128];
@ -398,9 +393,7 @@ sigfatal_handler(int i)
if (symbols) {
for (n = 0; n < count; n++) {
skygw_log_write_flush(
LOGFILE_ERROR,
" %s\n", symbols[n]);
MXS_ERROR(" %s\n", symbols[n]);
}
free(symbols);
} else {
@ -446,12 +439,10 @@ static int signal_set(int sig, void (*handler)(int)) {
int eno = errno;
errno = 0;
char errbuf[STRERROR_BUFLEN];
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed call sigaction() in %s due to %d, %s.",
program_invocation_short_name,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed call sigaction() in %s due to %d, %s.",
program_invocation_short_name,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
rc = 1;
}
return rc;
@ -475,13 +466,11 @@ int ntfw_cb(
int eno = errno;
errno = 0;
char errbuf[STRERROR_BUFLEN];
skygw_log_write(
LOGFILE_ERROR,
"Error : Failed to remove the data directory %s of "
"MaxScale due to %d, %s.",
datadir,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to remove the data directory %s of "
"MaxScale due to %d, %s.",
datadir,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
return rc;
}
@ -776,13 +765,11 @@ static void print_log_n_stderr(
if (do_log) {
char errbuf[STRERROR_BUFLEN];
skygw_log_write_flush(
LOGFILE_ERROR,
"%s %s %s %s",
log_err,
logstr,
eno == 0 ? " " : "Error :",
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_ERROR("%s %s %s %s",
log_err,
logstr,
eno == 0 ? " " : "Error :",
eno == 0 ? " " : strerror_r(eno, errbuf, sizeof(errbuf)));
}
if (do_stderr) {
char errbuf[STRERROR_BUFLEN];
@ -815,13 +802,11 @@ static bool file_is_readable(
absolute_pathname,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
skygw_log_write_flush(
LOGFILE_ERROR,
"Warning : Failed to read the configuration file %s due "
"to %d, %s.",
absolute_pathname,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_WARNING("Failed to read the configuration file %s due "
"to %d, %s.",
absolute_pathname,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
mxs_log_flush_sync();
succp = false;
}
@ -848,13 +833,11 @@ static bool file_is_writable(
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : unable to open file %s for write due "
"to %d, %s.",
absolute_pathname,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_ERROR("Unable to open file %s for write due "
"to %d, %s.",
absolute_pathname,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
succp = false;
}
return succp;
@ -909,14 +892,11 @@ static char* get_expanded_pathname(
relative_path,
strerror_r(eno, errbuf, sizeof(errbuf)));
skygw_log_write_flush(
LOGFILE_ERROR,
"Warning : Failed to read the "
"directory %s, due "
"to %d, %s.",
relative_path,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
MXS_WARNING("Failed to read the directory %s, due "
"to %d, %s.",
relative_path,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
free(expanded_path);
*output_path = NULL;
goto return_cnf_file_buf;
@ -939,10 +919,8 @@ static char* get_expanded_pathname(
ss_dassert(cnf_file_buf != NULL);
char errbuf[STRERROR_BUFLEN];
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)));
free(expanded_path);
expanded_path = NULL;
@ -1672,7 +1650,7 @@ int main(int argc, char **argv)
snprintf(errorbuffer, sizeof(errorbuffer),
"Error: Failed to pre-parse configuration file. Memory allocation failed.");
skygw_log_write(LE, errorbuffer);
MXS_ERROR("%s", errorbuffer);
if (!daemon_mode)
{
strncat(errorbuffer, "\n", STRING_BUFFER_SIZE);
@ -1775,29 +1753,11 @@ int main(int argc, char **argv)
get_cachedir());
}
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Configuration file: %s",
cnf_file_path)));
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Log directory: %s/",
get_logdir())));
LOGIF(LM,
(skygw_log_write_flush(
LOGFILE_MESSAGE,
"Data directory: %s",
get_datadir())));
LOGIF(LM,
(skygw_log_write_flush(LOGFILE_MESSAGE,
"Module directory: %s",
get_libdir())));
LOGIF(LM,
(skygw_log_write_flush(LOGFILE_MESSAGE,
"Service cache: %s",
get_cachedir())));
MXS_NOTICE("Configuration file: %s", cnf_file_path);
MXS_NOTICE("Log directory: %s", get_logdir());
MXS_NOTICE("Data directory: %s", get_datadir());
MXS_NOTICE("Module directory: %s", get_libdir());
MXS_NOTICE("Service cache: %s", get_cachedir());
/*< Update the server options */
for (i = 0; server_options[i]; i++)
@ -1854,15 +1814,13 @@ int main(int argc, char **argv)
}
}
}
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : mysql_library_init failed. It is a "
"mandatory component, required by router services and "
"the MaxScale core. Error %d, %s, %s : %d. Exiting.",
mysql_errno(NULL),
mysql_error(NULL),
__FILE__,
__LINE__);
MXS_ERROR("mysql_library_init failed. It is a "
"mandatory component, required by router services and "
"the MaxScale core. Error %d, %s, %s : %d. Exiting.",
mysql_errno(NULL),
mysql_error(NULL),
__FILE__,
__LINE__);
rc = MAXSCALE_NOLIBRARY;
goto return_main;
}
@ -1873,22 +1831,14 @@ int main(int argc, char **argv)
char* fprerr = "Failed to load MaxScale configuration "
"file. Exiting. See the error log for details.";
print_log_n_stderr(false, !daemon_mode, fprerr, fprerr, 0);
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to load MaxScale configuration file %s. "
"Exiting.",
cnf_file_path);
MXS_ERROR("Failed to load MaxScale configuration file %s. "
"Exiting.",
cnf_file_path);
rc = MAXSCALE_BADCONFIG;
goto return_main;
}
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"MariaDB Corporation MaxScale %s (C) MariaDB Corporation Ab 2013-2015",
MAXSCALE_VERSION)));
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"MaxScale is running in process %i",
getpid())));
MXS_NOTICE("MariaDB Corporation MaxScale %s (C) MariaDB Corporation Ab 2013-2015", MAXSCALE_VERSION);
MXS_NOTICE("MaxScale is running in process %i", getpid());
/** Check if a MaxScale process is already running */
if (pid_file_exists())
@ -1952,9 +1902,7 @@ int main(int argc, char **argv)
{
threads[thread_id] = thread_start(poll_waitevents, (void *)(thread_id + 1));
}
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE,
"MaxScale started with %d server threads.",
config_threadcount())));
MXS_NOTICE("MaxScale started with %d server threads.", config_threadcount());
/**
* Successful start, notify the parent process that it can exit.
*/
@ -1983,16 +1931,12 @@ int main(int argc, char **argv)
/*< Stop all the monitors */
monitorStopAll();
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"MaxScale is shutting down.")));
MXS_NOTICE("MaxScale is shutting down.");
/** Release mysql thread context*/
mysql_thread_end();
datadir_cleanup();
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"MaxScale shutdown completed.")));
MXS_NOTICE("MaxScale shutdown completed.");
unload_all_modules();
/* Remove Pidfile */
@ -2052,14 +1996,12 @@ static void log_flush_cb(
ts1.tv_sec = timeout_ms/1000;
ts1.tv_nsec = (timeout_ms%1000) * 1000000;
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE,
"Started MaxScale log flusher.")));
MXS_NOTICE("Started MaxScale log flusher.");
while (!do_exit) {
mxs_log_flush();
nanosleep(&ts1, NULL);
}
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE,
"Finished MaxScale log flusher.")));
MXS_NOTICE("Finished MaxScale log flusher.");
}
static void unlock_pidfile()

View File

@ -74,26 +74,22 @@ setipaddress(struct in_addr *a, char *p) {
hint.ai_flags = AI_PASSIVE;
hint.ai_family = AF_UNSPEC;
if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Failed to obtain address for host %s, %s",
p,
gai_strerror(rc))));
MXS_ERROR("Failed to obtain address for host %s, %s",
p,
gai_strerror(rc));
return 0;
return 0;
}
} else {
hint.ai_flags = AI_CANONNAME;
hint.ai_family = AF_INET;
if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Failed to obtain address for host %s, %s",
p,
gai_strerror(rc))));
MXS_ERROR("Failed to obtain address for host %s, %s",
p,
gai_strerror(rc));
return 0;
return 0;
}
}
@ -115,12 +111,9 @@ setipaddress(struct in_addr *a, char *p) {
if (h == NULL) {
if ((a->s_addr = inet_addr(p)) == -1) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : gethostbyname failed for [%s]",
p)));
MXS_ERROR("gethostbyname failed for [%s]", p);
return 0;
return 0;
}
} else {
/* take the first one */
@ -208,11 +201,8 @@ struct hostent *hp;
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to lookup host '%s'. ",
buf)));
return 0;
MXS_ERROR("Failed to lookup host '%s'.", buf);
return 0;
}
}
}
@ -233,7 +223,7 @@ long get_processor_count()
#ifdef _SC_NPROCESSORS_ONLN
if ((processors = sysconf(_SC_NPROCESSORS_ONLN)) <= 0)
{
skygw_log_write(LE, "Unable to establish the number of available cores. Defaulting to 4.");
MXS_WARNING("Unable to establish the number of available cores. Defaulting to 4.");
processors = 4;
}
#else

View File

@ -88,10 +88,8 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
mem->data = realloc(mem->data, mem->size + realsize + 1);
if(mem->data == NULL) {
/* out of memory! */
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error in module_feedback_send(), not enough memory for realloc")));
return 0;
MXS_ERROR("Error in module_feedback_send(), not enough memory for realloc");
return 0;
}
memcpy(&(mem->data[mem->size]), contents, realsize);
@ -133,36 +131,30 @@ MODULE_INFO *mod_info = NULL;
if (access(fname, F_OK) == -1)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to find library for "
"module: %s. Module dir: %s",
module, get_libdir())));
MXS_ERROR("Unable to find library for "
"module: %s. Module dir: %s",
module, get_libdir());
return NULL;
}
if ((dlhandle = dlopen(fname, RTLD_NOW|RTLD_LOCAL)) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to load library for module: "
"%s\n\n\t\t %s."
"\n\n",
module,
dlerror())));
return NULL;
MXS_ERROR("Unable to load library for module: "
"%s\n\n\t\t %s."
"\n\n",
module,
dlerror());
return NULL;
}
if ((sym = dlsym(dlhandle, "version")) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Version interface not supported by "
"module: %s\n\t\t\t %s.",
module,
dlerror())));
dlclose(dlhandle);
return NULL;
MXS_ERROR("Version interface not supported by "
"module: %s\n\t\t\t %s.",
module,
dlerror());
dlclose(dlhandle);
return NULL;
}
ver = sym;
version = ver();
@ -183,42 +175,26 @@ MODULE_INFO *mod_info = NULL;
if (strcmp(type, MODULE_PROTOCOL) == 0
&& mod_info->modapi != MODULE_API_PROTOCOL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Module '%s' does not implement "
"the protocol API.\n",
module)));
fatal = 1;
MXS_ERROR("Module '%s' does not implement the protocol API.", module);
fatal = 1;
}
if (strcmp(type, MODULE_ROUTER) == 0
&& mod_info->modapi != MODULE_API_ROUTER)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Module '%s' does not implement "
"the router API.\n",
module)));
fatal = 1;
MXS_ERROR("Module '%s' does not implement the router API.", module);
fatal = 1;
}
if (strcmp(type, MODULE_MONITOR) == 0
&& mod_info->modapi != MODULE_API_MONITOR)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Module '%s' does not implement "
"the monitor API.\n",
module)));
fatal = 1;
MXS_ERROR("Module '%s' does not implement the monitor API.", module);
fatal = 1;
}
if (strcmp(type, MODULE_FILTER) == 0
&& mod_info->modapi != MODULE_API_FILTER)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Module '%s' does not implement "
"the filter API.\n",
module)));
fatal = 1;
MXS_ERROR("Module '%s' does not implement the filter API.", module);
fatal = 1;
}
if (fatal)
{
@ -229,24 +205,20 @@ MODULE_INFO *mod_info = NULL;
if ((sym = dlsym(dlhandle, "GetModuleObject")) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Expected entry point interface missing "
"from module: %s\n\t\t\t %s.",
module,
dlerror())));
dlclose(dlhandle);
return NULL;
MXS_ERROR("Expected entry point interface missing "
"from module: %s\n\t\t\t %s.",
module,
dlerror());
dlclose(dlhandle);
return NULL;
}
ep = sym;
modobj = ep();
LOGIF(LM, (skygw_log_write_flush(
LOGFILE_MESSAGE,
"Loaded module %s: %s from %s",
module,
version,
fname)));
MXS_NOTICE("Loaded module %s: %s from %s",
module,
version,
fname);
register_module(module, type, dlhandle, version, modobj, mod_info);
}
else
@ -448,11 +420,9 @@ MODULES *modules_list = registered;
FEEDBACK_CONF *feedback_config = config_get_feedback_data();
if (!module_create_feedback_report(&buffer, modules_list, feedback_config)) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error in module_create_feedback_report(): gwbuf_alloc() failed to allocate memory")));
MXS_ERROR("Error in module_create_feedback_report(): gwbuf_alloc() failed to allocate memory");
return;
return;
}
dcb_printf(dcb, (char *)GWBUF_DATA(buffer));
gwbuf_free(buffer);
@ -568,13 +538,12 @@ module_feedback_send(void* data) {
/* Configuration check */
if (feedback_config->feedback_enable == 0 || feedback_config->feedback_url == NULL || feedback_config->feedback_user_info == NULL) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error in module_feedback_send(): some mandatory parameters are not set"
" feedback_enable=%u, feedback_url=%s, feedback_user_info=%s",
feedback_config->feedback_enable,
feedback_config->feedback_url == NULL ? "NULL" : feedback_config->feedback_url,
feedback_config->feedback_user_info == NULL ? "NULL" : feedback_config->feedback_user_info)));
MXS_ERROR("Error in module_feedback_send(): some mandatory parameters are not set"
" feedback_enable=%u, feedback_url=%s, feedback_user_info=%s",
feedback_config->feedback_enable,
feedback_config->feedback_url == NULL ? "NULL" : feedback_config->feedback_url,
feedback_config->feedback_user_info == NULL ?
"NULL" : feedback_config->feedback_user_info);
feedback_config->feedback_last_action = _NOTIFICATION_SEND_ERROR;
@ -591,36 +560,29 @@ module_feedback_send(void* data) {
/* It's not the rigt time, mark it as to be done and return */
feedback_config->feedback_last_action = _NOTIFICATION_SEND_PENDING;
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"module_feedback_send(): execution skipped, current hour [%d]"
" is not within the proper interval (from 2 AM to 4 AM)",
hour)));
MXS_INFO("module_feedback_send(): execution skipped, current hour [%d]"
" is not within the proper interval (from 2 AM to 4 AM)",
hour);
return;
}
/* Time to run the task: if a previous run was succesfull skip next runs */
if (feedback_config->feedback_last_action == _NOTIFICATION_SEND_OK) {
/* task was done before, return */
/* task was done before, return */
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"module_feedback_send(): execution skipped because of previous succesful run: hour is [%d], last_action [%d]",
hour, feedback_config->feedback_last_action)));
MXS_INFO("module_feedback_send(): execution skipped because of previous "
"succesful run: hour is [%d], last_action [%d]",
hour, feedback_config->feedback_last_action);
return;
return;
}
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"module_feedback_send(): task now runs: hour is [%d], last_action [%d]",
hour, feedback_config->feedback_last_action)));
MXS_INFO("module_feedback_send(): task now runs: hour is [%d], last_action [%d]",
hour, feedback_config->feedback_last_action);
if (!module_create_feedback_report(&buffer, modules_list, feedback_config)) {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error in module_create_feedback_report(): gwbuf_alloc() failed to allocate memory")));
MXS_ERROR("Error in module_create_feedback_report(): gwbuf_alloc() failed to allocate memory");
feedback_config->feedback_last_action = _NOTIFICATION_SEND_ERROR;
@ -635,16 +597,12 @@ module_feedback_send(void* data) {
} else {
feedback_config->feedback_last_action = _NOTIFICATION_SEND_ERROR;
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"Error in module_create_feedback_report(): do_http_post ret_code is %d", http_send)));
MXS_INFO("Error in module_create_feedback_report(): do_http_post ret_code is %d", http_send);
}
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"module_feedback_send(): task completed: hour is [%d], last_action [%d]",
hour,
feedback_config->feedback_last_action)));
MXS_INFO("module_feedback_send(): task completed: hour is [%d], last_action [%d]",
hour,
feedback_config->feedback_last_action);
gwbuf_free(buffer);
@ -822,12 +780,10 @@ do_http_post(GWBUF *buffer, void *cfg) {
/* Check for errors */
if(res != CURLE_OK) {
ret_code = 2;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: do_http_post(), curl call for [%s] failed due: %s, %s",
feedback_config->feedback_url,
curl_easy_strerror(res),
error_message)));
MXS_ERROR("do_http_post(), curl call for [%s] failed due: %s, %s",
feedback_config->feedback_url,
curl_easy_strerror(res),
error_message);
goto cleanup;
} else {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
@ -842,25 +798,18 @@ do_http_post(GWBUF *buffer, void *cfg) {
goto cleanup;
}
} else {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: do_http_post(), Bad HTTP Code from remote server: %lu",
http_code)));
ret_code = 4;
goto cleanup;
MXS_ERROR("do_http_post(), Bad HTTP Code from remote server: %lu", http_code);
ret_code = 4;
goto cleanup;
}
} else {
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: do_http_post(), curl object not initialized")));
ret_code = 1;
goto cleanup;
MXS_ERROR("do_http_post(), curl object not initialized");
ret_code = 1;
goto cleanup;
}
LOGIF(LT, (skygw_log_write_flush(
LOGFILE_TRACE,
"do_http_post() ret_code [%d], HTTP code [%d]",
ret_code, http_code)));
MXS_INFO("do_http_post() ret_code [%d], HTTP code [%d]",
ret_code, http_code);
cleanup:
if (chunk.data)

View File

@ -588,8 +588,7 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf)
/** The next packet is a partial, split into complete and partial packets */
if((buff = gwbuf_clone_portion(packet,0,total)) == NULL)
{
skygw_log_write(LOGFILE_ERROR,
"Error: Failed to partially clone buffer.");
MXS_ERROR("Failed to partially clone buffer.");
return NULL;
}
gwbuf_consume(packet,total);
@ -735,10 +734,8 @@ static void modutil_reply_routing_error(
if (buf == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Creating routing error message failed.")));
return;
MXS_ERROR("Creating routing error message failed.");
return;
}
/** Set flags that help router to process reply correctly */
gwbuf_set_type(buf, flags);
@ -876,8 +873,7 @@ void prepare_pcre2_patterns()
else
{
pcre2_get_error_message(err, errbuf, sizeof(errbuf));
skygw_log_write(LE, "Error: Failed to compile PCRE2 pattern: %s",
errbuf);
MXS_ERROR("Failed to compile PCRE2 pattern: %s", errbuf);
}
if (!pattern_init)
@ -940,8 +936,7 @@ mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char*
{
PCRE2_UCHAR errbuf[STRERROR_BUFLEN];
pcre2_get_error_message(errcode, errbuf, sizeof(errbuf));
skygw_log_write(LE, "Error: Failed to match pattern: %s",
errbuf);
MXS_ERROR("Failed to match pattern: %s", errbuf);
}
err = true;
}
@ -954,7 +949,7 @@ mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char*
if (err)
{
skygw_log_write(LE, "Error: Fatal error when matching wildcard patterns.");
MXS_ERROR("Fatal error when matching wildcard patterns.");
}
pcre2_match_data_free(mdata_percent);

View File

@ -66,12 +66,9 @@ MONITOR *mon;
if ((mon->module = load_module(module, MODULE_MONITOR)) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to load monitor module '%s'.",
name)));
free(mon);
return NULL;
MXS_ERROR("Unable to load monitor module '%s'.", name);
free(mon);
return NULL;
}
mon->state = MONITOR_STATE_ALLOC;
mon->name = strdup(name);
@ -364,10 +361,8 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
memcpy(&mon->connect_timeout, &value, sizeof(int));
} else {
memcpy(&mon->connect_timeout, &new_timeout, sizeof(int));
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"warning : Monitor Connect Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout)));
MXS_WARNING("Monitor Connect Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout);
}
break;
@ -376,10 +371,8 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
memcpy(&mon->read_timeout, &value, sizeof(int));
} else {
memcpy(&mon->read_timeout, &new_timeout, sizeof(int));
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"warning : Monitor Read Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout)));
MXS_WARNING("Monitor Read Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout);
}
break;
@ -388,17 +381,13 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
memcpy(&mon->write_timeout, &value, sizeof(int));
} else {
memcpy(&mon->write_timeout, &new_timeout, sizeof(int));
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"warning : Monitor Write Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout)));
MXS_WARNING("Monitor Write Timeout %i is greater than monitor interval ~%i seconds"
", lowering to %i seconds", value, max_timeout, new_timeout);
}
break;
default:
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Monitor setNetworkTimeout received an unsupported action type %i", type)));
break;
MXS_ERROR("Monitor setNetworkTimeout received an unsupported action type %i", type);
break;
}
}
@ -486,7 +475,7 @@ bool check_monitor_permissions(MONITOR* monitor)
if((mysql = mysql_init(NULL)) == NULL)
{
skygw_log_write(LE,"[%s] Error: MySQL connection initialization failed.",__FUNCTION__);
MXS_ERROR("[%s] Error: MySQL connection initialization failed.", __FUNCTION__);
free(dpasswd);
return false;
}
@ -499,12 +488,12 @@ bool check_monitor_permissions(MONITOR* monitor)
* user permissions. */
if(mysql_real_connect(mysql,server->name,user,dpasswd,NULL,server->port,NULL,0) == NULL)
{
skygw_log_write(LE,"%s: Error: Failed to connect to server %s(%s:%d) when"
" checking monitor user credentials and permissions.",
monitor->name,
server->unique_name,
server->name,
server->port);
MXS_ERROR("%s: Failed to connect to server %s(%s:%d) when"
" checking monitor user credentials and permissions.",
monitor->name,
server->unique_name,
server->name,
server->port);
mysql_close(mysql);
free(dpasswd);
return false;
@ -514,13 +503,13 @@ bool check_monitor_permissions(MONITOR* monitor)
{
if(mysql_errno(mysql) == ER_SPECIFIC_ACCESS_DENIED_ERROR)
{
skygw_log_write(LE,"%s: Error: User '%s' is missing REPLICATION CLIENT privileges. MySQL error message: %s",
monitor->name,user,mysql_error(mysql));
MXS_ERROR("%s: User '%s' is missing REPLICATION CLIENT privileges. MySQL error message: %s",
monitor->name,user,mysql_error(mysql));
}
else
{
skygw_log_write(LE,"%s: Error: Monitor failed to query for slave status. MySQL error message: %s",
monitor->name,mysql_error(mysql));
MXS_ERROR("%s: Monitor failed to query for slave status. MySQL error message: %s",
monitor->name,mysql_error(mysql));
}
rval = false;
}
@ -528,8 +517,8 @@ bool check_monitor_permissions(MONITOR* monitor)
{
if((res = mysql_use_result(mysql)) == NULL)
{
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for REPLICATION CLIENT permissions: %s",
monitor->name,mysql_error(mysql));
MXS_ERROR("%s: Result retrieval failed when checking for REPLICATION CLIENT permissions: %s",
monitor->name,mysql_error(mysql));
rval = false;
}
else

View File

@ -284,25 +284,21 @@ poll_add_dcb(DCB *dcb)
|| DCB_STATE_ZOMBIE == dcb->state
|| DCB_STATE_UNDEFINED == dcb->state)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_add_dcb] Error : existing state of dcb %p "
"is %s, but this should be impossible, crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
MXS_ERROR("%lu [poll_add_dcb] Error : existing state of dcb %p "
"is %s, but this should be impossible, crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
raise(SIGABRT);
}
if (DCB_STATE_POLLING == dcb->state
|| DCB_STATE_LISTENING == dcb->state)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_add_dcb] Error : existing state of dcb %p "
"is %s, but this is probably an error, not crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
MXS_ERROR("%lu [poll_add_dcb] Error : existing state of dcb %p "
"is %s, but this is probably an error, not crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
}
dcb->state = new_state;
spinlock_release(&dcb->dcb_initlock);
@ -318,12 +314,10 @@ poll_add_dcb(DCB *dcb)
}
if (0 == rc)
{
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_add_dcb] Added dcb %p in state %s to poll set.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
MXS_DEBUG("%lu [poll_add_dcb] Added dcb %p in state %s to poll set.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
}
else dcb->state = old_state;
return rc;
@ -354,13 +348,11 @@ poll_remove_dcb(DCB *dcb)
if (DCB_STATE_POLLING != dcb->state
&& DCB_STATE_LISTENING != dcb->state)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_remove_dcb] Error : existing state of dcb %p "
"is %s, but this is probably an error, not crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
MXS_ERROR("%lu [poll_remove_dcb] Error : existing state of dcb %p "
"is %s, but this is probably an error, not crashing.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
}
/*<
* Set state to NOPOLLING and remove dcb from poll set.
@ -409,25 +401,21 @@ poll_resolve_error(DCB *dcb, int errornum, bool adding)
{
if (EEXIST == errornum)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_resolve_error] Error : epoll_ctl could not add, "
"already exists for DCB %p.",
pthread_self(),
dcb)));
MXS_ERROR("%lu [poll_resolve_error] Error : epoll_ctl could not add, "
"already exists for DCB %p.",
pthread_self(),
dcb);
// Assume another thread added and no serious harm done
return 0;
}
if (ENOSPC == errornum)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_resolve_error] The limit imposed by "
"/proc/sys/fs/epoll/max_user_watches was "
"encountered while trying to register (EPOLL_CTL_ADD) a new "
"file descriptor on an epoll instance for dcb %p.",
pthread_self(),
dcb)));
MXS_ERROR("%lu [poll_resolve_error] The limit imposed by "
"/proc/sys/fs/epoll/max_user_watches was "
"encountered while trying to register (EPOLL_CTL_ADD) a new "
"file descriptor on an epoll instance for dcb %p.",
pthread_self(),
dcb);
/* Failure - assume handled by callers */
return -1;
}
@ -437,12 +425,10 @@ poll_resolve_error(DCB *dcb, int errornum, bool adding)
/* Must be removing */
if (ENOENT == errornum)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [poll_resolve_error] Error : epoll_ctl could not remove, "
"not found, for dcb %p.",
pthread_self(),
dcb)));
MXS_ERROR("%lu [poll_resolve_error] Error : epoll_ctl could not remove, "
"not found, for dcb %p.",
pthread_self(),
dcb);
// Assume another thread removed and no serious harm done
return 0;
}
@ -557,13 +543,11 @@ int poll_spins = 0;
atomic_add(&n_waiting, -1);
int eno = errno;
errno = 0;
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] epoll_wait returned "
"%d, errno %d",
pthread_self(),
nfds,
eno)));
MXS_DEBUG("%lu [poll_waitevents] epoll_wait returned "
"%d, errno %d",
pthread_self(),
nfds,
eno);
atomic_add(&n_waiting, -1);
}
/*
@ -604,11 +588,9 @@ int poll_spins = 0;
if (poll_spins <= number_poll_spins + 1)
atomic_add(&pollStats.n_nbpollev, 1);
poll_spins = 0;
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] epoll_wait found %d fds",
pthread_self(),
nfds)));
MXS_DEBUG("%lu [poll_waitevents] epoll_wait found %d fds",
pthread_self(),
nfds);
atomic_add(&pollStats.n_pollev, 1);
if (thread_data)
{
@ -757,8 +739,8 @@ poll_set_maxwait(unsigned int maxwait)
* Including session id to log entries depends on this function. Assumption is
* that when maxscale thread starts processing of an event it processes one
* and only one session until it returns from this function. Session id is
* read to thread's local storage in macro LOGIF_MAYBE(...) and reset back
* to zero just before returning in LOGIF(...) macro.
* read to thread's local storage if LOG_MAY_BE_ENABLED(LOGFILE_TRACE) returns true
* reset back to zero just before returning in LOG_IS_ENABLED(LOGFILE_TRACE) returns true.
* Thread local storage (tls_log_info_t) follows thread and is accessed every
* time log is written to particular log.
*
@ -842,15 +824,13 @@ unsigned long qtime;
#if defined(FAKE_CODE)
if (dcb_fake_write_ev[dcb->fd] != 0) {
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"Added fake events %d to ev %d.",
pthread_self(),
dcb_fake_write_ev[dcb->fd],
ev)));
ev |= dcb_fake_write_ev[dcb->fd];
dcb_fake_write_ev[dcb->fd] = 0;
MXS_DEBUG("%lu [poll_waitevents] "
"Added fake events %d to ev %d.",
pthread_self(),
dcb_fake_write_ev[dcb->fd],
ev);
ev |= dcb_fake_write_ev[dcb->fd];
dcb_fake_write_ev[dcb->fd] = 0;
}
#endif /* FAKE_CODE */
ss_debug(spinlock_acquire(&dcb->dcb_initlock);)
@ -861,16 +841,14 @@ unsigned long qtime;
{
return 0;
}
ss_debug(spinlock_release(&dcb->dcb_initlock);)
ss_debug(spinlock_release(&dcb->dcb_initlock));
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] event %d dcb %p "
"role %s",
pthread_self(),
ev,
dcb,
STRDCBROLE(dcb->dcb_role))));
MXS_DEBUG("%lu [poll_waitevents] event %d dcb %p "
"role %s",
pthread_self(),
ev,
dcb,
STRDCBROLE(dcb->dcb_role));
if (ev & EPOLLOUT)
{
@ -893,28 +871,24 @@ unsigned long qtime;
}
} else {
char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"EPOLLOUT due %d, %s. "
"dcb %p, fd %i",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)),
dcb,
dcb->fd)));
MXS_DEBUG("%lu [poll_waitevents] "
"EPOLLOUT due %d, %s. "
"dcb %p, fd %i",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)),
dcb,
dcb->fd);
}
}
if (ev & EPOLLIN)
{
if (dcb->state == DCB_STATE_LISTENING)
{
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"Accept in fd %d",
pthread_self(),
dcb->fd)));
MXS_DEBUG("%lu [poll_waitevents] "
"Accept in fd %d",
pthread_self(),
dcb->fd);
atomic_add(
&pollStats.n_accept, 1);
if (LOG_MAY_BE_ENABLED(LOGFILE_TRACE))
@ -931,13 +905,11 @@ unsigned long qtime;
}
else
{
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"Read in dcb %p fd %d",
pthread_self(),
dcb,
dcb->fd)));
MXS_DEBUG("%lu [poll_waitevents] "
"Read in dcb %p fd %d",
pthread_self(),
dcb,
dcb->fd);
atomic_add(&pollStats.n_read, 1);
/** Read session id to thread's local storage */
if (LOG_MAY_BE_ENABLED(LOGFILE_TRACE))
@ -960,26 +932,22 @@ unsigned long qtime;
if (eno == 0) {
eno = dcb_fake_write_errno[dcb->fd];
char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"Added fake errno %d. "
"%s",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_DEBUG("%lu [poll_waitevents] "
"Added fake errno %d. "
"%s",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
dcb_fake_write_errno[dcb->fd] = 0;
#endif /* FAKE_CODE */
if (eno != 0) {
char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"EPOLLERR due %d, %s.",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_DEBUG("%lu [poll_waitevents] "
"EPOLLERR due %d, %s.",
pthread_self(),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
atomic_add(&pollStats.n_error, 1);
/** Read session id to thread's local storage */
@ -1000,16 +968,14 @@ unsigned long qtime;
int eno = 0;
eno = gw_getsockerrno(dcb->fd);
char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"EPOLLHUP on dcb %p, fd %d. "
"Errno %d, %s.",
pthread_self(),
dcb,
dcb->fd,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_DEBUG("%lu [poll_waitevents] "
"EPOLLHUP on dcb %p, fd %d. "
"Errno %d, %s.",
pthread_self(),
dcb,
dcb->fd,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
atomic_add(&pollStats.n_hup, 1);
spinlock_acquire(&dcb->dcb_initlock);
if ((dcb->flags & DCBF_HUNG) == 0)
@ -1038,16 +1004,14 @@ unsigned long qtime;
int eno = 0;
eno = gw_getsockerrno(dcb->fd);
char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "
"EPOLLRDHUP on dcb %p, fd %d. "
"Errno %d, %s.",
pthread_self(),
dcb,
dcb->fd,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_DEBUG("%lu [poll_waitevents] "
"EPOLLRDHUP on dcb %p, fd %d. "
"Errno %d, %s.",
pthread_self(),
dcb,
dcb->fd,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
atomic_add(&pollStats.n_hup, 1);
spinlock_acquire(&dcb->dcb_initlock);
if ((dcb->flags & DCBF_HUNG) == 0)
@ -1126,7 +1090,10 @@ unsigned long qtime;
}
dcb->evq.processing = 0;
/** Reset session id from thread's local storage */
LOGIF(LT, tls_log_info.li_sesid = 0);
if (LOG_IS_ENABLED(LOGFILE_TRACE))
{
tls_log_info.li_sesid = 0;
}
spinlock_release(&pollqlock);
return 1;
@ -1150,14 +1117,12 @@ poll_dcb_session_check(DCB *dcb, const char *function)
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [%s] The dcb %p that was about to be processed by %s does not "
"have a non-null session pointer ",
pthread_self(),
__func__,
dcb,
function)));
MXS_ERROR("%lu [%s] The dcb %p that was about to be processed by %s does not "
"have a non-null session pointer ",
pthread_self(),
__func__,
dcb,
function);
return false;
}
}

View File

@ -82,23 +82,21 @@ secrets_readKeys(const char* path)
if (!reported)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LM, (skygw_log_write(LOGFILE_MESSAGE,
"Encrypted password file %s can't be accessed "
"(%s). Password encryption is not used.",
secret_file,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_NOTICE("Encrypted password file %s can't be accessed "
"(%s). Password encryption is not used.",
secret_file,
strerror_r(eno, errbuf, sizeof(errbuf)));
reported = 1;
}
}
else
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : access for secrets file "
"[%s] failed. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Access for secrets file "
"[%s] failed. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
}
return NULL;
}
@ -109,12 +107,11 @@ secrets_readKeys(const char* path)
int eno = errno;
errno = 0;
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Failed opening secret "
"file [%s]. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Failed opening secret "
"file [%s]. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
return NULL;
}
@ -126,12 +123,11 @@ secrets_readKeys(const char* path)
errno = 0;
close(fd);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : fstat for secret file %s "
"failed. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("fstat for secret file %s "
"failed. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
return NULL;
}
@ -141,30 +137,26 @@ secrets_readKeys(const char* path)
errno = 0;
close(fd);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Secrets file %s has "
"incorrect size. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Secrets file %s has "
"incorrect size. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
return NULL;
}
if (secret_stats.st_mode != (S_IRUSR | S_IFREG))
{
close(fd);
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Ignoring secrets file "
"%s, invalid permissions.",
secret_file)));
MXS_ERROR("Ignoring secrets file "
"%s, invalid permissions.",
secret_file);
return NULL;
}
if ((keys = (MAXKEYS *) malloc(sizeof(MAXKEYS))) == NULL)
{
close(fd);
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Memory allocation failed "
"for key structure.")));
MXS_ERROR("Memory allocation failed for key structure.");
return NULL;
}
@ -181,14 +173,13 @@ secrets_readKeys(const char* path)
close(fd);
free(keys);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Read from secrets file "
"%s failed. Read %d, expected %d bytes. Error %d, %s.",
secret_file,
len,
sizeof(MAXKEYS),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Read from secrets file "
"%s failed. Read %d, expected %d bytes. Error %d, %s.",
secret_file,
len,
sizeof(MAXKEYS),
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
return NULL;
}
@ -199,12 +190,11 @@ secrets_readKeys(const char* path)
errno = 0;
free(keys);
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Failed closing the "
"secrets file %s. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Failed closing the "
"secrets file %s. Error %d, %s.",
secret_file,
eno,
strerror_r(eno, errbuf, sizeof(errbuf)));
return NULL;
}
ss_dassert(keys != NULL);
@ -229,7 +219,7 @@ int secrets_writeKeys(const char *path)
if (strlen(path) > PATH_MAX)
{
skygw_log_write(LOGFILE_ERROR, "Error: Pathname too long.");
MXS_ERROR("Pathname too long.");
return 1;
}
@ -240,12 +230,11 @@ int secrets_writeKeys(const char *path)
if ((fd = open(secret_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR)) < 0)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed opening secret "
"file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("failed opening secret "
"file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
return 1;
}
@ -253,18 +242,16 @@ int secrets_writeKeys(const char *path)
if ((randfd = open("/dev/random", O_RDONLY)) < 0)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed opening /dev/random. Error %d, %s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("failed opening /dev/random. Error %d, %s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
close(fd);
return 1;
}
if (read(randfd, (void*) &randval, sizeof(unsigned int)) < 1)
{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed to read /dev/random.")));
MXS_ERROR("failed to read /dev/random.");
close(fd);
close(randfd);
return 1;
@ -278,12 +265,11 @@ int secrets_writeKeys(const char *path)
if (write(fd, &key, sizeof(key)) < 0)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed writing into "
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("failed writing into "
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
close(fd);
return 1;
}
@ -292,23 +278,21 @@ int secrets_writeKeys(const char *path)
if (close(fd) < 0)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed closing the "
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("failed closing the "
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
}
if (chmod(secret_file, S_IRUSR) < 0)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : failed to change the permissions of the"
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("failed to change the permissions of the"
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
}
return 0;

View File

@ -182,19 +182,17 @@ server_get_persistent(SERVER *server, char *user, const char *protocol)
}
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")));
MXS_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;
@ -725,26 +723,22 @@ server_update(SERVER *server, char *protocol, char *user, char *passwd)
{
if (!strcmp(server->protocol, protocol))
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Update server protocol for server %s to protocol %s.",
server->name,
protocol)));
free(server->protocol);
server->protocol = strdup(protocol);
MXS_NOTICE("Update server protocol for server %s to protocol %s.",
server->name,
protocol);
free(server->protocol);
server->protocol = strdup(protocol);
}
if (user != NULL && passwd != NULL) {
if (strcmp(server->monuser, user) == 0 ||
strcmp(server->monpw, passwd) == 0)
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Update server monitor credentials for server %s",
server->name)));
free(server->monuser);
free(server->monpw);
serverAddMonUser(server, user, passwd);
MXS_NOTICE("Update server monitor credentials for server %s",
server->name);
free(server->monuser);
free(server->monpw);
serverAddMonUser(server, user, passwd);
}
}
}

View File

@ -118,19 +118,17 @@ SERVICE *service;
char* home = get_libdir();
char* ldpath = getenv("LD_LIBRARY_PATH");
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to load %s module \"%s\".\n\t\t\t"
" Ensure that lib%s.so exists in one of the "
"following directories :\n\t\t\t "
"- %s\n%s%s",
MODULE_ROUTER,
router,
router,
home,
ldpath?"\t\t\t - ":"",
ldpath?ldpath:"")));
free(service);
MXS_ERROR("Unable to load %s module \"%s\".\n\t\t\t"
" Ensure that lib%s.so exists in one of the "
"following directories :\n\t\t\t "
"- %s\n%s%s",
MODULE_ROUTER,
router,
router,
home,
ldpath?"\t\t\t - ":"",
ldpath?ldpath:"");
free(service);
return NULL;
}
service->name = strdup(servname);
@ -214,11 +212,8 @@ GWPROTOCOL *funcs;
if (port->listener == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to create listener for service %s.",
service->name)));
goto retblock;
MXS_ERROR("Failed to create listener for service %s.", service->name);
goto retblock;
}
if (strcmp(port->protocol, "MySQLClient") == 0) {
@ -233,13 +228,11 @@ GWPROTOCOL *funcs;
if ((loaded = load_mysql_users(service)) < 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to load users for "
"service %s listening at %s:%d.",
service->name,
(port->address == NULL ? "0.0.0.0" : port->address),
port->port)));
MXS_ERROR("Unable to load users for "
"service %s listening at %s:%d.",
service->name,
(port->address == NULL ? "0.0.0.0" : port->address),
port->port);
{
/* Try loading authentication data from file cache */
@ -251,9 +244,7 @@ GWPROTOCOL *funcs;
loaded = dbusers_load(service->users, path);
if (loaded != -1)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Using cached credential information.")));
MXS_ERROR("Using cached credential information.");
}
}
if (loaded == -1)
@ -283,10 +274,10 @@ GWPROTOCOL *funcs;
if(errno != EEXIST)
{
char errbuf[STRERROR_BUFLEN];
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
path,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to create directory '%s': [%d] %s",
path,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
}
mkdir_rval = 0;
}
@ -302,10 +293,10 @@ GWPROTOCOL *funcs;
if(errno != EEXIST)
{
char errbuf[STRERROR_BUFLEN];
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
path,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
MXS_ERROR("Failed to create directory '%s': [%d] %s",
path,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
}
mkdir_rval = 0;
}
@ -314,12 +305,10 @@ GWPROTOCOL *funcs;
}
if (loaded == 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Service %s: failed to load any user "
"information. Authentication will "
"probably fail as a result.",
service->name)));
MXS_ERROR("Service %s: failed to load any user "
"information. Authentication will "
"probably fail as a result.",
service->name);
}
/* At service start last update is set to USERS_REFRESH_TIME seconds earlier.
@ -328,10 +317,8 @@ GWPROTOCOL *funcs;
service->rate_limit.last=time(NULL) - USERS_REFRESH_TIME;
service->rate_limit.nloads=1;
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Loaded %d MySQL Users for service [%s].",
loaded, service->name)));
MXS_NOTICE("Loaded %d MySQL Users for service [%s].",
loaded, service->name);
}
}
else
@ -350,12 +337,10 @@ GWPROTOCOL *funcs;
dcb_close(port->listener);
service->users = NULL;
port->listener = NULL;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to load protocol module %s. Listener "
"for service %s not started.",
port->protocol,
service->name)));
MXS_ERROR("Unable to load protocol module %s. Listener "
"for service %s not started.",
port->protocol,
service->name);
goto retblock;
}
memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL));
@ -376,10 +361,8 @@ GWPROTOCOL *funcs;
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to create session to service %s.",
service->name)));
MXS_ERROR("Failed to create session to service %s.",
service->name);
users_free(service->users);
service->users = NULL;
@ -391,12 +374,10 @@ GWPROTOCOL *funcs;
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to start to listen port %d for %s %s.",
port->port,
port->protocol,
service->name)));
MXS_ERROR("Unable to start to listen port %d for %s %s.",
port->port,
port->protocol,
service->name);
users_free(service->users);
service->users = NULL;
dcb_close(port->listener);
@ -445,8 +426,8 @@ int serviceStartAllPorts(SERVICE* service)
service->name, service->stats.n_failed_starts);
hktask_oneshot(taskname, service_interal_restart,
(void*) service, retry_after);
skygw_log_write(LM, "Failed to start service %s, retrying in %d seconds.",
service->name, retry_after);
MXS_NOTICE("Failed to start service %s, retrying in %d seconds.",
service->name, retry_after);
}
return listeners;
}
@ -480,25 +461,21 @@ serviceStart(SERVICE *service)
}
else
{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"%s: Failed to create router instance for service. Service not started.",
service->name)));
MXS_ERROR("%s: Failed to create router instance for service. Service not started.",
service->name);
service->state = SERVICE_STATE_FAILED;
}
}
else
{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"%s: SSL initialization failed. Service not started.",
service->name)));
MXS_ERROR("%s: SSL initialization failed. Service not started.", service->name);
service->state = SERVICE_STATE_FAILED;
}
}
else
{
skygw_log_write_flush(LE,
"%s: Error: Inadequate user permissions for service. Service not started.",
service->name);
MXS_ERROR("%s: Inadequate user permissions for service. Service not started.",
service->name);
service->state = SERVICE_STATE_FAILED;
}
return listeners;
@ -546,10 +523,7 @@ int n = 0,i;
if(i == 0)
{
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
"Error : Failed to start service '%s'.",
ptr->name)));
MXS_ERROR("Failed to start service '%s'.", ptr->name);
}
ptr = ptr->next;
@ -922,7 +896,7 @@ serviceOptimizeWildcard(SERVICE *service, int action)
service->optimize_wildcard = action;
if(action)
{
LOGIF(LM,(skygw_log_write(LOGFILE_MESSAGE,"[%s] Optimizing wildcard database grants.",service->name)));
MXS_NOTICE("[%s] Optimizing wildcard database grants.",service->name);
}
return 1;
}
@ -1105,9 +1079,8 @@ int n = 0;
if ((flist = (FILTER_DEF **)malloc(sizeof(FILTER_DEF *))) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Out of memory adding filters to service.\n")));
return;
MXS_ERROR("Out of memory adding filters to service.\n");
return;
}
ptr = strtok_r(filters, "|", &brkt);
while (ptr)
@ -1116,18 +1089,14 @@ int n = 0;
if ((flist = (FILTER_DEF **)realloc(flist,
(n + 1) * sizeof(FILTER_DEF *))) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error : Out of memory adding filters to service.\n")));
return;
MXS_ERROR("Out of memory adding filters to service.");
return;
}
if ((flist[n-1] = filter_find(trim(ptr))) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Warning : Unable to find filter '%s' for service '%s'\n",
trim(ptr), service->name
)));
n--;
MXS_WARNING("Unable to find filter '%s' for service '%s'\n",
trim(ptr), service->name);
n--;
}
flist[n] = NULL;
ptr = strtok_r(NULL, "|", &brkt);
@ -1405,34 +1374,27 @@ void *router_obj;
{
if ((router_obj = load_module(router, MODULE_ROUTER)) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to update router "
"for service %s to %s.",
service->name,
router)));
MXS_ERROR("Failed to update router "
"for service %s to %s.",
service->name,
router);
}
else
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Update router for service %s to %s.",
service->name,
router)));
free(service->routerModule);
service->routerModule = strdup(router);
service->router = router_obj;
MXS_NOTICE("Update router for service %s to %s.",
service->name,
router);
free(service->routerModule);
service->routerModule = strdup(router);
service->router = router_obj;
}
}
if (user &&
(strcmp(service->credentials.name, user) != 0 ||
strcmp(service->credentials.authdata, auth) != 0))
{
LOGIF(LM, (skygw_log_write(
LOGFILE_MESSAGE,
"Update credentials for service %s.",
service->name)));
serviceSetUser(service, user, auth);
MXS_NOTICE("Update credentials for service %s.", service->name);
serviceSetUser(service, user, auth);
}
}
@ -1448,22 +1410,19 @@ int service_refresh_users(SERVICE *service) {
int ret = 1;
/* check for another running getUsers request */
if (! spinlock_acquire_nowait(&service->users_table_spin)) {
LOGIF(LD, (skygw_log_write_flush(
LOGFILE_DEBUG,
"%s: [service_refresh_users] failed to get get lock for loading new users' table: another thread is loading users",
service->name)));
MXS_DEBUG("%s: [service_refresh_users] failed to get get lock for "
"loading new users' table: another thread is loading users",
service->name);
return 1;
return 1;
}
/* check if refresh rate limit has exceeded */
if ( (time(NULL) < (service->rate_limit.last + USERS_REFRESH_TIME)) || (service->rate_limit.nloads > USERS_REFRESH_MAX_PER_TIME)) {
spinlock_release(&service->users_table_spin);
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%s: Refresh rate limit exceeded for load of users' table.",
service->name)));
MXS_ERROR("%s: Refresh rate limit exceeded for load of users' table.",
service->name);
return 1;
}
@ -2046,7 +2005,7 @@ int serviceInitSSL(SERVICE* service)
if((service->ctx = SSL_CTX_new(service->method)) == NULL)
{
skygw_log_write(LE, "Error: SSL context initialization failed.");
MXS_ERROR("SSL context initialization failed.");
return -1;
}
@ -2059,7 +2018,7 @@ int serviceInitSSL(SERVICE* service)
rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL);
if (rsa_512 == NULL)
{
skygw_log_write(LE,"Error: 512-bit RSA key generation failed.");
MXS_ERROR("512-bit RSA key generation failed.");
return -1;
}
}
@ -2068,7 +2027,7 @@ int serviceInitSSL(SERVICE* service)
rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL);
if (rsa_1024 == NULL)
{
skygw_log_write(LE,"Error: 1024-bit RSA key generation failed.");
MXS_ERROR("1024-bit RSA key generation failed.");
return -1;
}
}
@ -2078,26 +2037,26 @@ int serviceInitSSL(SERVICE* service)
/** Load the server sertificate */
if (SSL_CTX_use_certificate_file(service->ctx, service->ssl_cert, SSL_FILETYPE_PEM) <= 0) {
skygw_log_write(LE,"Error: Failed to set server SSL certificate.");
MXS_ERROR("Failed to set server SSL certificate.");
return -1;
}
/* Load the private-key corresponding to the server certificate */
if (SSL_CTX_use_PrivateKey_file(service->ctx, service->ssl_key, SSL_FILETYPE_PEM) <= 0) {
skygw_log_write(LE,"Error: Failed to set server SSL key.");
MXS_ERROR("Failed to set server SSL key.");
return -1;
}
/* Check if the server certificate and private-key matches */
if (!SSL_CTX_check_private_key(service->ctx)) {
skygw_log_write(LE,"Error: Server SSL certificate and key do not match.");
MXS_ERROR("Server SSL certificate and key do not match.");
return -1;
}
/* Load the RSA CA certificate into the SSL_CTX structure */
if (!SSL_CTX_load_verify_locations(service->ctx, service->ssl_ca_cert, NULL)) {
skygw_log_write(LE,"Error: Failed to set Certificate Authority file.");
MXS_ERROR("Failed to set Certificate Authority file.");
return -1;
}

View File

@ -79,12 +79,10 @@ session_alloc(SERVICE *service, DCB *client_dcb)
if (session == NULL)
{
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to allocate memory for "
"session object due error %d, %s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Failed to allocate memory for "
"session object due error %d, %s.",
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
/* Does this possibly need a lock? */
/*
* This is really not the right way to do this. The data in a DCB is
@ -149,13 +147,11 @@ session_alloc(SERVICE *service, DCB *client_dcb)
{
session->state = SESSION_STATE_TO_BE_FREED;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [%s] Error : Failed to create %s session because router"
"could not establish a new router session, see earlier error.",
pthread_self(),
__func__,
service->name)));
MXS_ERROR("%lu [%s] Error : Failed to create %s session because router"
"could not establish a new router session, see earlier error.",
pthread_self(),
__func__,
service->name);
}
/*
@ -181,11 +177,9 @@ session_alloc(SERVICE *service, DCB *client_dcb)
&& !session_setup_filters(session))
{
session->state = SESSION_STATE_TO_BE_FREED;
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
"Error : Setting up filters failed. "
"Terminating session %s.",
service->name)));
MXS_ERROR("Setting up filters failed. "
"Terminating session %s.",
service->name);
}
}
@ -195,33 +189,27 @@ session_alloc(SERVICE *service, DCB *client_dcb)
if (session->client->user == NULL)
{
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Started session [%lu] for %s service ",
session->ses_id,
service->name)));
MXS_INFO("Started session [%lu] for %s service ",
session->ses_id,
service->name);
}
else
{
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Started %s client session [%lu] for '%s' from %s",
service->name,
session->ses_id,
session->client->user,
session->client->remote)));
MXS_INFO("Started %s client session [%lu] for '%s' from %s",
service->name,
session->ses_id,
session->client->user,
session->client->remote);
}
}
else
{
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Start %s client session [%lu] for '%s' from %s failed, will be "
"closed as soon as all related DCBs have been closed.",
service->name,
session->ses_id,
session->client->user,
session->client->remote)));
MXS_INFO("Start %s client session [%lu] for '%s' from %s failed, will be "
"closed as soon as all related DCBs have been closed.",
service->name,
session->ses_id,
session->client->user,
session->client->remote);
}
spinlock_acquire(&session_spin);
/** Assign a session id and increase, insert session into list */
@ -480,11 +468,9 @@ session_free(SESSION *session)
free(session->filters);
}
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Stopped %s client session [%lu]",
session->service->name,
session->ses_id)));
MXS_INFO("Stopped %s client session [%lu]",
session->service->name,
session->ses_id);
/** Disable trace and decrease trace logger counter */
session_disable_log(session, LT);
@ -845,33 +831,26 @@ int i;
if ((session->filters = calloc(service->n_filters,
sizeof(SESSION_FILTER))) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Insufficient memory to allocate session filter "
"tracking.\n")));
return 0;
MXS_ERROR("Insufficient memory to allocate session filter "
"tracking.\n");
return 0;
}
session->n_filters = service->n_filters;
for (i = service->n_filters - 1; i >= 0; i--)
{
if (service->filters[i] == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Service '%s' contians an unresolved filter.\n",
service->name)));
return 0;
MXS_ERROR("Service '%s' contians an unresolved filter.", service->name);
return 0;
}
if ((head = filterApply(service->filters[i], session,
&session->head)) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to create filter '%s' for "
"service '%s'.\n",
service->filters[i]->name,
service->name)));
return 0;
MXS_ERROR("Failed to create filter '%s' for "
"service '%s'.\n",
service->filters[i]->name,
service->name);
return 0;
}
session->filters[i].filter = service->filters[i];
session->filters[i].session = head->session;
@ -886,12 +865,10 @@ int i;
session->filters[i].session,
&session->tail)) == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Failed to create filter '%s' for service '%s'.\n",
service->filters[i]->name,
service->name)));
return 0;
MXS_ERROR("Failed to create filter '%s' for service '%s'.",
service->filters[i]->name,
service->name);
return 0;
}
/*

View File

@ -49,13 +49,13 @@ USERS *rval;
if ((rval = calloc(1, sizeof(USERS))) == NULL)
{
skygw_log_write(LE,"[%s:%d] Error: Memory allocation failed.",__FUNCTION__,__LINE__);
MXS_ERROR("[%s:%d]: Memory allocation failed.", __FUNCTION__, __LINE__);
return NULL;
}
if ((rval->data = hashtable_alloc(USERS_HASHTABLE_DEFAULT_SIZE, simple_str_hash, strcmp)) == NULL)
{
skygw_log_write(LE,"[%s:%d] Error: Memory allocation failed.",__FUNCTION__,__LINE__);
MXS_ERROR("[%s:%d]: Memory allocation failed.", __FUNCTION__, __LINE__);
free(rval);
return NULL;
}
@ -75,7 +75,7 @@ users_free(USERS *users)
{
if(users == NULL)
{
skygw_log_write(LE,"[%s:%d] Error: NULL parameter.",__FUNCTION__,__LINE__);
MXS_ERROR("[%s:%d]: NULL parameter.", __FUNCTION__, __LINE__);
return;
}

View File

@ -65,23 +65,19 @@ int setnonblocking(int fd) {
if ((fl = fcntl(fd, F_GETFL, 0)) == -1) {
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Can't GET fcntl for %i, errno = %d, %s.",
fd,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Can't GET fcntl for %i, errno = %d, %s.",
fd,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
return 1;
}
if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) {
char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Can't SET fcntl for %i, errno = %d, %s",
fd,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
MXS_ERROR("Can't SET fcntl for %i, errno = %d, %s",
fd,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)));
return 1;
}
return 0;