Skip to content

Commit 9d34207

Browse files
committed
Merge pull request #530 from michaelkruglos/master
Added call to mysql_library_init during initialization of the gem
2 parents 78d59bc + de48627 commit 9d34207

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/mysql2/client.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,13 @@ void init_mysql2_client() {
12351235
}
12361236
}
12371237

1238+
/* Initializing mysql library, so different threads could call Client.new */
1239+
/* without race condition in the library */
1240+
if (mysql_library_init(0, NULL, NULL) != 0) {
1241+
rb_raise(rb_eRuntimeError, "Could not initialize MySQL client library");
1242+
return;
1243+
}
1244+
12381245
#if 0
12391246
mMysql2 = rb_define_module("Mysql2"); Teach RDoc about Mysql2 constant.
12401247
#endif

0 commit comments

Comments
 (0)