Cleanup of fprintf's
This commit is contained in:
parent
016e759b2b
commit
6ed63b12d4
@ -142,6 +142,7 @@ char fname[1024], *home, *cpasswd;
|
||||
sprintf(fname, "/usr/local/skysql/MaxScale/etc/passwd");
|
||||
if (users == NULL)
|
||||
{
|
||||
skygw_log_write(NULL, LOGFILE_MESSAGE, "Create initial password file.\n");
|
||||
if ((users = users_alloc()) == NULL)
|
||||
return ADMIN_ERR_NOMEM;
|
||||
if ((fp = fopen(fname, "w")) == NULL)
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include <server.h>
|
||||
#include <users.h>
|
||||
#include <monitor.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
static int process_config_context(CONFIG_CONTEXT *);
|
||||
static int process_config_update(CONFIG_CONTEXT *);
|
||||
@ -168,7 +170,7 @@ CONFIG_CONTEXT *obj;
|
||||
{
|
||||
char *type = config_get_value(obj->parameters, "type");
|
||||
if (type == NULL)
|
||||
fprintf(stderr, "Object %s has no type\n", obj->object);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Object %s has no type\n", obj->object);
|
||||
else if (!strcmp(type, "service"))
|
||||
{
|
||||
char *router = config_get_value(obj->parameters, "router");
|
||||
@ -181,7 +183,7 @@ CONFIG_CONTEXT *obj;
|
||||
serviceSetUser(obj->element, user, auth);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "No router define for service '%s'\n",
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "No router define for service '%s'\n",
|
||||
obj->object);
|
||||
}
|
||||
else if (!strcmp(type, "server"))
|
||||
@ -397,7 +399,7 @@ SERVER *server;
|
||||
{
|
||||
char *type = config_get_value(obj->parameters, "type");
|
||||
if (type == NULL)
|
||||
fprintf(stderr, "Object %s has no type\n", obj->object);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Object %s has no type\n", obj->object);
|
||||
else if (!strcmp(type, "service"))
|
||||
{
|
||||
char *router = config_get_value(obj->parameters, "router");
|
||||
@ -420,7 +422,7 @@ SERVER *server;
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "No router defined for service '%s'\n",
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "No router defined for service '%s'\n",
|
||||
obj->object);
|
||||
}
|
||||
else if (!strcmp(type, "server"))
|
||||
|
@ -107,7 +107,7 @@ getUsers(SERVICE *service, struct users *users)
|
||||
con = mysql_init(NULL);
|
||||
|
||||
if (con == NULL) {
|
||||
fprintf(stderr, "%s\n", mysql_error(con));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "mysql_init: %s\n", mysql_error(con));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -135,13 +135,17 @@ getUsers(SERVICE *service, struct users *users)
|
||||
}
|
||||
if (server == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s\n", mysql_error(con));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Unable to find a to load user data from for service %s\n",
|
||||
service->name);
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mysql_query(con, "SELECT user, password FROM mysql.user")) {
|
||||
fprintf(stderr, ">>>>> %s\n", mysql_error(con));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Loading users for service %s encountered error: %s\n",
|
||||
service->name, mysql_error(con));
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -149,7 +153,9 @@ getUsers(SERVICE *service, struct users *users)
|
||||
result = mysql_store_result(con);
|
||||
|
||||
if (result == NULL) {
|
||||
fprintf(stderr, "%s\n", mysql_error(con));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Loading users for service %s encountered error: %s\n",
|
||||
service->name, mysql_error(con));
|
||||
mysql_close(con);
|
||||
return -1;
|
||||
}
|
||||
@ -158,8 +164,6 @@ getUsers(SERVICE *service, struct users *users)
|
||||
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
// we assume here two fields are returned !!!
|
||||
//printf("User %s , Passwd %s\n", row[0], row[1]);
|
||||
|
||||
// now adding to the hastable user and passwd+1 (escaping the first byte that is '*')
|
||||
users_add(users, row[0], row[1]+1);
|
||||
total_users++;
|
||||
@ -171,5 +175,3 @@ getUsers(SERVICE *service, struct users *users)
|
||||
return total_users;
|
||||
|
||||
}
|
||||
/////
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
* for handling backend asynchronous protocol connection
|
||||
* and a generic lock for backend authentication
|
||||
* 16/07/2013 Massimiliano Pinto Added command type for dcb
|
||||
* 23/07/13 Mark Riddoch Tidy up logging
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -57,6 +58,8 @@
|
||||
#include <gw.h>
|
||||
#include <poll.h>
|
||||
#include <atomic.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
static DCB *allDCBs = NULL; /* Diagnotics need a list of DCBs */
|
||||
static DCB *zombies = NULL;
|
||||
@ -262,7 +265,8 @@ GWPROTOCOL *funcs;
|
||||
if ((funcs = (GWPROTOCOL *)load_module(protocol, MODULE_PROTOCOL)) == NULL)
|
||||
{
|
||||
dcb_final_free(dcb);
|
||||
fprintf(stderr, "Failed to load protocol module for %s, feee dcb %p\n", protocol, dcb);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Failed to load protocol module for %s, feee dcb %p\n", protocol, dcb);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(&(dcb->func), funcs, sizeof(GWPROTOCOL));
|
||||
@ -271,7 +275,8 @@ GWPROTOCOL *funcs;
|
||||
if ((dcb->fd = dcb->func.connect(dcb, server, session)) == -1)
|
||||
{
|
||||
dcb_final_free(dcb);
|
||||
fprintf(stderr, "Failed to connect to server, feee dcb %p\n", dcb);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Failed to connect to server %s:%d, free dcb %p\n",
|
||||
server->name, server->port, dcb);
|
||||
return NULL;
|
||||
}
|
||||
atomic_add(&server->stats.n_connections, 1);
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include <modules.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
static MODULES *registered = NULL;
|
||||
|
||||
@ -79,19 +81,22 @@ MODULES *mod;
|
||||
sprintf(fname, "%s/modules/lib%s.so", home, module);
|
||||
if (access(fname, F_OK) == -1)
|
||||
{
|
||||
fprintf(stderr, "Unable to find library for module: %s\n", module);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Unable to find library for module: %s\n", module);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if ((dlhandle = dlopen(fname, RTLD_NOW|RTLD_LOCAL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load library for module: %s, %s\n", module, dlerror());
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Unable to load library for module: %s, %s\n", module, dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((sym = dlsym(dlhandle, "version")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Version interface not supported by module: %s, %s\n", module, dlerror());
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Version interface not supported by module: %s, %s\n", module, dlerror());
|
||||
dlclose(dlhandle);
|
||||
return NULL;
|
||||
}
|
||||
@ -109,14 +114,15 @@ MODULES *mod;
|
||||
|
||||
if ((sym = dlsym(dlhandle, "GetModuleObject")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Expected entry point interface missing from module: %s, %s\n", module, dlerror());
|
||||
skygw_log_write(NULL, LOGFILE_ERROR,
|
||||
"Expected entry point interface missing from module: %s, %s\n", module, dlerror());
|
||||
dlclose(dlhandle);
|
||||
return NULL;
|
||||
}
|
||||
ep = sym;
|
||||
modobj = ep();
|
||||
|
||||
fprintf(stderr, "Loaded module %s: %s\n", module, version);
|
||||
skygw_log_write(NULL, LOGFILE_MESSAGE, "Loaded module %s: %s\n", module, version);
|
||||
register_module(module, type, dlhandle, version, modobj);
|
||||
}
|
||||
else
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <monitor.h>
|
||||
#include <spinlock.h>
|
||||
#include <modules.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
|
||||
static MONITOR *allMonitors = NULL;
|
||||
@ -59,7 +61,7 @@ MONITOR *mon;
|
||||
mon->name = strdup(name);
|
||||
if ((mon->module = load_module(module, MODULE_MONITOR)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to load monitor module '%s'\n", name);
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Unable to load monitor module '%s'\n", name);
|
||||
free(mon->name);
|
||||
free(mon);
|
||||
return NULL;
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <mysql_protocol.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <poll.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
// used in the hex2bin function
|
||||
#define char_val(X) (X >= '0' && X <= '9' ? X-'0' :\
|
||||
@ -60,12 +62,12 @@ int setnonblocking(int fd) {
|
||||
int fl;
|
||||
|
||||
if ((fl = fcntl(fd, F_GETFL, 0)) == -1) {
|
||||
fprintf(stderr, "Can't GET fcntli for %i, errno = %d, %s", fd, errno, strerror(errno));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Can't GET fcntl for %i, errno = %d, %s", fd, errno, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) {
|
||||
fprintf(stderr, "Can't SET fcntl for %i, errno = %d, %s", fd, errno, strerror(errno));
|
||||
skygw_log_write(NULL, LOGFILE_ERROR, "Can't SET fcntl for %i, errno = %d, %s", fd, errno, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user