Small improvements

Small improvements
This commit is contained in:
MassimilianoPinto
2015-08-04 16:39:03 +02:00
parent 1fc335e5f7
commit 619261cd21
2 changed files with 22 additions and 17 deletions

View File

@ -595,8 +595,8 @@ int rc = 0;
{ {
sprintf(name, "%s stats", service->name); sprintf(name, "%s stats", service->name);
hktask_add(name, stats_func, inst, BLR_STATS_FREQ); hktask_add(name, stats_func, inst, BLR_STATS_FREQ);
}
free(name); free(name);
}
/* /*
* Now start the replication from the master to MaxScale * Now start the replication from the master to MaxScale
@ -1649,7 +1649,12 @@ char *service_passwd = NULL;
return 0; return 0;
} }
/* -1 is failure, >0 is success */ /**
* Load mysql dbusers into (service->users)
*
* @param router The router instance
* @return -1 on failure, 0 for no users found, > 0 for found users
*/
int int
blr_load_dbusers(ROUTER_INSTANCE *router) blr_load_dbusers(ROUTER_INSTANCE *router)
{ {
@ -1717,7 +1722,12 @@ SERVICE *service;
return loaded; return loaded;
} }
/* -1 is error, >= 0 is ok */ /**
* Save dbusers to cache file
*
* @param router The router instance
* @return -1 on failure, >= 0 on success
*/
int int
blr_save_dbusers(ROUTER_INSTANCE *router) blr_save_dbusers(ROUTER_INSTANCE *router)
{ {

View File

@ -101,7 +101,6 @@ blr_start_master(void* data)
{ {
ROUTER_INSTANCE *router = (ROUTER_INSTANCE*)data; ROUTER_INSTANCE *router = (ROUTER_INSTANCE*)data;
DCB *client; DCB *client;
GWBUF *buf;
router->stats.n_binlogs_ses = 0; router->stats.n_binlogs_ses = 0;
spinlock_acquire(&router->lock); spinlock_acquire(&router->lock);
@ -122,10 +121,9 @@ GWBUF *buf;
router->master_state = BLRM_CONNECTING; router->master_state = BLRM_CONNECTING;
/* Discard the queued residual data */ /* Discard the queued residual data */
buf = router->residual; while (router->residual)
while (buf)
{ {
buf = gwbuf_consume(buf, GWBUF_LENGTH(buf)); router->residual = gwbuf_consume(router->residual, GWBUF_LENGTH(router->residual));
} }
router->residual = NULL; router->residual = NULL;
@ -177,8 +175,7 @@ if (setsockopt(router->master->fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive , sizeof
perror("setsockopt"); perror("setsockopt");
router->master_state = BLRM_AUTHENTICATED; router->master_state = BLRM_AUTHENTICATED;
buf = blr_make_query("SELECT UNIX_TIMESTAMP()"); router->master->func.write(router->master, blr_make_query("SELECT UNIX_TIMESTAMP()"));
router->master->func.write(router->master, buf);
router->master_state = BLRM_TIMESTAMP; router->master_state = BLRM_TIMESTAMP;
router->stats.n_masterstarts++; router->stats.n_masterstarts++;
@ -195,15 +192,12 @@ perror("setsockopt");
static void static void
blr_restart_master(ROUTER_INSTANCE *router) blr_restart_master(ROUTER_INSTANCE *router)
{ {
GWBUF *ptr;
dcb_close(router->client); dcb_close(router->client);
/* Discard the queued residual data */ /* Discard the queued residual data */
ptr = router->residual; while (router->residual)
while (ptr)
{ {
ptr = gwbuf_consume(ptr, GWBUF_LENGTH(ptr)); router->residual = gwbuf_consume(router->residual, GWBUF_LENGTH(router->residual));
} }
router->residual = NULL; router->residual = NULL;
@ -1497,7 +1491,8 @@ int action;
static void static void
blr_log_packet(logfile_id_t file, char *msg, uint8_t *ptr, int len) blr_log_packet(logfile_id_t file, char *msg, uint8_t *ptr, int len)
{ {
char buf[400], *bufp; char buf[400] = "";
char *bufp;
int i; int i;
bufp = buf; bufp = buf;