gw_buffer was not freed.

This commit is contained in:
vraatikka 2013-10-14 13:16:33 +03:00
parent 42417797a9
commit 0f2eeff243
3 changed files with 23 additions and 17 deletions

View File

@ -61,28 +61,27 @@ typedef struct {
* be copied within the gateway.
*/
typedef struct gwbuf {
struct gwbuf *next; /**< Next buffer in a linked chain of buffers */
void *start; /**< Start of the valid data */
void *end; /**< First byte after the valid data */
SHARED_BUF *sbuf; /**< The shared buffer with the real data */
int command; /**< The command type for the queue */
struct gwbuf *next; /**< Next buffer in a linked chain of buffers */
void *start; /**< Start of the valid data */
void *end; /**< First byte after the valid data */
SHARED_BUF *sbuf; /**< The shared buffer with the real data */
int command;/**< The command type for the queue */
} GWBUF;
/*
* Macros to access the data in the buffers
*/
#define GWBUF_DATA(b) ((b)->start) /**< First valid, uncomsumed
* byte in the buffer
*/
#define GWBUF_LENGTH(b) ((b)->end - (b)->start) /**< Number of bytes in the
* individual buffer
*/
#define GWBUF_EMPTY(b) ((b)->start == (b)->end) /**< True if all bytes in the
* buffer have been consumed
*/
#define GWBUF_CONSUME(b, bytes) (b)->start += bytes /**< Consume a number of bytes
* in the buffer
*/
/**< First valid, uncomsumed byte in the buffer */
#define GWBUF_DATA(b) ((b)->start)
/**< Number of bytes in the individual buffer */
#define GWBUF_LENGTH(b) ((b)->end - (b)->start)
/**< True if all bytes in the buffer have been consumed */
#define GWBUF_EMPTY(b) ((b)->start == (b)->end)
/**< Consume a number of bytes in the buffer */
#define GWBUF_CONSUME(b, bytes) (b)->start += bytes
/*
* Function prototypes for the API to maniplate the buffers

View File

@ -661,6 +661,7 @@ int gw_read_client_event(DCB* dcb) {
* Read all the data that is available into a chain of buffers
*/
{
int len = -1;
GWBUF *queue = NULL;
GWBUF *gw_buffer = NULL;
uint8_t *ptr_buff = NULL;
@ -688,6 +689,7 @@ int gw_read_client_event(DCB* dcb) {
/* Now, we are assuming in the first buffer there is
* the information form mysql command */
queue = gw_buffer;
len = GWBUF_LENGTH(queue);
ptr_buff = GWBUF_DATA(queue);
/* get mysql commang at fifth byte */
@ -721,6 +723,8 @@ int gw_read_client_event(DCB* dcb) {
protocol->state = MYSQL_IDLE;
}
rc = 1;
/** Free buffer */
queue = gwbuf_consume(queue, len);
goto return_rc;
}
/** Route COM_QUIT to backend */
@ -758,6 +762,8 @@ int gw_read_client_event(DCB* dcb) {
protocol->state = MYSQL_IDLE;
}
}
/** Free buffer */
queue = gwbuf_consume(queue, len);
goto return_rc;
} /* MYSQL_IDLE */
break;

View File

@ -805,6 +805,7 @@ mysql_send_custom_error (DCB *dcb, int packet_number, int in_affected_rows, cons
// writing data in the Client buffer queue
dcb->func.write(dcb, buf);
gwbuf_free(buf);
return sizeof(mysql_packet_header) + mysql_payload_size;
}