Merge branch 'develop' into 1.2.1-binlog_router
Conflicts: server/core/server.c server/include/server.h server/modules/include/blr.h server/modules/routing/binlog/blr.c server/modules/routing/binlog/blr_file.c server/modules/routing/binlog/blr_master.c server/modules/routing/binlog/blr_slave.c
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
*
|
||||
* Date Who Description
|
||||
* 14/04/2014 Mark Riddoch Initial implementation
|
||||
* 07/05/2015 Massimiliano Pinto Added MAX_EVENT_TYPE_MARIADB10
|
||||
* 08/06/2015 Massimiliano Pinto Addition of blr_cache_read_master_data()
|
||||
* 15/06/2015 Massimiliano Pinto Addition of blr_file_get_next_binlogname()
|
||||
* 23/06/2015 Massimiliano Pinto Addition of blr_file_use_binlog, blr_file_create_binlog
|
||||
@ -50,7 +51,7 @@
|
||||
#include <blr.h>
|
||||
#include <dcb.h>
|
||||
#include <spinlock.h>
|
||||
|
||||
#include <gwdirs.h>
|
||||
#include <skygw_types.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
@ -62,7 +63,6 @@ extern __thread log_info_t tls_log_info;
|
||||
|
||||
static int blr_file_create(ROUTER_INSTANCE *router, char *file);
|
||||
static void blr_file_append(ROUTER_INSTANCE *router, char *file);
|
||||
static uint32_t extract_field(uint8_t *src, int bits);
|
||||
static void blr_log_header(logfile_id_t file, char *msg, uint8_t *ptr);
|
||||
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
||||
int blr_file_get_next_binlogname(ROUTER_INSTANCE *router);
|
||||
@ -81,7 +81,7 @@ int blr_file_write_master_config(ROUTER_INSTANCE *router, char *error);
|
||||
int
|
||||
blr_file_init(ROUTER_INSTANCE *router)
|
||||
{
|
||||
char *ptr, path[PATH_MAX], filename[PATH_MAX];
|
||||
char *ptr, path[PATH_MAX+1], filename[PATH_MAX+1];
|
||||
int file_found, n = 1;
|
||||
int root_len, i;
|
||||
DIR *dirp;
|
||||
@ -89,12 +89,8 @@ struct dirent *dp;
|
||||
|
||||
if (router->binlogdir == NULL)
|
||||
{
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr,PATH_MAX);
|
||||
}
|
||||
strncat(path, "/",PATH_MAX);
|
||||
strcpy(path, get_datadir());
|
||||
strncat(path,"/",PATH_MAX);
|
||||
strncat(path, router->service->name,PATH_MAX);
|
||||
|
||||
if (access(path, R_OK) == -1)
|
||||
@ -452,15 +448,26 @@ struct stat statb;
|
||||
hdr->next_pos = EXTRACT32(&hdbuf[13]);
|
||||
hdr->flags = EXTRACT16(&hdbuf[17]);
|
||||
|
||||
if (hdr->event_type > MAX_EVENT_TYPE)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Invalid event type 0x%x. "
|
||||
if (router->mariadb10_compat) {
|
||||
if (hdr->event_type > MAX_EVENT_TYPE_MARIADB10) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Invalid MariaDB 10 event type 0x%x. "
|
||||
"Binlog file is %s, position %d",
|
||||
hdr->event_type,
|
||||
file->binlogname, pos)));
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (hdr->event_type > MAX_EVENT_TYPE) {
|
||||
LOGIF(LE, (skygw_log_write(LOGFILE_ERROR,
|
||||
"Invalid event type 0x%x. "
|
||||
"Binlog file is %s, position %d",
|
||||
hdr->event_type,
|
||||
file->binlogname, pos)));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (hdr->next_pos < pos && hdr->event_type != ROTATE_EVENT)
|
||||
{
|
||||
@ -600,26 +607,6 @@ blr_close_binlog(ROUTER_INSTANCE *router, BLFILE *file)
|
||||
free(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a numeric field from a packet of the specified number of bits
|
||||
*
|
||||
* @param src The raw packet source
|
||||
* @param birs The number of bits to extract (multiple of 8)
|
||||
*/
|
||||
static uint32_t
|
||||
extract_field(uint8_t *src, int bits)
|
||||
{
|
||||
uint32_t rval = 0, shift = 0;
|
||||
|
||||
while (bits > 0)
|
||||
{
|
||||
rval |= (*src++) << shift;
|
||||
shift += 8;
|
||||
bits -= 8;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the event header of binlog event
|
||||
*
|
||||
@ -671,10 +658,10 @@ struct stat statb;
|
||||
void
|
||||
blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
||||
{
|
||||
char path[4097], *ptr;
|
||||
char path[PATH_MAX+1], *ptr;
|
||||
int fd;
|
||||
|
||||
strncpy(path, router->binlogdir, 4096);
|
||||
strncpy(path, router->binlogdir, PATH_MAX);
|
||||
strncat(path, "/cache", 4096);
|
||||
|
||||
if (access(path, R_OK) == -1) {
|
||||
@ -682,8 +669,8 @@ int fd;
|
||||
mkdir_ret = mkdir(path, 0700);
|
||||
}
|
||||
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, response, 4096);
|
||||
strncat(path, "/", PATH_MAX);
|
||||
strncat(path, response, PATH_MAX);
|
||||
|
||||
if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
|
||||
return;
|
||||
@ -707,14 +694,14 @@ GWBUF *
|
||||
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
|
||||
{
|
||||
struct stat statb;
|
||||
char path[4097], *ptr;
|
||||
char path[PATH_MAX+1], *ptr;
|
||||
int fd;
|
||||
GWBUF *buf;
|
||||
|
||||
strncpy(path, router->binlogdir, 4096);
|
||||
strncat(path, "/cache", 4096);
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, response, 4096);
|
||||
strncpy(path, router->binlogdir, PATH_MAX);
|
||||
strncat(path, "/cache", PATH_MAX);
|
||||
strncat(path, "/", PATH_MAX);
|
||||
strncat(path, response, PATH_MAX);
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) == -1)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user