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:
@ -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,18 +210,13 @@ 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)));
|
||||
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.")));
|
||||
MXS_ERROR("Authentication failed, wrong user/password "
|
||||
"combination. Removing user failed.");
|
||||
return ADMIN_ERR_AUTHENTICATION;
|
||||
}
|
||||
|
||||
@ -239,10 +225,8 @@ 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.")));
|
||||
MXS_ERROR("Deleting the only user is forbidden. Add new "
|
||||
"user before deleting the one.");
|
||||
return ADMIN_ERR_DELLASTUSER;
|
||||
}
|
||||
/**
|
||||
@ -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"
|
||||
MXS_ERROR("Unable to open password file %s : errno %d.\n"
|
||||
"Removing user from file failed; it must be done "
|
||||
"manually.",
|
||||
fname,
|
||||
err)));
|
||||
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"
|
||||
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)));
|
||||
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"
|
||||
MXS_ERROR("Unable to process passwd file %s : errno %d.\n"
|
||||
"Removing user from file failed, and must be done "
|
||||
"manually.",
|
||||
fname,
|
||||
err)));
|
||||
err);
|
||||
fclose(fp);
|
||||
fclose(fp_tmp);
|
||||
unlink(fname_tmp);
|
||||
@ -310,10 +288,7 @@ char* admin_remove_user(
|
||||
*/
|
||||
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. ")));
|
||||
|
||||
MXS_ERROR("Unable to set stream position. ");
|
||||
}
|
||||
fgets(line, LINELEN, fp);
|
||||
fputs(line, fp_tmp);
|
||||
@ -321,14 +296,12 @@ 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 : "
|
||||
MXS_ERROR("Unable to process passwd file %s : "
|
||||
"errno %d.\n"
|
||||
"Removing user from file failed, and must be "
|
||||
"done manually.",
|
||||
fname,
|
||||
err)));
|
||||
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 "
|
||||
MXS_ERROR("Unable to rename new passwd file %s : errno "
|
||||
"%d.\n"
|
||||
"Rename it to %s manually.",
|
||||
fname_tmp,
|
||||
err,
|
||||
fname)));
|
||||
fname);
|
||||
unlink(fname_tmp);
|
||||
fclose(fp_tmp);
|
||||
return ADMIN_ERR_PWDFILEACCESS;
|
||||
|
@ -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);
|
||||
|
@ -152,7 +152,7 @@ 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",
|
||||
MXS_ERROR("[%s] Regular expression compilation failed at %d: %s",
|
||||
__FUNCTION__, err_offset, errbuf);
|
||||
pcre2_code_free(re);
|
||||
free(dest);
|
||||
@ -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 "
|
||||
MXS_ERROR("Reading configuration "
|
||||
"for router service '%s' failed. "
|
||||
"Router %s is not loaded.",
|
||||
obj->object,
|
||||
obj->object)));
|
||||
obj->object);
|
||||
obj = obj->next;
|
||||
continue; /*< process next obj */
|
||||
}
|
||||
@ -584,7 +579,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
if (ssl_cert == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE, "Error: Server certificate missing for service '%s'."
|
||||
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);
|
||||
}
|
||||
@ -592,7 +587,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
if (ssl_ca_cert == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE, "Error: CA Certificate missing for service '%s'."
|
||||
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);
|
||||
@ -601,7 +596,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
if (ssl_key == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE, "Error: Server private key missing for service '%s'. "
|
||||
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);
|
||||
@ -609,7 +604,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
|
||||
if (access(ssl_ca_cert, F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE, "Error: Certificate authority file for service '%s' "
|
||||
MXS_ERROR("Certificate authority file for service '%s' "
|
||||
"not found: %s",
|
||||
obj->object, ssl_ca_cert);
|
||||
error_count++;
|
||||
@ -617,7 +612,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
|
||||
if (access(ssl_cert, F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE, "Error: Server certificate file for service '%s' not found: %s",
|
||||
MXS_ERROR("Server certificate file for service '%s' not found: %s",
|
||||
obj->object,
|
||||
ssl_cert);
|
||||
error_count++;
|
||||
@ -625,7 +620,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
|
||||
if (access(ssl_key, F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE, "Error: Server private key file for service '%s' not found: %s",
|
||||
MXS_ERROR("Server private key file for service '%s' not found: %s",
|
||||
obj->object,
|
||||
ssl_key);
|
||||
error_count++;
|
||||
@ -635,7 +630,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
{
|
||||
if (serviceSetSSL(obj->element, ssl) != 0)
|
||||
{
|
||||
skygw_log_write(LE, "Error: Unknown parameter for service '%s': %s",
|
||||
MXS_ERROR("Unknown parameter for service '%s': %s",
|
||||
obj->object, ssl);
|
||||
error_count++;
|
||||
}
|
||||
@ -646,7 +641,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
{
|
||||
if (serviceSetSSLVersion(obj->element, ssl_version) != 0)
|
||||
{
|
||||
skygw_log_write(LE, "Error: Unknown parameter value for "
|
||||
MXS_ERROR("Unknown parameter value for "
|
||||
"'ssl_version' for service '%s': %s",
|
||||
obj->object, ssl_version);
|
||||
error_count++;
|
||||
@ -656,7 +651,7 @@ 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 "
|
||||
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 "
|
||||
MXS_ERROR("Service '%s' has a "
|
||||
"user defined but no "
|
||||
"corresponding password.",
|
||||
obj->object)));
|
||||
obj->object);
|
||||
}
|
||||
/** Read, validate and set max_slave_connections */
|
||||
if (max_slave_conn_str != NULL)
|
||||
@ -747,9 +740,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"* Warning : invalid value type "
|
||||
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 "
|
||||
@ -757,7 +748,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
"slaves that will be connected.",
|
||||
((SERVICE*)obj->element)->name,
|
||||
param->name,
|
||||
param->value)));
|
||||
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 "
|
||||
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)));
|
||||
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 "
|
||||
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)));
|
||||
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 "
|
||||
MXS_ERROR("Server '%s' is missing a "
|
||||
"required configuration parameter. A "
|
||||
"server must "
|
||||
"have address, port and protocol "
|
||||
"defined.",
|
||||
obj->object)));
|
||||
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"
|
||||
MXS_ERROR("Server '%s' has a monitoruser"
|
||||
"defined but no corresponding password.",
|
||||
obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("Filter '%s' has no module "
|
||||
"defined defined to load.",
|
||||
obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("Unable to find "
|
||||
"server '%s' that is "
|
||||
"configured as part of "
|
||||
"service '%s'.",
|
||||
s, obj->object)));
|
||||
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 "
|
||||
MXS_WARNING("The service '%s' is missing a "
|
||||
"definition of the servers that provide "
|
||||
"the service.",
|
||||
obj->object)));
|
||||
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', "
|
||||
MXS_ERROR("Listener '%s', "
|
||||
"service '%s' not found. "
|
||||
"Listener will not execute for socket %s.",
|
||||
obj->object, service, socket)));
|
||||
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', "
|
||||
MXS_ERROR("Listener '%s', "
|
||||
"service '%s' not found. "
|
||||
"Listener will not execute.",
|
||||
obj->object, service)));
|
||||
obj->object, service);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Listener '%s' is missing a "
|
||||
MXS_ERROR("Listener '%s' is missing a "
|
||||
"required "
|
||||
"parameter. A Listener must have a "
|
||||
"service, port and protocol defined.",
|
||||
obj->object)));
|
||||
obj->object);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
@ -1200,7 +1165,7 @@ process_config_context(CONFIG_CONTEXT *context)
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR, "Warning: Monitor '%s' "
|
||||
MXS_WARNING("Monitor '%s' "
|
||||
"missing monitor_interval parameter, "
|
||||
"default value of 10000 miliseconds.", obj->object);
|
||||
}
|
||||
@ -1232,8 +1197,7 @@ 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]. "
|
||||
MXS_WARNING("Multiple monitors are monitoring server [%s]. "
|
||||
"This will cause undefined behavior.",
|
||||
obj1->object);
|
||||
}
|
||||
@ -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 "
|
||||
MXS_ERROR("Monitor '%s' defines a "
|
||||
"username with no password.",
|
||||
obj->object)));
|
||||
obj->object);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->element = NULL;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Monitor '%s' is missing a "
|
||||
MXS_ERROR("Monitor '%s' is missing a "
|
||||
"require module parameter.",
|
||||
obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("Configuration object '%s' has an "
|
||||
"invalid type specified.",
|
||||
obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("%d errors where encountered processing the "
|
||||
"configuration file '%s'.",
|
||||
error_count,
|
||||
config_file)));
|
||||
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,9 +1912,7 @@ process_config_update(CONFIG_CONTEXT *context)
|
||||
|
||||
if (!succp && param != NULL)
|
||||
{
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"* Warning : invalid value type "
|
||||
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 "
|
||||
@ -1973,7 +1920,7 @@ process_config_update(CONFIG_CONTEXT *context)
|
||||
"slaves that will be connected.",
|
||||
((SERVICE*)obj->element)->name,
|
||||
param->name,
|
||||
param->value)));
|
||||
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 "
|
||||
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)));
|
||||
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 "
|
||||
MXS_ERROR("Server '%s' is missing a "
|
||||
"required "
|
||||
"configuration parameter. A server must "
|
||||
"have address, port and protocol "
|
||||
"defined.",
|
||||
obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("Unable to find "
|
||||
"server '%s' that is "
|
||||
"configured as part of "
|
||||
"service '%s'.",
|
||||
s, obj->object)));
|
||||
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 "
|
||||
MXS_ERROR("Unexpected parameter "
|
||||
"'%s' for object '%s' of type "
|
||||
"'%s'.",
|
||||
params->name,
|
||||
obj->object,
|
||||
type)));
|
||||
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, "
|
||||
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)));
|
||||
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"
|
||||
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" : "")));
|
||||
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,14 +2792,14 @@ 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,
|
||||
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"
|
||||
MXS_ERROR("Failed to allocate enough memory when checking"
|
||||
" for duplicate sections in configuration file.");
|
||||
rval = true;
|
||||
}
|
||||
@ -2926,7 +2849,7 @@ int maxscale_getline(char** dest, int* size, FILE* file)
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE, "Error: Failed to reallocate memory from %d"
|
||||
MXS_ERROR("Failed to reallocate memory from %d"
|
||||
" bytes to %d bytes when reading from file.",
|
||||
*size, *size * 2);
|
||||
destptr[offset - 1] = '\0';
|
||||
|
@ -288,20 +288,16 @@ HASHTABLE *oldresources;
|
||||
/* digest compare */
|
||||
if (oldusers != NULL && memcmp(oldusers->cksum, newusers->cksum, SHA_DIGEST_LENGTH) == 0) {
|
||||
/* same data, nothing to do */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [replace_mysql_users] users' tables not switched, checksum is the same",
|
||||
pthread_self())));
|
||||
MXS_DEBUG("%lu [replace_mysql_users] users' tables not switched, checksum is the same",
|
||||
pthread_self());
|
||||
|
||||
/* free the new table */
|
||||
users_free(newusers);
|
||||
i = 0;
|
||||
} else {
|
||||
/* replace the service with effective new data */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [replace_mysql_users] users' tables replaced, checksum differs",
|
||||
pthread_self())));
|
||||
MXS_DEBUG("%lu [replace_mysql_users] users' tables replaced, checksum differs",
|
||||
pthread_self());
|
||||
service->users = newusers;
|
||||
}
|
||||
|
||||
@ -432,11 +428,7 @@ int add_mysql_users_with_host_ipv4(USERS *users, char *user, char *host, char *p
|
||||
key.netmask = normalize_hostname(host, ret_ip);
|
||||
|
||||
if (key.netmask == -1) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : strdup() failed in normalize_hostname for %s@%s",
|
||||
user,
|
||||
host)));
|
||||
MXS_ERROR("strdup() failed in normalize_hostname for %s@%s", user, host);
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,24 +486,20 @@ addDatabases(SERVICE *service, MYSQL *con)
|
||||
return -1;
|
||||
|
||||
if (mysql_query(con, get_showdbs_priv_query)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -523,10 +511,7 @@ addDatabases(SERVICE *service, MYSQL *con)
|
||||
} else {
|
||||
ndbs = 0;
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
ERROR_NO_SHOW_DATABASES,
|
||||
service->name, service_user)));
|
||||
MXS_ERROR(ERROR_NO_SHOW_DATABASES, service->name, service_user);
|
||||
}
|
||||
|
||||
/* free resut set */
|
||||
@ -538,12 +523,10 @@ addDatabases(SERVICE *service, MYSQL *con)
|
||||
}
|
||||
|
||||
if (mysql_query(con, "SHOW DATABASES")) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -551,12 +534,10 @@ addDatabases(SERVICE *service, MYSQL *con)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -565,7 +546,7 @@ addDatabases(SERVICE *service, MYSQL *con)
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
if(resource_add(service->resources, row[0], ""))
|
||||
{
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding database %s to the resouce hash.",service->name,row[0]);
|
||||
MXS_DEBUG("%s: Adding database %s to the resouce hash.", service->name, row[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,24 +580,20 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
return -1;
|
||||
|
||||
if (mysql_query(con, get_showdbs_priv_query)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error when querying database privileges: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error when storing result set of database privilege query: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -628,10 +605,7 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
} else {
|
||||
ndbs = 0;
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
ERROR_NO_SHOW_DATABASES,
|
||||
service->name, service_user)));
|
||||
MXS_ERROR(ERROR_NO_SHOW_DATABASES, service->name, service_user);
|
||||
}
|
||||
|
||||
/* free resut set */
|
||||
@ -643,12 +617,10 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
}
|
||||
|
||||
if (mysql_query(con, "SHOW DATABASES")) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error when executing SHOW DATABASES query: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -656,12 +628,10 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading database names for service %s encountered "
|
||||
MXS_ERROR("Loading database names for service %s encountered "
|
||||
"error when storing the result set: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -671,7 +641,7 @@ getDatabases(SERVICE *service, MYSQL *con)
|
||||
|
||||
/* insert key and value "" */
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding database %s to the resouce hash.",service->name,row[0]);
|
||||
MXS_DEBUG("%s: Adding database %s to the resouce hash.", service->name, row[0]);
|
||||
resource_add(service->resources, row[0], "");
|
||||
}
|
||||
|
||||
@ -752,30 +722,22 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (con == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : mysql_init: %s",
|
||||
mysql_error(con))));
|
||||
MXS_ERROR("mysql_init: %s", mysql_error(con));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set timeout values for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set timeout values for backend connection.");
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (mysql_options(con, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set external connection. "
|
||||
"It is needed for backend server connections.")));
|
||||
MXS_ERROR("Failed to set external connection. "
|
||||
"It is needed for backend server connections.");
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -798,11 +760,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (server == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to get user data from backend database "
|
||||
MXS_ERROR("Unable to get user data from backend database "
|
||||
"for service [%s]. Missing server information.",
|
||||
service->name)));
|
||||
service->name);
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -821,30 +781,22 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (con == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : mysql_init: %s",
|
||||
mysql_error(con))));
|
||||
MXS_ERROR("mysql_init: %s", mysql_error(con));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set timeout values for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set timeout values for backend connection.");
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (mysql_options(con, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set external connection. "
|
||||
"It is needed for backend server connections.")));
|
||||
MXS_ERROR("Failed to set external connection. "
|
||||
"It is needed for backend server connections.");
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -867,11 +819,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (server == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to get user data from backend database "
|
||||
MXS_ERROR("Unable to get user data from backend database "
|
||||
"for service [%s]. Missing server information.",
|
||||
service->name)));
|
||||
service->name);
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -890,12 +840,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
if (mysql_query(con, user_with_db_count)) {
|
||||
if (mysql_errno(con) != ER_TABLEACCESS_DENIED_ERROR) {
|
||||
/* This is an error we cannot handle, return */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
} else {
|
||||
@ -904,12 +851,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
* try counting users from mysql.user without DB names.
|
||||
*/
|
||||
if (mysql_query(con, MYSQL_USERS_COUNT)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -919,12 +863,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -936,10 +877,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
mysql_free_result(result);
|
||||
|
||||
if (!nusers) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Counting users for service %s returned 0",
|
||||
service->name)));
|
||||
MXS_ERROR("Counting users for service %s returned 0.", service->name);
|
||||
mysql_close(con);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -959,13 +897,11 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
if (1142 != mysql_errno(con)) {
|
||||
/* This is an error we cannot handle, return */
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users with dbnames for service [%s] encountered "
|
||||
MXS_ERROR("Loading users with dbnames for service [%s] encountered "
|
||||
"error: [%s], MySQL errno %i",
|
||||
service->name,
|
||||
mysql_error(con),
|
||||
mysql_errno(con))));
|
||||
mysql_errno(con));
|
||||
|
||||
mysql_close(con);
|
||||
|
||||
@ -976,10 +912,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
* try loading users from mysql.user without DB names.
|
||||
*/
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
ERROR_NO_SHOW_DATABASES,
|
||||
service->name, service_user)));
|
||||
MXS_ERROR(ERROR_NO_SHOW_DATABASES, service->name, service_user);
|
||||
|
||||
/* check for root user select */
|
||||
if(service->enable_root) {
|
||||
@ -989,13 +922,11 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
|
||||
if (mysql_query(con, users_query)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
MXS_ERROR("Loading users for service [%s] encountered "
|
||||
"error: [%s], code %i",
|
||||
service->name,
|
||||
mysql_error(con),
|
||||
mysql_errno(con))));
|
||||
mysql_errno(con));
|
||||
|
||||
mysql_close(con);
|
||||
|
||||
@ -1004,30 +935,25 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
/* users successfully loaded but without db grants */
|
||||
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Loading users from [mysql.user] without access to [mysql.db] for "
|
||||
MXS_NOTICE("Loading users from [mysql.user] without access to [mysql.db] for "
|
||||
"service [%s]. MaxScale Authentication with DBname on connect "
|
||||
"will not consider database grants.",
|
||||
service->name)));
|
||||
service->name);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* users successfully loaded with db grants.
|
||||
*/
|
||||
skygw_log_write(LOGFILE_DEBUG,"[%s] Loading users with db grants.",service->name);
|
||||
MXS_DEBUG("[%s] Loading users with db grants.",service->name);
|
||||
db_grants = 1;
|
||||
}
|
||||
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service %s encountered "
|
||||
"error: %s.",
|
||||
MXS_ERROR("Loading users for service %s encountered error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
@ -1039,12 +965,9 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
MXS_ERROR("Memory allocation for user data failed due to %d, %s.",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
@ -1074,16 +997,14 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
if (row[2] != NULL) {
|
||||
/* detect mysql_old_password (pre 4.1 protocol) */
|
||||
if (strlen(row[2]) == 16) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%s: The user %s@%s has on old password in the "
|
||||
MXS_ERROR("%s: The user %s@%s has on old password in the "
|
||||
"backend database. MaxScale does not support these "
|
||||
"old passwords. This user will not be able to connect "
|
||||
"via MaxScale. Update the users password to correct "
|
||||
"this.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1])));
|
||||
row[1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1107,28 +1028,26 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
havedb = true;
|
||||
if(service->strip_db_esc) {
|
||||
strip_escape_chars(dbnm);
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"[%s]: %s -> %s",
|
||||
MXS_DEBUG("[%s]: %s -> %s",
|
||||
service->name,
|
||||
row[5],
|
||||
dbnm)));
|
||||
dbnm);
|
||||
}
|
||||
}
|
||||
|
||||
if(havedb && wildcard_db_grant(dbnm) && service->optimize_wildcard)
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,dbnm,rc);
|
||||
MXS_INFO("%s: Converted '%s' to %d individual database grants.",service->name,dbnm,rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, row[4], havedb ? dbnm : NULL);
|
||||
}
|
||||
|
||||
LOGIF(LD,(skygw_log_write(LOGFILE_DEBUG,"%s: Adding user:%s host:%s anydb:%s db:%s.",
|
||||
MXS_DEBUG("%s: Adding user:%s host:%s anydb:%s db:%s.",
|
||||
service->name,row[0],row[1],row[4],
|
||||
havedb ? dbnm : NULL)));
|
||||
havedb ? dbnm : NULL);
|
||||
} else {
|
||||
/* we don't have dbgrants, simply set ANY DB for the user */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, "Y", NULL);
|
||||
@ -1150,22 +1069,17 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
strcpy(dbgrant, "no db");
|
||||
|
||||
/* Log the user being added with its db grants */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG|LOGFILE_TRACE,
|
||||
"%s: User %s@%s for database %s added to "
|
||||
"service user table.",
|
||||
MXS_INFO("%s: User %s@%s for database %s added to service user table.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1],
|
||||
dbgrant)));
|
||||
dbgrant);
|
||||
} else {
|
||||
/* Log the user being added (without db grants) */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG|LOGFILE_TRACE,
|
||||
"%s: User %s@%s added to service user table.",
|
||||
MXS_INFO("%s: User %s@%s added to service user table.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1])));
|
||||
row[1]);
|
||||
}
|
||||
|
||||
/* Append data in the memory area for SHA1 digest */
|
||||
@ -1177,7 +1091,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
/** Duplicate user*/
|
||||
if (service->log_auth_warnings)
|
||||
{
|
||||
skygw_log_write(LM, "Duplicate MySQL user found for service"
|
||||
MXS_NOTICE("Duplicate MySQL user found for service"
|
||||
" [%s]: %s@%s%s%s", service->name, row[0],
|
||||
row[1], havedb ? " for database: " : "",
|
||||
havedb ? dbnm : "");
|
||||
@ -1185,7 +1099,7 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
} else {
|
||||
if (service->log_auth_warnings)
|
||||
{
|
||||
skygw_log_write_flush(LM, "Warning: Failed to add user %s@%s"
|
||||
MXS_NOTICE("Warning: Failed to add user %s@%s"
|
||||
" for service [%s]. This user will be "
|
||||
"unavailable via MaxScale.", row[0],
|
||||
row[1], service->name);
|
||||
@ -1282,28 +1196,20 @@ getUsers(SERVICE *service, USERS *users)
|
||||
con = mysql_init(NULL);
|
||||
|
||||
if (con == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : mysql_init: %s",
|
||||
mysql_error(con))));
|
||||
MXS_ERROR("mysql_init: %s", mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
/** Set read, write and connect timeout values */
|
||||
if (gw_mysql_set_timeouts(con))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set timeout values for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set timeout values for backend connection.");
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mysql_options(con, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set external connection. "
|
||||
"It is needed for backend server connections.")));
|
||||
MXS_ERROR("Failed to set external connection. "
|
||||
"It is needed for backend server connections.");
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -1336,13 +1242,11 @@ getUsers(SERVICE *service, USERS *users)
|
||||
server->server->port,
|
||||
NULL, 0) != NULL))
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"Dbusers : Loading data from backend database with "
|
||||
MXS_DEBUG("Dbusers : Loading data from backend database with "
|
||||
"Master role [%s:%i] for service [%s]",
|
||||
server->server->name,
|
||||
server->server->port,
|
||||
service->name)));
|
||||
service->name);
|
||||
} else {
|
||||
/* load data from other servers via loop */
|
||||
server = service->dbref;
|
||||
@ -1358,15 +1262,13 @@ getUsers(SERVICE *service, USERS *users)
|
||||
NULL,
|
||||
0) == NULL))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failure loading users data from backend "
|
||||
MXS_ERROR("Failure loading users data from backend "
|
||||
"[%s:%i] for service [%s]. MySQL error %i, %s",
|
||||
server->server->name,
|
||||
server->server->port,
|
||||
service->name,
|
||||
mysql_errno(con),
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
server = server->next;
|
||||
}
|
||||
@ -1379,13 +1281,11 @@ getUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
|
||||
if (server != NULL) {
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"Dbusers : Loading data from backend database "
|
||||
MXS_DEBUG("Loading data from backend database "
|
||||
"[%s:%i] for service [%s]",
|
||||
server->server->name,
|
||||
server->server->port,
|
||||
service->name)));
|
||||
service->name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1393,11 +1293,9 @@ getUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (server == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to get user data from backend database "
|
||||
MXS_ERROR("Unable to get user data from backend database "
|
||||
"for service [%s]. Failed to connect to any of the backend databases.",
|
||||
service->name)));
|
||||
service->name);
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -1417,12 +1315,9 @@ getUsers(SERVICE *service, USERS *users)
|
||||
if (mysql_query(con, user_with_db_count)) {
|
||||
if (mysql_errno(con) != ER_TABLEACCESS_DENIED_ERROR) {
|
||||
/* This is an error we cannot handle, return */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
} else {
|
||||
@ -1431,12 +1326,9 @@ getUsers(SERVICE *service, USERS *users)
|
||||
* try counting users from mysql.user without DB names.
|
||||
*/
|
||||
if (mysql_query(con, MYSQL_USERS_COUNT)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -1446,12 +1338,9 @@ getUsers(SERVICE *service, USERS *users)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
"error: [%s].",
|
||||
MXS_ERROR("Loading users for service [%s] encountered error: [%s].",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -1463,10 +1352,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
mysql_free_result(result);
|
||||
|
||||
if (!nusers) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Counting users for service %s returned 0",
|
||||
service->name)));
|
||||
MXS_ERROR("Counting users for service %s returned 0.", service->name);
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -1484,16 +1370,13 @@ getUsers(SERVICE *service, USERS *users)
|
||||
if (1142 != mysql_errno(con)) {
|
||||
/* This is an error we cannot handle, return */
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users with dbnames for service [%s] encountered "
|
||||
MXS_ERROR("Loading users with dbnames for service [%s] encountered "
|
||||
"error: [%s], MySQL errno %i",
|
||||
service->name,
|
||||
mysql_error(con),
|
||||
mysql_errno(con))));
|
||||
mysql_errno(con));
|
||||
|
||||
mysql_close(con);
|
||||
|
||||
return -1;
|
||||
} else {
|
||||
/*
|
||||
@ -1501,10 +1384,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
* try loading users from mysql.user without DB names.
|
||||
*/
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
ERROR_NO_SHOW_DATABASES,
|
||||
service->name, service_user)));
|
||||
MXS_ERROR(ERROR_NO_SHOW_DATABASES, service->name, service_user);
|
||||
|
||||
/* check for root user select */
|
||||
if(service->enable_root) {
|
||||
@ -1514,27 +1394,22 @@ getUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
|
||||
if (mysql_query(con, users_query)) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service [%s] encountered "
|
||||
MXS_ERROR("Loading users for service [%s] encountered "
|
||||
"error: [%s], code %i",
|
||||
service->name,
|
||||
mysql_error(con),
|
||||
mysql_errno(con))));
|
||||
mysql_errno(con));
|
||||
|
||||
mysql_close(con);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* users successfully loaded but without db grants */
|
||||
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Loading users from [mysql.user] without access to [mysql.db] for "
|
||||
MXS_NOTICE("Loading users from [mysql.user] without access to [mysql.db] for "
|
||||
"service [%s]. MaxScale Authentication with DBname on connect "
|
||||
"will not consider database grants.",
|
||||
service->name)));
|
||||
service->name);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -1547,16 +1422,12 @@ getUsers(SERVICE *service, USERS *users)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Loading users for service %s encountered "
|
||||
"error: %s.",
|
||||
MXS_ERROR("Loading users for service %s encountered error: %s.",
|
||||
service->name,
|
||||
mysql_error(con))));
|
||||
mysql_error(con));
|
||||
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1564,15 +1435,11 @@ getUsers(SERVICE *service, USERS *users)
|
||||
|
||||
if (users_data == NULL) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Memory allocation for user data failed due to "
|
||||
"%d, %s.",
|
||||
MXS_ERROR("Memory allocation for user data failed due to %d, %s.",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
mysql_free_result(result);
|
||||
mysql_close(con);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1580,11 +1447,9 @@ getUsers(SERVICE *service, USERS *users)
|
||||
/* load all mysql database names */
|
||||
dbnames = getDatabases(service, con);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"Loaded %d MySQL Database Names for service [%s]",
|
||||
MXS_DEBUG("Loaded %d MySQL Database Names for service [%s]",
|
||||
dbnames,
|
||||
service->name)));
|
||||
service->name);
|
||||
} else {
|
||||
service->resources = NULL;
|
||||
}
|
||||
@ -1612,16 +1477,14 @@ getUsers(SERVICE *service, USERS *users)
|
||||
if (row[2] != NULL) {
|
||||
/* detect mysql_old_password (pre 4.1 protocol) */
|
||||
if (strlen(row[2]) == 16) {
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%s: The user %s@%s has on old password in the "
|
||||
MXS_ERROR("%s: The user %s@%s has on old password in the "
|
||||
"backend database. MaxScale does not support these "
|
||||
"old passwords. This user will not be able to connect "
|
||||
"via MaxScale. Update the users password to correct "
|
||||
"this.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1])));
|
||||
row[1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1645,12 +1508,10 @@ getUsers(SERVICE *service, USERS *users)
|
||||
havedb = true;
|
||||
if(service->strip_db_esc) {
|
||||
strip_escape_chars(dbnm);
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"[%s]: %s -> %s",
|
||||
MXS_DEBUG("[%s]: %s -> %s",
|
||||
service->name,
|
||||
row[5],
|
||||
dbnm)));
|
||||
dbnm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1659,7 +1520,8 @@ getUsers(SERVICE *service, USERS *users)
|
||||
if(service->optimize_wildcard)
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,row[5],rc);
|
||||
MXS_INFO("%s: Converted '%s' to %d individual database grants.",
|
||||
service->name, row[5], rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1693,22 +1555,18 @@ getUsers(SERVICE *service, USERS *users)
|
||||
strcpy(dbgrant, "no db");
|
||||
|
||||
/* Log the user being added with its db grants */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG|LOGFILE_TRACE,
|
||||
"%s: User %s@%s for database %s added to "
|
||||
MXS_INFO("%s: User %s@%s for database %s added to "
|
||||
"service user table.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1],
|
||||
dbgrant)));
|
||||
dbgrant);
|
||||
} else {
|
||||
/* Log the user being added (without db grants) */
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG|LOGFILE_TRACE,
|
||||
"%s: User %s@%s added to service user table.",
|
||||
MXS_INFO("%s: User %s@%s added to service user table.",
|
||||
service->name,
|
||||
row[0],
|
||||
row[1])));
|
||||
row[1]);
|
||||
}
|
||||
|
||||
/* Append data in the memory area for SHA1 digest */
|
||||
@ -1720,7 +1578,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
/** Duplicate user*/
|
||||
if (service->log_auth_warnings)
|
||||
{
|
||||
skygw_log_write(LM, "Warning: Duplicate MySQL user found for "
|
||||
MXS_WARNING("Duplicate MySQL user found for "
|
||||
"service [%s]: %s@%s%s%s", service->name, row[0],
|
||||
row[1], db_grants ? " for database: " : "",
|
||||
db_grants ? row[5] : "");
|
||||
@ -1728,7 +1586,7 @@ getUsers(SERVICE *service, USERS *users)
|
||||
} else {
|
||||
if (service->log_auth_warnings)
|
||||
{
|
||||
skygw_log_write_flush(LM, "Warning: Failed to add user %s@%s for"
|
||||
MXS_WARNING("Failed to add user %s@%s for"
|
||||
" service [%s]. This user will be unavailable"
|
||||
" via MaxScale.", row[0], row[1], service->name);
|
||||
}
|
||||
@ -2198,10 +2056,7 @@ static int gw_mysql_set_timeouts(MYSQL* handle)
|
||||
MYSQL_OPT_READ_TIMEOUT,
|
||||
(void *)&cnf->auth_read_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set read timeout for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set read timeout for backend connection.");
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
@ -2209,10 +2064,7 @@ static int gw_mysql_set_timeouts(MYSQL* handle)
|
||||
MYSQL_OPT_CONNECT_TIMEOUT,
|
||||
(void *)&cnf->auth_conn_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set connect timeout for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set connect timeout for backend connection.");
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
@ -2220,10 +2072,7 @@ static int gw_mysql_set_timeouts(MYSQL* handle)
|
||||
MYSQL_OPT_WRITE_TIMEOUT,
|
||||
(void *)&cnf->auth_write_timeout)))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : failed to set write timeout for backend "
|
||||
"connection.")));
|
||||
MXS_ERROR("Failed to set write timeout for backend connection.");
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
@ -2482,8 +2331,7 @@ int add_wildcard_users(USERS *users, char* name, char* host, char* password, cha
|
||||
if((err = regcomp(&re,restr,REG_ICASE|REG_NOSUB)))
|
||||
{
|
||||
regerror(err,&re,errbuf,1024);
|
||||
skygw_log_write(LOGFILE_ERROR,"Error: Failed to compile regex "
|
||||
"when resolving wildcard database grants: %s",
|
||||
MXS_ERROR("Failed to compile regex when resolving wildcard database grants: %s",
|
||||
errbuf);
|
||||
free(restr);
|
||||
return 0;
|
||||
@ -2529,7 +2377,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
|
||||
if(service->dbref == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Service is missing the servers parameter.",service->name);
|
||||
MXS_ERROR("%s: Service is missing the servers parameter.", service->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2537,8 +2385,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
|
||||
if (serviceGetUser(service, &user, &password) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
"%s: Error: Service is missing the user credentials for authentication.",
|
||||
MXS_ERROR("%s: Service is missing the user credentials for authentication.",
|
||||
service->name);
|
||||
return false;
|
||||
}
|
||||
@ -2547,7 +2394,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
|
||||
if((mysql = mysql_init(NULL)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"[%s] Error: MySQL connection initialization failed.",__FUNCTION__);
|
||||
MXS_ERROR("[%s] MySQL connection initialization failed.", __FUNCTION__);
|
||||
free(dpasswd);
|
||||
return false;
|
||||
}
|
||||
@ -2561,7 +2408,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
int my_errno = mysql_errno(mysql);
|
||||
|
||||
skygw_log_write(LE,"%s: Error: Failed to connect to server %s(%s:%d) when"
|
||||
MXS_ERROR("%s: Failed to connect to server %s(%s:%d) when"
|
||||
" checking authentication user credentials and permissions: %d %s",
|
||||
service->name,
|
||||
server->server->unique_name,
|
||||
@ -2580,14 +2427,14 @@ bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: User '%s' is missing SELECT privileges"
|
||||
MXS_ERROR("%s: User '%s' is missing SELECT privileges"
|
||||
" on mysql.user table. MySQL error message: %s",
|
||||
service->name,user,mysql_error(mysql));
|
||||
rval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Failed to query from mysql.user table."
|
||||
MXS_ERROR("%s: Error: Failed to query from mysql.user table."
|
||||
" MySQL error message: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
@ -2596,7 +2443,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
if((res = mysql_use_result(mysql)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for"
|
||||
MXS_ERROR("%s: Error: Result retrieval failed when checking for"
|
||||
" permissions to the mysql.user table: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
@ -2609,12 +2456,13 @@ bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
if(mysql_errno(mysql) == ER_TABLEACCESS_DENIED_ERROR)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Warning: User '%s' is missing SELECT privileges on mysql.db table. Database name will be ignored in authentication. MySQL error message: %s",
|
||||
MXS_WARNING("%s: User '%s' is missing SELECT privileges on mysql.db table. "
|
||||
"Database name will be ignored in authentication. MySQL error message: %s",
|
||||
service->name,user,mysql_error(mysql));
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Failed to query from mysql.db table. MySQL error message: %s",
|
||||
MXS_ERROR("%s: Failed to query from mysql.db table. MySQL error message: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
}
|
||||
@ -2622,7 +2470,7 @@ bool check_service_permissions(SERVICE* service)
|
||||
{
|
||||
if((res = mysql_use_result(mysql)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"%s: Error: Result retrieval failed when checking for permissions to the mysql.db table: %s",
|
||||
MXS_ERROR("%s: Result retrieval failed when checking for permissions to the mysql.db table: %s",
|
||||
service->name,mysql_error(mysql));
|
||||
}
|
||||
else
|
||||
|
@ -305,10 +305,7 @@ dcb_final_free(DCB *dcb)
|
||||
if (DCB_POLL_BUSY(dcb))
|
||||
{
|
||||
/* Check if DCB has outstanding poll events */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"dcb_final_free: DCB %p has outstanding events",
|
||||
dcb)));
|
||||
MXS_ERROR("dcb_final_free: DCB %p has outstanding events.", dcb);
|
||||
}
|
||||
|
||||
/*< First remove this DCB from the chain */
|
||||
@ -481,16 +478,14 @@ DCB *listofdcb = NULL;
|
||||
previousdcb->memdata.next = zombiedcb->memdata.next;
|
||||
}
|
||||
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [%s] Remove dcb "
|
||||
MXS_DEBUG("%lu [%s] Remove dcb "
|
||||
"%p fd %d in state %s from the "
|
||||
"list of zombies.",
|
||||
pthread_self(),
|
||||
__func__,
|
||||
zombiedcb,
|
||||
zombiedcb->fd,
|
||||
STRDCBSTATE(zombiedcb->state))));
|
||||
STRDCBSTATE(zombiedcb->state));
|
||||
/*<
|
||||
* Move zombie dcb to linked list of victim dcbs.
|
||||
* The variable dcb is used to hold the last DCB
|
||||
@ -547,15 +542,13 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
{
|
||||
if (dcb->state == DCB_STATE_LISTENING)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [%s] Error : Removing DCB %p but was in state %s "
|
||||
MXS_ERROR("%lu [%s] Error : Removing DCB %p but was in state %s "
|
||||
"which is not expected for a call to dcb_close, although it"
|
||||
"should be processed correctly. ",
|
||||
pthread_self(),
|
||||
__func__,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state))));
|
||||
STRDCBSTATE(dcb->state));
|
||||
}
|
||||
else {
|
||||
/* Must be DCB_STATE_POLLING */
|
||||
@ -602,27 +595,23 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_process_victim_queue] Error : Failed to close "
|
||||
MXS_ERROR("%lu [dcb_process_victim_queue] Error : Failed to close "
|
||||
"socket %d on dcb %p due error %d, %s.",
|
||||
pthread_self(),
|
||||
dcb->fd,
|
||||
dcb,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb->fd = DCBFD_CLOSED;
|
||||
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_process_victim_queue] Closed socket "
|
||||
MXS_DEBUG("%lu [dcb_process_victim_queue] Closed socket "
|
||||
"%d on dcb %p.",
|
||||
pthread_self(),
|
||||
dcb->fd,
|
||||
dcb)));
|
||||
dcb);
|
||||
#if defined(FAKE_CODE)
|
||||
conn_open[dcb->fd] = false;
|
||||
#endif /* FAKE_CODE */
|
||||
@ -643,7 +632,10 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
dcb = nextdcb;
|
||||
}
|
||||
/** Reset threads session data */
|
||||
LOGIF(LT, tls_log_info.li_sesid = 0);
|
||||
if (LOG_IS_ENABLED(LOGFILE_TRACE))
|
||||
{
|
||||
tls_log_info.li_sesid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -690,9 +682,8 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
user = session_getUser(session);
|
||||
if (user && strlen(user))
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Looking for persistent connection DCB user %s protocol %s\n", pthread_self(), user, protocol)));
|
||||
MXS_DEBUG("%lu [dcb_connect] Looking for persistent connection DCB "
|
||||
"user %s protocol %s\n", pthread_self(), user, protocol);
|
||||
dcb = server_get_persistent(server, user, protocol);
|
||||
if (dcb)
|
||||
{
|
||||
@ -701,26 +692,21 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
*/
|
||||
if (!session_link_dcb(session, dcb))
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to link to session, the "
|
||||
MXS_DEBUG("%lu [dcb_connect] Failed to link to session, the "
|
||||
"session has been removed.\n",
|
||||
pthread_self())));
|
||||
pthread_self());
|
||||
dcb_close(dcb);
|
||||
return NULL;
|
||||
}
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Reusing a persistent connection, dcb %p\n", pthread_self(), dcb)));
|
||||
MXS_DEBUG("%lu [dcb_connect] Reusing a persistent connection, dcb %p\n",
|
||||
pthread_self(), dcb);
|
||||
dcb->persistentstart = 0;
|
||||
return dcb;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to find a reusable persistent connection.\n",
|
||||
pthread_self())));
|
||||
MXS_DEBUG("%lu [dcb_connect] Failed to find a reusable persistent connection.\n",
|
||||
pthread_self());
|
||||
}
|
||||
}
|
||||
|
||||
@ -734,12 +720,9 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
{
|
||||
dcb->state = DCB_STATE_DISCONNECTED;
|
||||
dcb_final_free(dcb);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to load protocol module for %s, free "
|
||||
"dcb %p\n",
|
||||
MXS_ERROR("Failed to load protocol module for %s, free dcb %p\n",
|
||||
protocol,
|
||||
dcb)));
|
||||
dcb);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(&(dcb->func), funcs, sizeof(GWPROTOCOL));
|
||||
@ -750,41 +733,35 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
*/
|
||||
if (!session_link_dcb(session, dcb))
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to link to session, the "
|
||||
MXS_DEBUG("%lu [dcb_connect] Failed to link to session, the "
|
||||
"session has been removed.",
|
||||
pthread_self())));
|
||||
pthread_self());
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
}
|
||||
fd = dcb->func.connect(dcb, server, session);
|
||||
|
||||
if (fd == DCBFD_CLOSED) {
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Failed to connect to server %s:%d, "
|
||||
MXS_DEBUG("%lu [dcb_connect] Failed to connect to server %s:%d, "
|
||||
"from backend dcb %p, client dcp %p fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
dcb,
|
||||
session->client,
|
||||
session->client->fd)));
|
||||
session->client->fd);
|
||||
dcb->state = DCB_STATE_DISCONNECTED;
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
} else {
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_connect] Connected to server %s:%d, "
|
||||
MXS_DEBUG("%lu [dcb_connect] Connected to server %s:%d, "
|
||||
"from backend dcb %p, client dcp %p fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
dcb,
|
||||
session->client,
|
||||
session->client->fd)));
|
||||
session->client->fd);
|
||||
}
|
||||
/**
|
||||
* Successfully connected to backend. Assign file descriptor to dcb
|
||||
@ -854,11 +831,9 @@ int dcb_read(
|
||||
if (dcb->fd <= 0)
|
||||
{
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_read] Error : Read failed, dcb is %s.",
|
||||
MXS_ERROR("%lu [dcb_read] Error : Read failed, dcb is %s.",
|
||||
pthread_self(),
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not readable")));
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not readable");
|
||||
/* </editor-fold> */
|
||||
return 0;
|
||||
}
|
||||
@ -871,16 +846,14 @@ int dcb_read(
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_read] Error : ioctl FIONREAD for dcb %p in "
|
||||
MXS_ERROR("%lu [dcb_read] Error : ioctl FIONREAD for dcb %p in "
|
||||
"state %s fd %d failed due error %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -922,15 +895,13 @@ int dcb_read(
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_read] Error : Failed to allocate read buffer "
|
||||
MXS_ERROR("%lu [dcb_read] Error : Failed to allocate read buffer "
|
||||
"for dcb %p fd %d, due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
/* </editor-fold> */
|
||||
return -1;
|
||||
}
|
||||
@ -943,16 +914,14 @@ int dcb_read(
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_read] Error : Read failed, dcb %p in state "
|
||||
MXS_ERROR("%lu [dcb_read] Error : Read failed, dcb %p in state "
|
||||
"%s fd %d, due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
/* </editor-fold> */
|
||||
}
|
||||
gwbuf_free(buffer);
|
||||
@ -960,15 +929,13 @@ int dcb_read(
|
||||
}
|
||||
nreadtotal += nsingleread;
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Debug Logging "> */
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_read] Read %d bytes from dcb %p in state %s "
|
||||
MXS_DEBUG("%lu [dcb_read] Read %d bytes from dcb %p in state %s "
|
||||
"fd %d.",
|
||||
pthread_self(),
|
||||
nsingleread,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
/* </editor-fold> */
|
||||
/*< Append read data to the gwbuf */
|
||||
*head = gwbuf_append(*head, buffer);
|
||||
@ -997,9 +964,8 @@ int dcb_read_SSL(DCB *dcb,
|
||||
|
||||
if (dcb->fd <= 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : Read failed, dcb is %s.",
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not readable")));
|
||||
MXS_ERROR("Read failed, dcb is %s.",
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not readable");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1015,13 +981,12 @@ int dcb_read_SSL(DCB *dcb,
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : Failed to allocate read buffer "
|
||||
MXS_ERROR("Failed to allocate read buffer "
|
||||
"for dcb %p fd %d, due %d, %s.",
|
||||
dcb,
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof (errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof (errbuf)));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -1049,7 +1014,7 @@ int dcb_read_SSL(DCB *dcb,
|
||||
if (buffer)
|
||||
{
|
||||
#ifdef SS_DEBUG
|
||||
skygw_log_write(LD, "%lu SSL: Truncated buffer from %d to %d bytes. "
|
||||
MXS_DEBUG("%lu SSL: Truncated buffer from %d to %d bytes. "
|
||||
"Read %d bytes, %d bytes waiting.\n", pthread_self(),
|
||||
bufsize, GWBUF_LENGTH(buffer), n, b);
|
||||
|
||||
@ -1063,14 +1028,13 @@ int dcb_read_SSL(DCB *dcb,
|
||||
#endif
|
||||
nread += n;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"%lu [dcb_read_SSL] Read %d bytes from dcb %p in state %s "
|
||||
MXS_DEBUG("%lu [dcb_read_SSL] Read %d bytes from dcb %p in state %s "
|
||||
"fd %d.",
|
||||
pthread_self(),
|
||||
n,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
|
||||
/*< Append read data to the gwbuf */
|
||||
*head = gwbuf_append(*head, buffer);
|
||||
@ -1078,12 +1042,12 @@ int dcb_read_SSL(DCB *dcb,
|
||||
}
|
||||
|
||||
ss_dassert(gwbuf_length(*head) == nread);
|
||||
LOGIF(LD, skygw_log_write(LD, "%lu Read a total of %d bytes from dcb %p in state %s fd %d.",
|
||||
MXS_DEBUG("%lu Read a total of %d bytes from dcb %p in state %s fd %d.",
|
||||
pthread_self(),
|
||||
nread,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd));
|
||||
dcb->fd);
|
||||
|
||||
return nread;
|
||||
}
|
||||
@ -1153,15 +1117,13 @@ int below_water;
|
||||
* queue with have.
|
||||
*/
|
||||
queue = gwbuf_consume(queue, written);
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
||||
MXS_DEBUG("%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
||||
"state %s fd %d",
|
||||
pthread_self(),
|
||||
written,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
} /*< while (queue != NULL) */
|
||||
|
||||
} /* if (dcb->writeq) */
|
||||
@ -1215,10 +1177,8 @@ dcb_write_parameter_check(DCB *dcb, GWBUF *queue)
|
||||
|
||||
if (dcb->fd <= 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write failed, dcb is %s.",
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not writable")));
|
||||
MXS_ERROR("Write failed, dcb is %s.",
|
||||
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not writable");
|
||||
gwbuf_free(queue);
|
||||
return false;
|
||||
}
|
||||
@ -1241,15 +1201,13 @@ dcb_write_parameter_check(DCB *dcb, GWBUF *queue)
|
||||
|
||||
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write aborted to dcb %p because "
|
||||
MXS_DEBUG("%lu [dcb_write] Write aborted to dcb %p because "
|
||||
"it is in state %s",
|
||||
pthread_self(),
|
||||
dcb->stats.n_buffered,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
gwbuf_free(queue);
|
||||
return false;
|
||||
}
|
||||
@ -1278,15 +1236,13 @@ dcb_write_when_already_queued(DCB *dcb, GWBUF *queue)
|
||||
atomic_add(&dcb->writeqlen, gwbuf_length(queue));
|
||||
dcb->writeq = gwbuf_append(dcb->writeq, queue);
|
||||
dcb->stats.n_buffered++;
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Append to writequeue. %d writes "
|
||||
MXS_DEBUG("%lu [dcb_write] Append to writequeue. %d writes "
|
||||
"buffered for dcb %p in state %s fd %d",
|
||||
pthread_self(),
|
||||
dcb->stats.n_buffered,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1304,9 +1260,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
if (eno == EPIPE)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
MXS_DEBUG("%lu [dcb_write] Write to dcb "
|
||||
"%p in state %s fd %d failed "
|
||||
"due errno %d, %s",
|
||||
pthread_self(),
|
||||
@ -1314,7 +1268,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1325,16 +1279,14 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
eno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p in "
|
||||
MXS_ERROR("Write to dcb %p in "
|
||||
"state %s fd %d failed due "
|
||||
"errno %d, %s",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
|
||||
}
|
||||
|
||||
@ -1361,13 +1313,11 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
if (dolog)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
MXS_DEBUG("%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
pthread_self(),
|
||||
dcb_isclient(dcb) ? "client" : "backend server",
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1447,7 +1397,7 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
||||
#ifdef SS_DEBUG
|
||||
else
|
||||
{
|
||||
skygw_log_write(LD, "SSL error: SSL_ERROR_WANT_WRITE, retrying SSL_write...");
|
||||
MXS_DEBUG("SSL error: SSL_ERROR_WANT_WRITE, retrying SSL_write...");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1455,15 +1405,13 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
||||
|
||||
/** Remove written bytes from the queue */
|
||||
queue = gwbuf_consume(queue, w);
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
||||
MXS_DEBUG("%lu [dcb_write] Wrote %d Bytes to dcb %p in "
|
||||
"state %s fd %d",
|
||||
pthread_self(),
|
||||
w,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
} /*< while (queue != NULL) */
|
||||
/*<
|
||||
* What wasn't successfully written is stored to write queue
|
||||
@ -1495,37 +1443,31 @@ dcb_write_SSL_error_report (DCB *dcb, int ret, int ssl_errno)
|
||||
switch(ssl_errno)
|
||||
{
|
||||
case SSL_ERROR_WANT_READ:
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
MXS_DEBUG("%lu [dcb_write] Write to dcb "
|
||||
"%p in state %s fd %d failed "
|
||||
"due error SSL_ERROR_WANT_READ",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
break;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
MXS_DEBUG("%lu [dcb_write] Write to dcb "
|
||||
"%p in state %s fd %d failed "
|
||||
"due error SSL_ERROR_WANT_WRITE",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
break;
|
||||
default:
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_write] Write to dcb "
|
||||
MXS_DEBUG("%lu [dcb_write] Write to dcb "
|
||||
"%p in state %s fd %d failed "
|
||||
"due error %d",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,ssl_errno)));
|
||||
dcb->fd,ssl_errno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1534,26 +1476,24 @@ dcb_write_SSL_error_report (DCB *dcb, int ret, int ssl_errno)
|
||||
{
|
||||
if (ret == -1)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p in "
|
||||
MXS_ERROR("Write to dcb %p in "
|
||||
"state %s fd %d failed due to "
|
||||
"SSL error %d",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
ssl_errno)));
|
||||
ssl_errno);
|
||||
if(ssl_errno == SSL_ERROR_SSL || ssl_errno == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
if(ssl_errno == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
MXS_ERROR("%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
do
|
||||
{
|
||||
char errbuf[SSL_ERRBUF_LEN];
|
||||
ERR_error_string_n(ssl_errno,errbuf, sizeof(errbuf));
|
||||
skygw_log_write(LE,"%d:%s",ssl_errno,errbuf);
|
||||
MXS_ERROR("%d:%s", ssl_errno,errbuf);
|
||||
} while((ssl_errno = ERR_get_error()) != 0);
|
||||
}
|
||||
}
|
||||
@ -1563,7 +1503,7 @@ dcb_write_SSL_error_report (DCB *dcb, int ret, int ssl_errno)
|
||||
{
|
||||
char errbuf[SSL_ERRBUF_LEN];
|
||||
ERR_error_string_n(ssl_errno,errbuf,sizeof(errbuf));
|
||||
skygw_log_write(LE,"%d:%s",ssl_errno,errbuf);
|
||||
MXS_ERROR("%d:%s", ssl_errno,errbuf);
|
||||
} while((ssl_errno = ERR_get_error()) != 0);
|
||||
}
|
||||
}
|
||||
@ -1618,15 +1558,13 @@ int above_water;
|
||||
break;
|
||||
}
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Write to dcb %p "
|
||||
MXS_ERROR("Write to dcb %p "
|
||||
"in state %s fd %d failed due errno %d, %s",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
saved_errno,
|
||||
strerror_r(saved_errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(saved_errno, errbuf, sizeof(errbuf)));
|
||||
break;
|
||||
}
|
||||
/*
|
||||
@ -1634,15 +1572,13 @@ int above_water;
|
||||
* queue with have.
|
||||
*/
|
||||
dcb->writeq = gwbuf_consume(dcb->writeq, w);
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_drain_writeq] Wrote %d Bytes to dcb %p "
|
||||
MXS_DEBUG("%lu [dcb_drain_writeq] Wrote %d Bytes to dcb %p "
|
||||
"in state %s fd %d",
|
||||
pthread_self(),
|
||||
w,
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd)));
|
||||
dcb->fd);
|
||||
n += w;
|
||||
}
|
||||
}
|
||||
@ -1704,8 +1640,7 @@ dcb_drain_writeq_SSL(DCB *dcb)
|
||||
{
|
||||
break;
|
||||
}
|
||||
skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : Write to dcb failed due to "
|
||||
MXS_ERROR("Write to dcb failed due to "
|
||||
"SSL error %d:",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
@ -1719,20 +1654,20 @@ dcb_drain_writeq_SSL(DCB *dcb)
|
||||
{
|
||||
char errbuf[SSL_ERRBUF_LEN];
|
||||
ERR_error_string_n(ssl_errno,errbuf,sizeof(errbuf));
|
||||
skygw_log_write(LE,"%s",errbuf);
|
||||
MXS_ERROR("%s", errbuf);
|
||||
}
|
||||
if(errno != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LE,"%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
MXS_ERROR("%d:%s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
break;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
skygw_log_write(LE,"Socket is closed.");
|
||||
MXS_ERROR("Socket is closed.");
|
||||
break;
|
||||
|
||||
default:
|
||||
skygw_log_write(LE,"Unexpected error.");
|
||||
MXS_ERROR("Unexpected error.");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -1782,13 +1717,11 @@ dcb_close(DCB *dcb)
|
||||
if (DCB_STATE_UNDEFINED == dcb->state
|
||||
|| DCB_STATE_DISCONNECTED == dcb->state)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [dcb_close] Error : Removing DCB %p but was in state %s "
|
||||
MXS_ERROR("%lu [dcb_close] Error : Removing DCB %p but was in state %s "
|
||||
"which is not legal for a call to dcb_close. ",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state))));
|
||||
STRDCBSTATE(dcb->state));
|
||||
raise(SIGABRT);
|
||||
}
|
||||
|
||||
@ -1864,11 +1797,9 @@ dcb_maybe_add_persistent(DCB *dcb)
|
||||
&& (poolcount = dcb_persistent_clean_count(dcb, false)) < dcb->server->persistpoolmax)
|
||||
{
|
||||
DCB_CALLBACK *loopcallback;
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_maybe_add_persistent] Adding DCB to persistent pool, user %s.\n",
|
||||
MXS_DEBUG("%lu [dcb_maybe_add_persistent] Adding DCB to persistent pool, user %s.\n",
|
||||
pthread_self(),
|
||||
dcb->user)));
|
||||
dcb->user);
|
||||
dcb->dcb_is_zombie = false;
|
||||
dcb->persistentstart = time(NULL);
|
||||
if (dcb->session)
|
||||
@ -1901,9 +1832,7 @@ dcb_maybe_add_persistent(DCB *dcb)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [dcb_maybe_add_persistent] Not adding DCB %p to persistent pool, "
|
||||
MXS_DEBUG("%lu [dcb_maybe_add_persistent] Not adding DCB %p to persistent pool, "
|
||||
"user %s, max for pool %d, error handle called %s, hung flag %s, "
|
||||
"server status %d, pool count %d.\n",
|
||||
pthread_self(),
|
||||
@ -1913,7 +1842,7 @@ dcb_maybe_add_persistent(DCB *dcb)
|
||||
dcb->dcb_errhandle_called ? "true" : "false",
|
||||
(dcb->flags & DCBF_HUNG) ? "true" : "false",
|
||||
dcb->server ? dcb->server->status : 0,
|
||||
poolcount)));
|
||||
poolcount);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2446,12 +2375,10 @@ gw_write(DCB *dcb, const void *buf, size_t nbytes)
|
||||
{
|
||||
snprintf(s, len, "%s", (char *)str);
|
||||
}
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [gw_write] Wrote %d bytes : %s ",
|
||||
MXS_INFO("%lu [gw_write] Wrote %d bytes : %s ",
|
||||
pthread_self(),
|
||||
w,
|
||||
s)));
|
||||
s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
@ -2588,10 +2515,9 @@ DCB_CALLBACK *cb, *nextcb;
|
||||
nextcb = cb->next;
|
||||
spinlock_release(&dcb->cb_lock);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"%lu [dcb_call_callback] %s",
|
||||
MXS_DEBUG("%lu [dcb_call_callback] %s",
|
||||
pthread_self(),
|
||||
STRDCBREASON(reason))));
|
||||
STRDCBREASON(reason));
|
||||
|
||||
cb->cb(dcb, reason, cb->userdata);
|
||||
spinlock_acquire(&dcb->cb_lock);
|
||||
@ -2686,9 +2612,7 @@ dcb_get_next (DCB *dcb)
|
||||
void
|
||||
dcb_call_foreach(struct server* server, DCB_REASON reason)
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"%lu [dcb_call_foreach]",
|
||||
pthread_self())));
|
||||
MXS_DEBUG("%lu [dcb_call_foreach]", pthread_self());
|
||||
|
||||
switch (reason) {
|
||||
case DCB_REASON_CLOSE:
|
||||
@ -2732,9 +2656,7 @@ dcb_call_foreach(struct server* server, DCB_REASON reason)
|
||||
void
|
||||
dcb_hangup_foreach(struct server* server)
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"%lu [dcb_hangup_foreach]",
|
||||
pthread_self())));
|
||||
MXS_DEBUG("%lu [dcb_hangup_foreach]", pthread_self());
|
||||
|
||||
DCB *dcb;
|
||||
spinlock_acquire(&dcbspin);
|
||||
@ -2938,13 +2860,13 @@ int dcb_create_SSL(DCB* dcb)
|
||||
|
||||
if((dcb->ssl = SSL_new(dcb->service->ctx)) == NULL)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Failed to initialize SSL for connection.");
|
||||
MXS_ERROR("Failed to initialize SSL for connection.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(SSL_set_fd(dcb->ssl,dcb->fd) == 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Failed to set file descriptor for SSL connection.");
|
||||
MXS_ERROR("Failed to set file descriptor for SSL connection.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2973,14 +2895,12 @@ int dcb_accept_SSL(DCB* dcb)
|
||||
{
|
||||
ssl_rval = SSL_accept(dcb->ssl);
|
||||
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"[dcb_accept_SSL] SSL_accept %d, error %d",
|
||||
ssl_rval,ssl_errnum)));
|
||||
MXS_DEBUG("[dcb_accept_SSL] SSL_accept %d, error %d", ssl_rval,ssl_errnum);
|
||||
switch(ssl_rval)
|
||||
{
|
||||
case 0:
|
||||
ssl_errnum = SSL_get_error(dcb->ssl,ssl_rval);
|
||||
skygw_log_write(LE,"Error: SSL authentication failed (SSL error %d):",
|
||||
ssl_errnum);
|
||||
MXS_ERROR("SSL authentication failed (SSL error %d):", ssl_errnum);
|
||||
|
||||
if(ssl_errnum == SSL_ERROR_SSL ||
|
||||
ssl_errnum == SSL_ERROR_SYSCALL)
|
||||
@ -2988,15 +2908,14 @@ int dcb_accept_SSL(DCB* dcb)
|
||||
while((err_errnum = ERR_get_error()) != 0)
|
||||
{
|
||||
ERR_error_string_n(err_errnum,errbuf,sizeof(errbuf));
|
||||
skygw_log_write(LE,"%s",errbuf);
|
||||
MXS_ERROR("%s", errbuf);
|
||||
}
|
||||
}
|
||||
rval = -1;
|
||||
break;
|
||||
case 1:
|
||||
rval = 1;
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"[dcb_accept_SSL] SSL_accept done for %s",
|
||||
dcb->remote)));
|
||||
MXS_DEBUG("[dcb_accept_SSL] SSL_accept done for %s", dcb->remote);
|
||||
return rval;
|
||||
|
||||
case -1:
|
||||
@ -3008,15 +2927,13 @@ int dcb_accept_SSL(DCB* dcb)
|
||||
/** Not all of the data has been read. Go back to the poll
|
||||
queue and wait for more.*/
|
||||
rval = 0;
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"[dcb_accept_SSL] SSL_accept ongoing for %s",
|
||||
dcb->remote)));
|
||||
MXS_DEBUG("[dcb_accept_SSL] SSL_accept ongoing for %s", dcb->remote);
|
||||
return rval;
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = -1;
|
||||
skygw_log_write(LE,
|
||||
"Error: Fatal error in SSL_accept for %s: (SSL version: %s SSL error code: %d)",
|
||||
MXS_ERROR("Fatal error in SSL_accept for %s: (SSL version: %s SSL error code: %d)",
|
||||
dcb->remote,
|
||||
SSL_get_version(dcb->ssl),
|
||||
ssl_errnum);
|
||||
@ -3026,13 +2943,11 @@ int dcb_accept_SSL(DCB* dcb)
|
||||
while((err_errnum = ERR_get_error()) != 0)
|
||||
{
|
||||
ERR_error_string_n(err_errnum,errbuf,sizeof(errbuf));
|
||||
skygw_log_write(LE,
|
||||
"%s",
|
||||
errbuf);
|
||||
MXS_ERROR("%s", errbuf);
|
||||
}
|
||||
if(errno)
|
||||
{
|
||||
skygw_log_write(LE, "Error: SSL authentication failed due to system"
|
||||
MXS_ERROR("SSL authentication failed due to system"
|
||||
" error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
}
|
||||
@ -3040,16 +2955,14 @@ int dcb_accept_SSL(DCB* dcb)
|
||||
break;
|
||||
|
||||
default:
|
||||
skygw_log_write_flush(LE,
|
||||
"Error: Fatal library error in SSL_accept, returned value was %d.",
|
||||
ssl_rval);
|
||||
MXS_ERROR("Fatal library error in SSL_accept, returned value was %d.", ssl_rval);
|
||||
rval = -1;
|
||||
break;
|
||||
}
|
||||
ioctl(fd,FIONREAD,&b);
|
||||
pending = SSL_pending(dcb->ssl);
|
||||
#ifdef SS_DEBUG
|
||||
skygw_log_write_flush(LD,"[dcb_accept_SSL] fd %d: %d bytes, %d pending",fd,b,pending);
|
||||
MXS_DEBUG("[dcb_accept_SSL] fd %d: %d bytes, %d pending", fd, b, pending);
|
||||
#endif
|
||||
}while((b > 0 || pending > 0) && rval != -1);
|
||||
|
||||
@ -3075,16 +2988,16 @@ int dcb_connect_SSL(DCB* dcb)
|
||||
{
|
||||
case 0:
|
||||
errnum = SSL_get_error(dcb->ssl,rval);
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"SSL_connect shutdown for %s@%s",
|
||||
MXS_DEBUG("SSL_connect shutdown for %s@%s",
|
||||
dcb->user,
|
||||
dcb->remote)));
|
||||
dcb->remote);
|
||||
return -1;
|
||||
break;
|
||||
case 1:
|
||||
rval = 1;
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"SSL_connect done for %s@%s",
|
||||
MXS_DEBUG("SSL_connect done for %s@%s",
|
||||
dcb->user,
|
||||
dcb->remote)));
|
||||
dcb->remote);
|
||||
return rval;
|
||||
|
||||
case -1:
|
||||
@ -3096,16 +3009,15 @@ int dcb_connect_SSL(DCB* dcb)
|
||||
queue and wait for more.*/
|
||||
|
||||
rval = 0;
|
||||
LOGIF(LD,(skygw_log_write_flush(LD,"SSL_connect ongoing for %s@%s",
|
||||
MXS_DEBUG("SSL_connect ongoing for %s@%s",
|
||||
dcb->user,
|
||||
dcb->remote)));
|
||||
dcb->remote);
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = -1;
|
||||
ERR_error_string_n(errnum,errbuf,sizeof(errbuf));
|
||||
skygw_log_write_flush(LE,
|
||||
"Error: Fatal error in SSL_accept for %s@%s: (SSL error code: %d) %s",
|
||||
MXS_ERROR("Fatal error in SSL_accept for %s@%s: (SSL error code: %d) %s",
|
||||
dcb->user,
|
||||
dcb->remote,
|
||||
errnum,
|
||||
@ -3114,9 +3026,7 @@ int dcb_connect_SSL(DCB* dcb)
|
||||
break;
|
||||
|
||||
default:
|
||||
skygw_log_write_flush(LE,
|
||||
"Error: Fatal error in SSL_connect, returned value was %d.",
|
||||
rval);
|
||||
MXS_ERROR("Fatal error in SSL_connect, returned value was %d.", rval);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3165,14 +3075,13 @@ int dcb_bytes_readable_SSL(DCB *dcb, int nread)
|
||||
if (rc == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : ioctl FIONREAD for dcb %p in "
|
||||
MXS_ERROR("ioctl FIONREAD for dcb %p in "
|
||||
"state %s fd %d failed due error %d, %s.",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof (errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof (errbuf)));
|
||||
rval = -1;
|
||||
}
|
||||
else
|
||||
@ -3202,12 +3111,11 @@ int dcb_bytes_readable_SSL(DCB *dcb, int nread)
|
||||
#ifdef SS_DEBUG
|
||||
else if (nbytes != 0 || pending != 0)
|
||||
{
|
||||
skygw_log_write_flush(LD, "Total: %d Socket: %d Pending: %d",
|
||||
nread, nbytes, pending);
|
||||
MXS_DEBUG("Total: %d Socket: %d Pending: %d", nread, nbytes, pending);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LD, "Tried to read from socket, no data left. %d bytes read in total.", nread);
|
||||
MXS_DEBUG("Tried to read from socket, no data left. %d bytes read in total.", nread);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3228,14 +3136,13 @@ void dcb_log_ssl_read_error(DCB *dcb, int ssl_errno, int rc)
|
||||
{
|
||||
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"Error : Read failed, dcb %p in state "
|
||||
MXS_ERROR("Read failed, dcb %p in state "
|
||||
"%s fd %d, SSL error %d: %s.",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
ssl_errno,
|
||||
strerror_r(errno, errbuf, sizeof (errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
|
||||
if (ssl_errno == SSL_ERROR_SSL ||
|
||||
ssl_errno == SSL_ERROR_SYSCALL)
|
||||
@ -3243,9 +3150,7 @@ void dcb_log_ssl_read_error(DCB *dcb, int ssl_errno, int rc)
|
||||
while ((ssl_errno = ERR_get_error()) != 0)
|
||||
{
|
||||
ERR_error_string_n(ssl_errno, errbuf, STRERROR_BUFLEN);
|
||||
skygw_log_write(LE,
|
||||
"%s",
|
||||
errbuf);
|
||||
MXS_ERROR("%s", errbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,11 +94,11 @@ 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 "
|
||||
MXS_ERROR("Cannot execute file '%s'. Missing "
|
||||
"execution permissions.", cmd->argv[0]);
|
||||
}
|
||||
externcmd_free(cmd);
|
||||
@ -152,7 +152,7 @@ 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",
|
||||
MXS_ERROR("Failed to execute command '%s', fork failed: [%d] %s",
|
||||
cmd->argv[0], errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
rval = -1;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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 "
|
||||
MXS_ERROR("Memory allocation for filter session failed "
|
||||
"due to %d,%s.",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -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,27 +334,32 @@ 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",
|
||||
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",
|
||||
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.",
|
||||
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",
|
||||
MXS_ERROR("Child process %d did not exit normally. Exit status: %d",
|
||||
child, exit_status);
|
||||
}
|
||||
}
|
||||
@ -383,11 +380,9 @@ 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 "
|
||||
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);
|
||||
|
||||
@ -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,9 +439,7 @@ 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.",
|
||||
MXS_ERROR("Failed call sigaction() in %s due to %d, %s.",
|
||||
program_invocation_short_name,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
@ -475,9 +466,7 @@ 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 "
|
||||
MXS_ERROR("Failed to remove the data directory %s of "
|
||||
"MaxScale due to %d, %s.",
|
||||
datadir,
|
||||
eno,
|
||||
@ -776,9 +765,7 @@ static void print_log_n_stderr(
|
||||
|
||||
if (do_log) {
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%s %s %s %s",
|
||||
MXS_ERROR("%s %s %s %s",
|
||||
log_err,
|
||||
logstr,
|
||||
eno == 0 ? " " : "Error :",
|
||||
@ -815,9 +802,7 @@ 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 "
|
||||
MXS_WARNING("Failed to read the configuration file %s due "
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
@ -848,9 +833,7 @@ 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 "
|
||||
MXS_ERROR("Unable to open file %s for write due "
|
||||
"to %d, %s.",
|
||||
absolute_pathname,
|
||||
eno,
|
||||
@ -909,10 +892,7 @@ 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 "
|
||||
MXS_WARNING("Failed to read the directory %s, due "
|
||||
"to %d, %s.",
|
||||
relative_path,
|
||||
eno,
|
||||
@ -939,9 +919,7 @@ 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.",
|
||||
MXS_ERROR("Memory allocation failed due to %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
|
||||
free(expanded_path);
|
||||
@ -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,9 +1814,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : mysql_library_init failed. It is a "
|
||||
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),
|
||||
@ -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. "
|
||||
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()
|
||||
|
@ -74,11 +74,9 @@ 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",
|
||||
MXS_ERROR("Failed to obtain address for host %s, %s",
|
||||
p,
|
||||
gai_strerror(rc))));
|
||||
gai_strerror(rc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -87,11 +85,9 @@ setipaddress(struct in_addr *a, char *p) {
|
||||
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",
|
||||
MXS_ERROR("Failed to obtain address for host %s, %s",
|
||||
p,
|
||||
gai_strerror(rc))));
|
||||
gai_strerror(rc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -115,10 +111,7 @@ 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;
|
||||
}
|
||||
@ -208,10 +201,7 @@ struct hostent *hp;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to lookup host '%s'. ",
|
||||
buf)));
|
||||
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
|
||||
|
@ -88,9 +88,7 @@ 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")));
|
||||
MXS_ERROR("Error in module_feedback_send(), not enough memory for realloc");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -133,34 +131,28 @@ 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 "
|
||||
MXS_ERROR("Unable to find library for "
|
||||
"module: %s. Module dir: %s",
|
||||
module, get_libdir())));
|
||||
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: "
|
||||
MXS_ERROR("Unable to load library for module: "
|
||||
"%s\n\n\t\t %s."
|
||||
"\n\n",
|
||||
module,
|
||||
dlerror())));
|
||||
dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((sym = dlsym(dlhandle, "version")) == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Version interface not supported by "
|
||||
MXS_ERROR("Version interface not supported by "
|
||||
"module: %s\n\t\t\t %s.",
|
||||
module,
|
||||
dlerror())));
|
||||
dlerror());
|
||||
dlclose(dlhandle);
|
||||
return NULL;
|
||||
}
|
||||
@ -183,41 +175,25 @@ 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)));
|
||||
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)));
|
||||
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)));
|
||||
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)));
|
||||
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 "
|
||||
MXS_ERROR("Expected entry point interface missing "
|
||||
"from module: %s\n\t\t\t %s.",
|
||||
module,
|
||||
dlerror())));
|
||||
dlerror());
|
||||
dlclose(dlhandle);
|
||||
return NULL;
|
||||
}
|
||||
ep = sym;
|
||||
modobj = ep();
|
||||
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Loaded module %s: %s from %s",
|
||||
MXS_NOTICE("Loaded module %s: %s from %s",
|
||||
module,
|
||||
version,
|
||||
fname)));
|
||||
fname);
|
||||
register_module(module, type, dlhandle, version, modobj, mod_info);
|
||||
}
|
||||
else
|
||||
@ -448,9 +420,7 @@ 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;
|
||||
}
|
||||
@ -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"
|
||||
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_user_info == NULL ?
|
||||
"NULL" : feedback_config->feedback_user_info);
|
||||
|
||||
feedback_config->feedback_last_action = _NOTIFICATION_SEND_ERROR;
|
||||
|
||||
@ -591,11 +560,9 @@ 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]"
|
||||
MXS_INFO("module_feedback_send(): execution skipped, current hour [%d]"
|
||||
" is not within the proper interval (from 2 AM to 4 AM)",
|
||||
hour)));
|
||||
hour);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -604,23 +571,18 @@ module_feedback_send(void* data) {
|
||||
if (feedback_config->feedback_last_action == _NOTIFICATION_SEND_OK) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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]",
|
||||
MXS_INFO("module_feedback_send(): task completed: hour is [%d], last_action [%d]",
|
||||
hour,
|
||||
feedback_config->feedback_last_action)));
|
||||
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",
|
||||
MXS_ERROR("do_http_post(), curl call for [%s] failed due: %s, %s",
|
||||
feedback_config->feedback_url,
|
||||
curl_easy_strerror(res),
|
||||
error_message)));
|
||||
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)));
|
||||
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")));
|
||||
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)
|
||||
|
@ -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,9 +734,7 @@ static void modutil_reply_routing_error(
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Creating routing error message failed.")));
|
||||
MXS_ERROR("Creating routing error message failed.");
|
||||
return;
|
||||
}
|
||||
/** Set flags that help router to process reply correctly */
|
||||
@ -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);
|
||||
|
@ -66,10 +66,7 @@ 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)));
|
||||
MXS_ERROR("Unable to load monitor module '%s'.", name);
|
||||
free(mon);
|
||||
return NULL;
|
||||
}
|
||||
@ -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,16 +381,12 @@ 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)));
|
||||
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,7 +488,7 @@ 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"
|
||||
MXS_ERROR("%s: Failed to connect to server %s(%s:%d) when"
|
||||
" checking monitor user credentials and permissions.",
|
||||
monitor->name,
|
||||
server->unique_name,
|
||||
@ -514,12 +503,12 @@ 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",
|
||||
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",
|
||||
MXS_ERROR("%s: Monitor failed to query for slave status. MySQL error message: %s",
|
||||
monitor->name,mysql_error(mysql));
|
||||
}
|
||||
rval = false;
|
||||
@ -528,7 +517,7 @@ 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",
|
||||
MXS_ERROR("%s: Result retrieval failed when checking for REPLICATION CLIENT permissions: %s",
|
||||
monitor->name,mysql_error(mysql));
|
||||
rval = false;
|
||||
}
|
||||
|
@ -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 "
|
||||
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))));
|
||||
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 "
|
||||
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))));
|
||||
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.",
|
||||
MXS_DEBUG("%lu [poll_add_dcb] Added dcb %p in state %s to poll set.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state))));
|
||||
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 "
|
||||
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))));
|
||||
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, "
|
||||
MXS_ERROR("%lu [poll_resolve_error] Error : epoll_ctl could not add, "
|
||||
"already exists for DCB %p.",
|
||||
pthread_self(),
|
||||
dcb)));
|
||||
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 "
|
||||
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)));
|
||||
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, "
|
||||
MXS_ERROR("%lu [poll_resolve_error] Error : epoll_ctl could not remove, "
|
||||
"not found, for dcb %p.",
|
||||
pthread_self(),
|
||||
dcb)));
|
||||
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 "
|
||||
MXS_DEBUG("%lu [poll_waitevents] epoll_wait returned "
|
||||
"%d, errno %d",
|
||||
pthread_self(),
|
||||
nfds,
|
||||
eno)));
|
||||
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",
|
||||
MXS_DEBUG("%lu [poll_waitevents] epoll_wait found %d fds",
|
||||
pthread_self(),
|
||||
nfds)));
|
||||
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,13 +824,11 @@ 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] "
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Added fake events %d to ev %d.",
|
||||
pthread_self(),
|
||||
dcb_fake_write_ev[dcb->fd],
|
||||
ev)));
|
||||
ev);
|
||||
ev |= dcb_fake_write_ev[dcb->fd];
|
||||
dcb_fake_write_ev[dcb->fd] = 0;
|
||||
}
|
||||
@ -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 "
|
||||
MXS_DEBUG("%lu [poll_waitevents] event %d dcb %p "
|
||||
"role %s",
|
||||
pthread_self(),
|
||||
ev,
|
||||
dcb,
|
||||
STRDCBROLE(dcb->dcb_role))));
|
||||
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] "
|
||||
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)));
|
||||
dcb->fd);
|
||||
}
|
||||
}
|
||||
if (ev & EPOLLIN)
|
||||
{
|
||||
if (dcb->state == DCB_STATE_LISTENING)
|
||||
{
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [poll_waitevents] "
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Accept in fd %d",
|
||||
pthread_self(),
|
||||
dcb->fd)));
|
||||
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] "
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Read in dcb %p fd %d",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd)));
|
||||
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] "
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Added fake errno %d. "
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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] "
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"EPOLLERR due %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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] "
|
||||
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)))));
|
||||
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] "
|
||||
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)))));
|
||||
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 "
|
||||
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)));
|
||||
function);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -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 "
|
||||
MXS_NOTICE("Encrypted password file %s can't be accessed "
|
||||
"(%s). Password encryption is not used.",
|
||||
secret_file,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("Access for secrets file "
|
||||
"[%s] failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("Failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("fstat for secret file %s "
|
||||
"failed. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("Secrets file %s has "
|
||||
"incorrect size. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("Ignoring secrets file "
|
||||
"%s, invalid permissions.",
|
||||
secret_file)));
|
||||
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 "
|
||||
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)))));
|
||||
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 "
|
||||
MXS_ERROR("Failed closing the "
|
||||
"secrets file %s. Error %d, %s.",
|
||||
secret_file,
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("failed opening secret "
|
||||
"file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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.",
|
||||
MXS_ERROR("failed opening /dev/random. Error %d, %s.",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("failed writing into "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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 "
|
||||
MXS_ERROR("failed closing the "
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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"
|
||||
MXS_ERROR("failed to change the permissions of the"
|
||||
"secret file [%s]. Error %d, %s.",
|
||||
secret_file,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -182,9 +182,7 @@ 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 "
|
||||
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(),
|
||||
@ -194,7 +192,7 @@ server_get_persistent(SERVER *server, char *user, const char *protocol)
|
||||
dcb->protoname ? dcb->protoname : "NULL",
|
||||
protocol,
|
||||
(dcb->flags & DCBF_HUNG) ? "true" : "false",
|
||||
dcb-> dcb_errhandle_called ? "true" : "false")));
|
||||
dcb-> dcb_errhandle_called ? "true" : "false");
|
||||
}
|
||||
previous = dcb;
|
||||
dcb = dcb->nextpersistent;
|
||||
@ -725,11 +723,9 @@ 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.",
|
||||
MXS_NOTICE("Update server protocol for server %s to protocol %s.",
|
||||
server->name,
|
||||
protocol)));
|
||||
protocol);
|
||||
free(server->protocol);
|
||||
server->protocol = strdup(protocol);
|
||||
}
|
||||
@ -738,10 +734,8 @@ server_update(SERVER *server, char *protocol, char *user, char *passwd)
|
||||
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)));
|
||||
MXS_NOTICE("Update server monitor credentials for server %s",
|
||||
server->name);
|
||||
free(server->monuser);
|
||||
free(server->monpw);
|
||||
serverAddMonUser(server, user, passwd);
|
||||
|
@ -118,9 +118,7 @@ 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"
|
||||
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",
|
||||
@ -129,7 +127,7 @@ SERVICE *service;
|
||||
router,
|
||||
home,
|
||||
ldpath?"\t\t\t - ":"",
|
||||
ldpath?ldpath:"")));
|
||||
ldpath?ldpath:"");
|
||||
free(service);
|
||||
return NULL;
|
||||
}
|
||||
@ -214,10 +212,7 @@ GWPROTOCOL *funcs;
|
||||
|
||||
if (port->listener == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to create listener for service %s.",
|
||||
service->name)));
|
||||
MXS_ERROR("Failed to create listener for service %s.", service->name);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
@ -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 "
|
||||
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)));
|
||||
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,7 +274,7 @@ GWPROTOCOL *funcs;
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
MXS_ERROR("Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
@ -302,7 +293,7 @@ GWPROTOCOL *funcs;
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
skygw_log_write(LOGFILE_ERROR,"Error : Failed to create directory '%s': [%d] %s",
|
||||
MXS_ERROR("Failed to create directory '%s': [%d] %s",
|
||||
path,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
@ -314,12 +305,10 @@ GWPROTOCOL *funcs;
|
||||
}
|
||||
if (loaded == 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Service %s: failed to load any user "
|
||||
MXS_ERROR("Service %s: failed to load any user "
|
||||
"information. Authentication will "
|
||||
"probably fail as a result.",
|
||||
service->name)));
|
||||
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 "
|
||||
MXS_ERROR("Unable to load protocol module %s. Listener "
|
||||
"for service %s not started.",
|
||||
port->protocol,
|
||||
service->name)));
|
||||
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.",
|
||||
MXS_ERROR("Unable to start to listen port %d for %s %s.",
|
||||
port->port,
|
||||
port->protocol,
|
||||
service->name)));
|
||||
service->name);
|
||||
users_free(service->users);
|
||||
service->users = NULL;
|
||||
dcb_close(port->listener);
|
||||
@ -445,7 +426,7 @@ 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.",
|
||||
MXS_NOTICE("Failed to start service %s, retrying in %d seconds.",
|
||||
service->name, retry_after);
|
||||
}
|
||||
return listeners;
|
||||
@ -480,24 +461,20 @@ 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.",
|
||||
MXS_ERROR("%s: Inadequate user permissions for service. Service not started.",
|
||||
service->name);
|
||||
service->state = SERVICE_STATE_FAILED;
|
||||
}
|
||||
@ -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,8 +1079,7 @@ 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")));
|
||||
MXS_ERROR("Out of memory adding filters to service.\n");
|
||||
return;
|
||||
}
|
||||
ptr = strtok_r(filters, "|", &brkt);
|
||||
@ -1116,17 +1089,13 @@ 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")));
|
||||
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
|
||||
)));
|
||||
MXS_WARNING("Unable to find filter '%s' for service '%s'\n",
|
||||
trim(ptr), service->name);
|
||||
n--;
|
||||
}
|
||||
flist[n] = NULL;
|
||||
@ -1405,20 +1374,16 @@ 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 "
|
||||
MXS_ERROR("Failed to update router "
|
||||
"for service %s to %s.",
|
||||
service->name,
|
||||
router)));
|
||||
router);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Update router for service %s to %s.",
|
||||
MXS_NOTICE("Update router for service %s to %s.",
|
||||
service->name,
|
||||
router)));
|
||||
router);
|
||||
free(service->routerModule);
|
||||
service->routerModule = strdup(router);
|
||||
service->router = router_obj;
|
||||
@ -1428,10 +1393,7 @@ void *router_obj;
|
||||
(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)));
|
||||
MXS_NOTICE("Update credentials for service %s.", service->name);
|
||||
serviceSetUser(service, user, auth);
|
||||
}
|
||||
}
|
||||
@ -1448,10 +1410,9 @@ 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;
|
||||
}
|
||||
@ -1460,10 +1421,8 @@ int service_refresh_users(SERVICE *service) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -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 "
|
||||
MXS_ERROR("Failed to allocate memory for "
|
||||
"session object due error %d, %s.",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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"
|
||||
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)));
|
||||
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. "
|
||||
MXS_ERROR("Setting up filters failed. "
|
||||
"Terminating session %s.",
|
||||
service->name)));
|
||||
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 ",
|
||||
MXS_INFO("Started session [%lu] for %s service ",
|
||||
session->ses_id,
|
||||
service->name)));
|
||||
service->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Started %s client session [%lu] for '%s' from %s",
|
||||
MXS_INFO("Started %s client session [%lu] for '%s' from %s",
|
||||
service->name,
|
||||
session->ses_id,
|
||||
session->client->user,
|
||||
session->client->remote)));
|
||||
session->client->remote);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"Start %s client session [%lu] for '%s' from %s failed, will be "
|
||||
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)));
|
||||
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]",
|
||||
MXS_INFO("Stopped %s client session [%lu]",
|
||||
session->service->name,
|
||||
session->ses_id)));
|
||||
session->ses_id);
|
||||
|
||||
/** Disable trace and decrease trace logger counter */
|
||||
session_disable_log(session, LT);
|
||||
@ -845,10 +831,8 @@ 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")));
|
||||
MXS_ERROR("Insufficient memory to allocate session filter "
|
||||
"tracking.\n");
|
||||
return 0;
|
||||
}
|
||||
session->n_filters = service->n_filters;
|
||||
@ -856,21 +840,16 @@ int i;
|
||||
{
|
||||
if (service->filters[i] == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Service '%s' contians an unresolved filter.\n",
|
||||
service->name)));
|
||||
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 "
|
||||
MXS_ERROR("Failed to create filter '%s' for "
|
||||
"service '%s'.\n",
|
||||
service->filters[i]->name,
|
||||
service->name)));
|
||||
service->name);
|
||||
return 0;
|
||||
}
|
||||
session->filters[i].filter = service->filters[i];
|
||||
@ -886,11 +865,9 @@ 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",
|
||||
MXS_ERROR("Failed to create filter '%s' for service '%s'.",
|
||||
service->filters[i]->name,
|
||||
service->name)));
|
||||
service->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.",
|
||||
MXS_ERROR("Can't GET fcntl for %i, errno = %d, %s.",
|
||||
fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
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",
|
||||
MXS_ERROR("Can't SET fcntl for %i, errno = %d, %s",
|
||||
fd,
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)))));
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user