diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-08-25 15:39:39 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-08-25 15:39:39 -0400 |
commit | 90266e8a0eb46867c990930fa4d305d2424929ba (patch) | |
tree | 787918cf537c678ab4f7a949520c847fa3fd8442 /wsrep | |
parent | dfa3046db48d8439cf3eb02ba6623fe2f6e44f91 (diff) | |
parent | b506d9527b4303b91f69fe6b6f21f911e5bfef72 (diff) | |
download | mariadb-git-90266e8a0eb46867c990930fa4d305d2424929ba.tar.gz |
Merge branch '10.0-galera' into bb-10.1-serg
Diffstat (limited to 'wsrep')
-rw-r--r-- | wsrep/wsrep_dummy.c | 11 | ||||
-rw-r--r-- | wsrep/wsrep_loader.c | 37 |
2 files changed, 40 insertions, 8 deletions
diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c index fa726877fcf..eae084f1979 100644 --- a/wsrep/wsrep_dummy.c +++ b/wsrep/wsrep_dummy.c @@ -84,8 +84,15 @@ static wsrep_status_t dummy_options_set( static char* dummy_options_get (wsrep_t* w) { - WSREP_DBUG_ENTER(w); - return WSREP_DUMMY(w)->options; + char *options; + + WSREP_DBUG_ENTER(w); + options= WSREP_DUMMY(w)->options; + + if (options) + options= strdup(WSREP_DUMMY(w)->options); + + return options; } static wsrep_status_t dummy_connect( diff --git a/wsrep/wsrep_loader.c b/wsrep/wsrep_loader.c index 5c4e61e1832..f4d5991339e 100644 --- a/wsrep/wsrep_loader.c +++ b/wsrep/wsrep_loader.c @@ -37,6 +37,22 @@ static wsrep_log_cb_t logger = default_logger; * Library loader **************************************************************************/ +static int wsrep_check_iface_version(const char* found, const char* iface_ver) +{ + const size_t msg_len = 128; + char msg[128]; + + if (strcmp(found, iface_ver)) { + snprintf (msg, msg_len, + "provider interface version mismatch: need '%s', found '%s'", + iface_ver, found); + logger (WSREP_LOG_ERROR, msg); + return EINVAL; + } + + return 0; +} + static int verify(const wsrep_t *wh, const char *iface_ver) { char msg[128]; @@ -50,13 +66,8 @@ static int verify(const wsrep_t *wh, const char *iface_ver) VERIFY(wh); VERIFY(wh->version); - if (strcmp(wh->version, iface_ver)) { - snprintf (msg, sizeof(msg), - "provider interface version mismatch: need '%s', found '%s'", - iface_ver, wh->version); - logger (WSREP_LOG_ERROR, msg); + if (wsrep_check_iface_version(wh->version, iface_ver)) return EINVAL; - } VERIFY(wh->init); VERIFY(wh->options_set); @@ -107,6 +118,15 @@ static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) return alias.dlfun; } +static int wsrep_check_version_symbol(void *dlh) +{ + char** dlversion = NULL; + dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion == NULL) + return 0; + return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION); +} + extern int wsrep_dummy_loader(wsrep_t *w); int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) @@ -152,6 +172,11 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) goto out; } + if (wsrep_check_version_symbol(dlh) != 0) { + ret = EINVAL; + goto out; + } + if ((ret = (*dlfun)(*hptr)) != 0) { snprintf(msg, sizeof(msg)-1, "wsrep_load(): loader failed: %s", strerror(ret)); |