@@ -37,6 +37,22 @@ static wsrep_log_cb_t logger = default_logger;
37
37
* Library loader
38
38
**************************************************************************/
39
39
40
+ static int wsrep_check_iface_version (const char * found , const char * iface_ver )
41
+ {
42
+ const size_t msg_len = 128 ;
43
+ char msg [128 ];
44
+
45
+ if (strcmp (found , iface_ver )) {
46
+ snprintf (msg , msg_len ,
47
+ "provider interface version mismatch: need '%s', found '%s'" ,
48
+ iface_ver , found );
49
+ logger (WSREP_LOG_ERROR , msg );
50
+ return EINVAL ;
51
+ }
52
+
53
+ return 0 ;
54
+ }
55
+
40
56
static int verify (const wsrep_t * wh , const char * iface_ver )
41
57
{
42
58
char msg [128 ];
@@ -50,13 +66,8 @@ static int verify(const wsrep_t *wh, const char *iface_ver)
50
66
VERIFY (wh );
51
67
VERIFY (wh -> version );
52
68
53
- if (strcmp (wh -> version , iface_ver )) {
54
- snprintf (msg , sizeof (msg ),
55
- "provider interface version mismatch: need '%s', found '%s'" ,
56
- iface_ver , wh -> version );
57
- logger (WSREP_LOG_ERROR , msg );
69
+ if (wsrep_check_iface_version (wh -> version , iface_ver ))
58
70
return EINVAL ;
59
- }
60
71
61
72
VERIFY (wh -> init );
62
73
VERIFY (wh -> options_set );
@@ -107,6 +118,15 @@ static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym)
107
118
return alias .dlfun ;
108
119
}
109
120
121
+ static int wsrep_check_version_symbol (void * dlh )
122
+ {
123
+ char * * dlversion = NULL ;
124
+ dlversion = (char * * ) dlsym (dlh , "wsrep_interface_version" );
125
+ if (dlversion == NULL )
126
+ return 0 ;
127
+ return wsrep_check_iface_version (* dlversion , WSREP_INTERFACE_VERSION );
128
+ }
129
+
110
130
extern int wsrep_dummy_loader (wsrep_t * w );
111
131
112
132
int wsrep_load (const char * spec , wsrep_t * * hptr , wsrep_log_cb_t log_cb )
@@ -151,6 +171,11 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
151
171
goto out ;
152
172
}
153
173
174
+ if (wsrep_check_version_symbol (dlh ) != 0 ) {
175
+ ret = EINVAL ;
176
+ goto out ;
177
+ }
178
+
154
179
if ((ret = (* dlfun )(* hptr )) != 0 ) {
155
180
snprintf (msg , sizeof (msg ), "wsrep_load(): loader failed: %s" ,
156
181
strerror (ret ));
0 commit comments