Small improvements for string buffers
Small improvements an constants added in string buffers
This commit is contained in:
@ -161,6 +161,9 @@
|
|||||||
#define BLR_TYPE_STRING 0xf
|
#define BLR_TYPE_STRING 0xf
|
||||||
#define BLR_TYPE_INT 0x03
|
#define BLR_TYPE_INT 0x03
|
||||||
|
|
||||||
|
/* string len for COM_STATISTICS output */
|
||||||
|
#define BLRM_COM_STATISTICS_SIZE 1000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some useful macros for examining the MySQL Response packets
|
* Some useful macros for examining the MySQL Response packets
|
||||||
*/
|
*/
|
||||||
|
@ -1482,11 +1482,12 @@ ROUTER_SLAVE *slave;
|
|||||||
int
|
int
|
||||||
blr_statistics(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
blr_statistics(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||||
{
|
{
|
||||||
char result[1000], *ptr;
|
char result[BLRM_COM_STATISTICS_SIZE + 1] = "";
|
||||||
|
char *ptr;
|
||||||
GWBUF *ret;
|
GWBUF *ret;
|
||||||
unsigned long len;
|
unsigned long len;
|
||||||
|
|
||||||
snprintf(result, 1000,
|
snprintf(result, BLRM_COM_STATISTICS_SIZE,
|
||||||
"Uptime: %u Threads: %u Events: %u Slaves: %u Master State: %s",
|
"Uptime: %u Threads: %u Events: %u Slaves: %u Master State: %s",
|
||||||
(unsigned int)(time(0) - router->connect_time),
|
(unsigned int)(time(0) - router->connect_time),
|
||||||
(unsigned int)config_threadcount(),
|
(unsigned int)config_threadcount(),
|
||||||
@ -1907,10 +1908,10 @@ static int blr_check_binlog(ROUTER_INSTANCE *router) {
|
|||||||
"blr_read_events_all_events() ret = %i\n", n)));
|
"blr_read_events_all_events() ret = %i\n", n)));
|
||||||
|
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
char msg_err[1024 + 1] = "";
|
char msg_err[BINLOG_ERROR_MSG_LEN + 1] = "";
|
||||||
router->master_state = BLRM_SLAVE_STOPPED;
|
router->master_state = BLRM_SLAVE_STOPPED;
|
||||||
|
|
||||||
snprintf(msg_err, 1024, "Error found in binlog %s. Safe pos is %lu", router->binlog_name, router->binlog_position);
|
snprintf(msg_err, BINLOG_ERROR_MSG_LEN, "Error found in binlog %s. Safe pos is %lu", router->binlog_name, router->binlog_position);
|
||||||
/* set mysql_errno */
|
/* set mysql_errno */
|
||||||
router->m_errno = 2032;
|
router->m_errno = 2032;
|
||||||
|
|
||||||
|
@ -82,7 +82,9 @@ int blr_file_write_master_config(ROUTER_INSTANCE *router, char *error);
|
|||||||
int
|
int
|
||||||
blr_file_init(ROUTER_INSTANCE *router)
|
blr_file_init(ROUTER_INSTANCE *router)
|
||||||
{
|
{
|
||||||
char *ptr, path[PATH_MAX+1], filename[PATH_MAX+1];
|
char *ptr;
|
||||||
|
char path[PATH_MAX+1] = "";
|
||||||
|
char filename[PATH_MAX+1] = "";
|
||||||
int file_found, n = 1;
|
int file_found, n = 1;
|
||||||
int root_len, i;
|
int root_len, i;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
@ -221,7 +223,7 @@ int fd;
|
|||||||
fsync(fd);
|
fsync(fd);
|
||||||
close(router->binlog_fd);
|
close(router->binlog_fd);
|
||||||
spinlock_acquire(&router->binlog_lock);
|
spinlock_acquire(&router->binlog_lock);
|
||||||
strncpy(router->binlog_name, file,BINLOG_FNAMELEN);
|
strncpy(router->binlog_name, file, BINLOG_FNAMELEN);
|
||||||
router->binlog_fd = fd;
|
router->binlog_fd = fd;
|
||||||
spinlock_release(&router->binlog_lock);
|
spinlock_release(&router->binlog_lock);
|
||||||
return 1;
|
return 1;
|
||||||
@ -236,7 +238,7 @@ int fd;
|
|||||||
static void
|
static void
|
||||||
blr_file_append(ROUTER_INSTANCE *router, char *file)
|
blr_file_append(ROUTER_INSTANCE *router, char *file)
|
||||||
{
|
{
|
||||||
char path[1024];
|
char path[PATH_MAX+1] = "";
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
strcpy(path, router->binlogdir);
|
strcpy(path, router->binlogdir);
|
||||||
@ -253,7 +255,7 @@ int fd;
|
|||||||
fsync(fd);
|
fsync(fd);
|
||||||
close(router->binlog_fd);
|
close(router->binlog_fd);
|
||||||
spinlock_acquire(&router->binlog_lock);
|
spinlock_acquire(&router->binlog_lock);
|
||||||
strncpy(router->binlog_name, file,BINLOG_FNAMELEN);
|
strncpy(router->binlog_name, file, BINLOG_FNAMELEN);
|
||||||
router->current_pos = lseek(fd, 0L, SEEK_END);
|
router->current_pos = lseek(fd, 0L, SEEK_END);
|
||||||
if (router->current_pos < 4) {
|
if (router->current_pos < 4) {
|
||||||
if (router->current_pos == 0) {
|
if (router->current_pos == 0) {
|
||||||
@ -327,7 +329,7 @@ blr_file_flush(ROUTER_INSTANCE *router)
|
|||||||
BLFILE *
|
BLFILE *
|
||||||
blr_open_binlog(ROUTER_INSTANCE *router, char *binlog)
|
blr_open_binlog(ROUTER_INSTANCE *router, char *binlog)
|
||||||
{
|
{
|
||||||
char path[1025];
|
char path[PATH_MAX + 1] = "";
|
||||||
BLFILE *file;
|
BLFILE *file;
|
||||||
|
|
||||||
spinlock_acquire(&router->fileslock);
|
spinlock_acquire(&router->fileslock);
|
||||||
@ -347,14 +349,14 @@ BLFILE *file;
|
|||||||
spinlock_release(&router->fileslock);
|
spinlock_release(&router->fileslock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strncpy(file->binlogname, binlog,BINLOG_FNAMELEN+1);
|
strncpy(file->binlogname, binlog, BINLOG_FNAMELEN);
|
||||||
file->refcnt = 1;
|
file->refcnt = 1;
|
||||||
file->cache = 0;
|
file->cache = 0;
|
||||||
spinlock_init(&file->lock);
|
spinlock_init(&file->lock);
|
||||||
|
|
||||||
strncpy(path, router->binlogdir,1024);
|
strncpy(path, router->binlogdir, PATH_MAX);
|
||||||
strncat(path, "/",1024);
|
strncat(path, "/", PATH_MAX);
|
||||||
strncat(path, binlog,1024);
|
strncat(path, binlog, PATH_MAX);
|
||||||
|
|
||||||
if ((file->fd = open(path, O_RDONLY, 0666)) == -1)
|
if ((file->fd = open(path, O_RDONLY, 0666)) == -1)
|
||||||
{
|
{
|
||||||
@ -670,7 +672,8 @@ struct stat statb;
|
|||||||
void
|
void
|
||||||
blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX+1], *ptr;
|
char path[PATH_MAX+1] = "";
|
||||||
|
char *ptr;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
strncpy(path, router->binlogdir, PATH_MAX);
|
strncpy(path, router->binlogdir, PATH_MAX);
|
||||||
@ -706,7 +709,8 @@ GWBUF *
|
|||||||
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
|
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
|
||||||
{
|
{
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
char path[PATH_MAX+1], *ptr;
|
char path[PATH_MAX+1] = "";
|
||||||
|
char *ptr;
|
||||||
int fd;
|
int fd;
|
||||||
GWBUF *buf;
|
GWBUF *buf;
|
||||||
|
|
||||||
|
@ -955,7 +955,7 @@ static int
|
|||||||
blr_slave_send_maxscale_version(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
blr_slave_send_maxscale_version(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
char version[40];
|
char version[80] = "";
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
int len, vers_len;
|
int len, vers_len;
|
||||||
|
|
||||||
@ -1026,7 +1026,7 @@ static int
|
|||||||
blr_slave_send_maxscale_variables(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
blr_slave_send_maxscale_variables(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
char name[40];
|
char name[80];
|
||||||
char version[40];
|
char version[40];
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
int len, vers_len, seqno = 2;
|
int len, vers_len, seqno = 2;
|
||||||
|
Reference in New Issue
Block a user