diff --git a/server/core/buffer.c b/server/core/buffer.c index d3278a505..54b285dcb 100644 --- a/server/core/buffer.c +++ b/server/core/buffer.c @@ -82,6 +82,7 @@ SHARED_BUF *sbuf; sbuf->refcount = 1; rval->sbuf = sbuf; rval->next = NULL; + rval->hint = NULL; rval->gwbuf_type = GWBUF_TYPE_UNDEFINED; rval->command = 0; CHK_GWBUF(rval); diff --git a/server/include/buffer.h b/server/include/buffer.h index 9729c538c..055fd13bd 100644 --- a/server/include/buffer.h +++ b/server/include/buffer.h @@ -38,10 +38,12 @@ * 10/06/2013 Mark Riddoch Initial implementation * 11/07/2013 Mark Riddoch Addition of reference count in the gwbuf * 16/07/2013 Massimiliano Pinto Added command type for the queue + * 10/07/2014 Mark Riddoch Addition of hints * * @endverbatim */ #include +#include typedef enum @@ -88,6 +90,7 @@ typedef struct gwbuf { SHARED_BUF *sbuf; /*< The shared buffer with the real data */ int command;/*< The command type for the queue */ gwbuf_type_t gwbuf_type; /*< buffer's data type information */ + HINT *hint; /*< Hint data for this buffer */ } GWBUF; /*< diff --git a/server/include/hint.h b/server/include/hint.h new file mode 100644 index 000000000..d18d303fa --- /dev/null +++ b/server/include/hint.h @@ -0,0 +1,59 @@ +#ifndef _HINT_H +#define _ATOMIC_H +/* + * This file is distributed as part of MaxScale. It is free + * software: you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation, + * version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright SkySQL Ab 2014 + */ + +/** + * @file hint.h The generic hint data that may be attached to buffers + * + * @verbatim + * Revision History + * + * Date Who Description + * 10/07/14 Mark Riddoch Initial implementation + * + * @endverbatim + */ + +/** + * The types of hint that are supported by the generic hinting mechanism. + */ +typedef enum { + HINT_ROUTE_TO_MASTER = 1, + HINT_ROUTE_TO_SLAVE, + HINT_ROUTE_TO_NAMED_SERVER, + HINT_ROUTE_TO_UPTODATE_SERVER +} HINT_TYPE; + +/** + * A generic hint. + * + * A hint has a type associated with it and may optionally have hint + * specific data. + * Multiple hints may be attached to a single buffer. + */ +typedef struct hint { + HINT_TYPE type; /*< The Type of hint */ + void *data; /*< Type sepecific data */ + unsigned int dsize; /*< Size of the hint data */ + struct hint *next; /*< Another hint for this buffer */ +} HINT; + +extern HINT *hint_alloc(HINT_TYPE, void *, unsigned int); +extern void hint_free(HINT *); +#endif