From 903b906044fe35f0215aeaf8d56ce2b7945ced2e Mon Sep 17 00:00:00 2001 From: Massimiliano Pinto Date: Wed, 3 Jul 2013 09:34:22 +0200 Subject: [PATCH] Added the backend delayq: this will assure incoming data are queued before mysql backend connection is complete After connection data will be written to backend --- include/dcb.h | 2 ++ modules/protocol/mysql_backend.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/dcb.h b/include/dcb.h index aa4b4a0a2..fe9047397 100644 --- a/include/dcb.h +++ b/include/dcb.h @@ -132,6 +132,8 @@ typedef struct dcb { SPINLOCK writeqlock; /**< Write Queue spinlock */ GWBUF *writeq; /**< Write Data Queue */ + SPINLOCK delayqlock; /**< Delay Backend Write Queue spinlock */ + GWBUF *delayq; /**< Delay Backend Write Data Queue */ DCBSTATS stats; /**< DCB related statistics */ diff --git a/modules/protocol/mysql_backend.c b/modules/protocol/mysql_backend.c index ce938acb8..600a847b4 100644 --- a/modules/protocol/mysql_backend.c +++ b/modules/protocol/mysql_backend.c @@ -704,3 +704,25 @@ int gw_mysql_connect(char *host, int port, char *dbname, char *user, uint8_t *pa } +/** + * This routine writes the delayq via dcb_write + * The dcb->delayq contains data received from the client before + * mysql backend authentication succeded + * + * @param dcb The current backend DCB + * @return The dcb_write status + */ +static int backend_write_delayqueue(DCB *dcb) +{ + GWBUF *localq = NULL; + + spinlock_acquire(&dcb->delayqlock); + + localq = dcb->delayq; + dcb->delayq = NULL; + + spinlock_release(&dcb->delayqlock); + + return dcb_write(dcb, localq); +} +/////