Merge branch 'develop' into MAX-324

Conflicts:
	macros.cmake
	server/core/config.c
	server/core/service.c
	server/modules/routing/CMakeLists.txt
This commit is contained in:
Markus Makela
2015-02-24 06:26:55 +02:00
36 changed files with 9590 additions and 308 deletions

View File

@ -1,5 +1,8 @@
if(BUILD_TESTS)
add_subdirectory(test)
add_library(testroute SHARED testroute.c)
target_link_libraries(testroute log_manager utils)
install(TARGETS testroute DESTINATION modules)
endif()
add_library(testroute SHARED testroute.c)

View File

@ -432,7 +432,7 @@ unsigned char *defuuid;
* Now start the replication from the master to MaxScale
*/
blr_start_master(inst);
free(name);
return (ROUTER *)inst;
}

View File

@ -668,7 +668,7 @@ GWBUF *
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
{
struct stat statb;
char path[4096], *ptr;
char path[4097], *ptr;
int fd;
GWBUF *buf;

View File

@ -142,6 +142,7 @@ GWBUF *buf;
sprintf(name, "%s Master", router->service->name);
hktask_oneshot(name, blr_start_master, router,
BLR_MASTER_BACKOFF_TIME * router->retry_backoff++);
free(name);
}
if (router->retry_backoff > BLR_MAX_BACKOFF)
router->retry_backoff = BLR_MAX_BACKOFF;
@ -203,11 +204,12 @@ GWBUF *ptr;
router->master_state = BLRM_UNCONNECTED;
if ((name = malloc(strlen(router->service->name)
+ strlen(" Master")+1)) != NULL);
+ strlen(" Master")+1)) != NULL)
{
sprintf(name, "%s Master", router->service->name);
hktask_oneshot(name, blr_start_master, router,
BLR_MASTER_BACKOFF_TIME * router->retry_backoff++);
free(name);
}
if (router->retry_backoff > BLR_MAX_BACKOFF)
router->retry_backoff = BLR_MAX_BACKOFF;
@ -283,10 +285,11 @@ blr_master_delayed_connect(ROUTER_INSTANCE *router)
char *name;
if ((name = malloc(strlen(router->service->name)
+ strlen(" Master Recovery")+1)) != NULL);
+ strlen(" Master Recovery")+1)) != NULL)
{
sprintf(name, "%s Master Recovery", router->service->name);
hktask_oneshot(name, blr_start_master, router, 60);
free(name);
}
}
@ -407,6 +410,7 @@ char query[128];
}
router->master_state = BLRM_HBPERIOD;
router->master->func.write(router->master, buf);
free(val);
break;
}
case BLRM_HBPERIOD:
@ -511,7 +515,7 @@ char query[128];
GWBUF_CONSUME_ALL(router->saved_master.select1);
router->saved_master.select1 = buf;
blr_cache_response(router, "select1", buf);
buf = blr_make_query("SELECT VERSION();");
buf = blr_make_query("SELECT VERSION()");
router->master_state = BLRM_SELECTVER;
router->master->func.write(router->master, buf);
break;
@ -521,7 +525,7 @@ char query[128];
GWBUF_CONSUME_ALL(router->saved_master.selectver);
router->saved_master.selectver = buf;
blr_cache_response(router, "selectver", buf);
buf = blr_make_query("SELECT @@version_comment limit 1;");
buf = blr_make_query("SELECT @@version_comment limit 1");
router->master_state = BLRM_SELECTVERCOM;
router->master->func.write(router->master, buf);
break;
@ -531,7 +535,7 @@ char query[128];
GWBUF_CONSUME_ALL(router->saved_master.selectvercom);
router->saved_master.selectvercom = buf;
blr_cache_response(router, "selectvercom", buf);
buf = blr_make_query("SELECT @@hostname;");
buf = blr_make_query("SELECT @@hostname");
router->master_state = BLRM_SELECTHOSTNAME;
router->master->func.write(router->master, buf);
break;
@ -541,7 +545,7 @@ char query[128];
GWBUF_CONSUME_ALL(router->saved_master.selecthostname);
router->saved_master.selecthostname = buf;
blr_cache_response(router, "selecthostname", buf);
buf = blr_make_query("SELECT @@max_allowed_packet;");
buf = blr_make_query("SELECT @@max_allowed_packet");
router->master_state = BLRM_MAP;
router->master->func.write(router->master, buf);
break;
@ -701,7 +705,7 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
{
uint8_t *msg = NULL, *ptr, *pdata;
REP_HEADER hdr;
unsigned int len, reslen;
unsigned int len = 0, reslen;
unsigned int pkt_length;
int no_residual = 1;
int preslen = -1;

View File

@ -1371,7 +1371,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
GWBUF *head, *record;
REP_HEADER hdr;
int written, rval = 1, burst;
int rotating;
int rotating = 0;
unsigned long burst_size;
uint8_t *ptr;

View File

@ -3756,7 +3756,7 @@ static GWBUF* sescmd_cursor_process_replies(
dcb_close(bref->bref_dcb);
*reconnect = true;
if(replybuf)
gwbuf_free(replybuf);
gwbuf_consume(replybuf,gwbuf_length(replybuf));
}
}
/** This is a response from the master and it is the "right" one.

View File

@ -33,9 +33,16 @@ static void *newSession(ROUTER *instance, SESSION *session);
static void closeSession(ROUTER *instance, void *session);
static void freeSession(ROUTER *instance, void *session);
static int routeQuery(ROUTER *instance, void *session, GWBUF *queue);
static void clientReply(ROUTER *instance, void *session, GWBUF *queue);
static void diagnostic(ROUTER *instance, DCB *dcb);
static uint8_t getCapabilities (ROUTER* inst, void* router_session);
static void handleError(
ROUTER *instance,
void *router_session,
GWBUF *errbuf,
DCB *backend_dcb,
error_action_t action,
bool *succp);
static ROUTER_OBJECT MyObject = {
createInstance,
@ -44,11 +51,17 @@ static ROUTER_OBJECT MyObject = {
freeSession,
routeQuery,
diagnostic,
NULL,
NULL,
clientReply,
handleError,
getCapabilities
};
typedef struct{
}TESTROUTER;
typedef struct{
}TESTSESSION;
/**
* Implementation of the mandatory version entry point
*
@ -96,7 +109,8 @@ GetModuleObject()
static ROUTER *
createInstance(SERVICE *service, char **options)
{
return NULL;
return (ROUTER*)malloc(sizeof(TESTROUTER));
}
/**
@ -109,7 +123,7 @@ createInstance(SERVICE *service, char **options)
static void *
newSession(ROUTER *instance, SESSION *session)
{
return NULL;
return (SESSION*)malloc(sizeof(TESTSESSION));
}
/**
@ -128,7 +142,7 @@ static void freeSession(
ROUTER* router_instance,
void* router_client_session)
{
return;
free(router_client_session);
}
static int
@ -137,6 +151,10 @@ routeQuery(ROUTER *instance, void *session, GWBUF *queue)
return 0;
}
void clientReply(ROUTER* instance, void* session, GWBUF* queue)
{
}
/**
* Diagnostics routine
*
@ -154,3 +172,14 @@ static uint8_t getCapabilities(
{
return 0;
}
static void handleError(
ROUTER *instance,
void *router_session,
GWBUF *errbuf,
DCB *backend_dcb,
error_action_t action,
bool *succp)
{
}