summaryrefslogtreecommitdiff
path: root/wsrep
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@skysql.com>2014-03-25 17:01:05 -0400
committerNirbhay Choubey <nirbhay@skysql.com>2014-03-25 17:01:05 -0400
commit899f9801d4466a6ecccd32a34a38aaf19019e39a (patch)
tree67d0be09c93257a3eb9f687af2ffeca172a05bec /wsrep
parent3088d52c20eca10e5b8689648edef8f7fd49830a (diff)
downloadmariadb-git-899f9801d4466a6ecccd32a34a38aaf19019e39a.tar.gz
bzr merge -r3946..3968 codership/5.5
Diffstat (limited to 'wsrep')
-rw-r--r--wsrep/wsrep_api.h4
-rw-r--r--wsrep/wsrep_dummy.c49
2 files changed, 48 insertions, 5 deletions
diff --git a/wsrep/wsrep_api.h b/wsrep/wsrep_api.h
index f713de66d57..c3304d7ed7c 100644
--- a/wsrep/wsrep_api.h
+++ b/wsrep/wsrep_api.h
@@ -137,7 +137,11 @@ typedef void (*wsrep_log_cb_t)(wsrep_log_level_t, const char *);
typedef uint64_t wsrep_trx_id_t; //!< application transaction ID
typedef uint64_t wsrep_conn_id_t; //!< application connection ID
typedef int64_t wsrep_seqno_t; //!< sequence number of a writeset, etc.
+#ifdef __cplusplus
+typedef bool wsrep_bool_t;
+#else
typedef _Bool wsrep_bool_t; //!< should be the same as standard (C99) bool
+#endif /* __cplusplus */
/*! undefined seqno */
#define WSREP_SEQNO_UNDEFINED (-1)
diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c
index 3c7a7c2e354..7b86e2e386a 100644
--- a/wsrep/wsrep_dummy.c
+++ b/wsrep/wsrep_dummy.c
@@ -20,11 +20,13 @@
#include <errno.h>
#include <stdbool.h>
+#include <string.h>
/*! Dummy backend context. */
typedef struct wsrep_dummy
{
wsrep_log_cb_t log_fn;
+ char* options;
} wsrep_dummy_t;
/* Get pointer to wsrep_dummy context from wsrep_t pointer */
@@ -42,6 +44,10 @@ typedef struct wsrep_dummy
static void dummy_free(wsrep_t *w)
{
WSREP_DBUG_ENTER(w);
+ if (WSREP_DUMMY(w)->options)
+ {
+ free(WSREP_DUMMY(w)->options);
+ }
free(w->ctx);
w->ctx = NULL;
}
@@ -49,8 +55,15 @@ static void dummy_free(wsrep_t *w)
static wsrep_status_t dummy_init (wsrep_t* w,
const struct wsrep_init_args* args)
{
- WSREP_DUMMY(w)->log_fn = args->logger_cb;
WSREP_DBUG_ENTER(w);
+ WSREP_DUMMY(w)->log_fn = args->logger_cb;
+ if (args->options)
+ {
+ char* options = malloc(strlen(args->options) + 1);
+ if (options == NULL) return WSREP_WARNING;
+ strcpy(options, args->options);
+ WSREP_DUMMY(w)->options = options;
+ }
return WSREP_OK;
}
@@ -61,16 +74,41 @@ static uint64_t dummy_capabilities (wsrep_t* w __attribute__((unused)))
static wsrep_status_t dummy_options_set(
wsrep_t* w,
- const char* conf __attribute__((unused)))
-{
- WSREP_DBUG_ENTER(w);
+ const char* conf)
+{
+ char* options = NULL;
+ WSREP_DBUG_ENTER(w);
+ // concatenate config string with ';'
+ options = WSREP_DUMMY(w)->options;
+ if (options == NULL)
+ {
+ options = malloc(strlen(conf) + 1);
+ if (options == NULL)
+ {
+ return WSREP_WARNING;
+ }
+ strcpy(options, conf);
+ } else {
+ int opt_len = strlen(options);
+ char* p = realloc(options,
+ opt_len + 1 + // ';'
+ strlen(conf) + 1); // \0
+ if (p == NULL)
+ {
+ return WSREP_WARNING;
+ }
+ p[opt_len] = ';';
+ strcpy(p + opt_len + 1, conf);
+ options = p;
+ }
+ WSREP_DUMMY(w)->options = options;
return WSREP_OK;
}
static char* dummy_options_get (wsrep_t* w)
{
WSREP_DBUG_ENTER(w);
- return NULL;
+ return WSREP_DUMMY(w)->options;
}
static wsrep_status_t dummy_connect(
@@ -385,6 +423,7 @@ int wsrep_dummy_loader(wsrep_t* w)
// initialize private context
WSREP_DUMMY(w)->log_fn = NULL;
+ WSREP_DUMMY(w)->options = NULL;
return 0;
}