Add fix for duplicating COM_QUIT, COM_INIT_DB and COM_CHANGE_USER packets
This commit is contained in:
@ -41,6 +41,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 20/06/2014 Mark Riddoch Initial implementation
|
* 20/06/2014 Mark Riddoch Initial implementation
|
||||||
* 24/06/2014 Mark Riddoch Addition of support for multi-packet queries
|
* 24/06/2014 Mark Riddoch Addition of support for multi-packet queries
|
||||||
|
* 12/12/2014 Mark Riddoch Add support for otehr packet types
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -58,6 +59,10 @@
|
|||||||
#include <router.h>
|
#include <router.h>
|
||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
|
|
||||||
|
#define MYSQL_COM_QUIT 0x01
|
||||||
|
#define MYSQL_COM_INITDB 0x02
|
||||||
|
#define MYSQL_COM_CHANGE_USER 0x11
|
||||||
|
|
||||||
/** Defined in log_manager.cc */
|
/** Defined in log_manager.cc */
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
extern size_t log_ses_count[];
|
extern size_t log_ses_count[];
|
||||||
@ -128,6 +133,7 @@ typedef struct {
|
|||||||
int residual; /* Any outstanding SQL text */
|
int residual; /* Any outstanding SQL text */
|
||||||
} TEE_SESSION;
|
} TEE_SESSION;
|
||||||
|
|
||||||
|
static int packet_is_required(GWBUF *queue);
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
*
|
*
|
||||||
@ -429,6 +435,10 @@ GWBUF *clone = NULL;
|
|||||||
}
|
}
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
else if (packet_is_required(queue))
|
||||||
|
{
|
||||||
|
clone = gwbuf_clone(queue);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pass the query downstream */
|
/* Pass the query downstream */
|
||||||
rval = my_session->down.routeQuery(my_session->down.instance,
|
rval = my_session->down.routeQuery(my_session->down.instance,
|
||||||
@ -484,3 +494,25 @@ TEE_SESSION *my_session = (TEE_SESSION *)fsession;
|
|||||||
my_session->n_rejected);
|
my_session->n_rejected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the packet is a command that must be sent to the branch
|
||||||
|
* to maintain the session consistancy. These are COM_INIT_DB,
|
||||||
|
* COM_CHANGE_USER and COM_QUIT packets.
|
||||||
|
*
|
||||||
|
* @param queue The buffer to check
|
||||||
|
* @return non-zero if the packet should be sent to the branch
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
packet_is_required(GWBUF *queue)
|
||||||
|
{
|
||||||
|
uint8_t *ptr;
|
||||||
|
|
||||||
|
ptr = GWBUF_DATA(queue);
|
||||||
|
if (GWBUF_LENGTH(queue) > 4 &&
|
||||||
|
(ptr[4] == MYSQL_COM_QUIT || ptr[4] == MYSQL_COM_INITDB
|
||||||
|
|| ptr[4] == MYSQL_COM_CHANGE_USER))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user