提交 47489d64 编写于 作者: M Matthias Bolte 提交者: Cole Robinson

Call curl_global_init from virInitialize to avoid thread-safety issues

curl_global_init is not thread-safe. curl_easy_init might call
curl_global_init when it was no called before. But curl_easy_init
can be called from different threads by the ESX driver. Therefore,
call curl_global_init from virInitialize to stop curl_easy_init from
calling it.

Reported by Benjamin Wang.
(cherry picked from commit 458c4998)
上级 88c7f28b
...@@ -2297,9 +2297,12 @@ dnl ...@@ -2297,9 +2297,12 @@ dnl
LIBCURL_CFLAGS="" LIBCURL_CFLAGS=""
LIBCURL_LIBS="" LIBCURL_LIBS=""
have_curl=no
if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi" = "yes" || test "$with_xenapi" = "check"; then if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi" = "yes" || test "$with_xenapi" = "check"; then
PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [ PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [
have_curl=yes
if test "$with_esx" = "check"; then if test "$with_esx" = "check"; then
with_esx=yes with_esx=yes
fi fi
...@@ -2324,6 +2327,11 @@ if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi" ...@@ -2324,6 +2327,11 @@ if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi"
]) ])
fi fi
if test "$have_curl" = "yes" ; then
AC_DEFINE_UNQUOTED([HAVE_LIBCURL], 1, [whether libcurl is available])
fi
AM_CONDITIONAL([HAVE_LIBCURL], [test "$have_curl" = "yes"])
if test "$with_esx" = "yes" ; then if test "$with_esx" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled]) AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled])
...@@ -3079,7 +3087,7 @@ AC_MSG_NOTICE([Libraries]) ...@@ -3079,7 +3087,7 @@ AC_MSG_NOTICE([Libraries])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS]) AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
AC_MSG_NOTICE([ dlopen: $DLOPEN_LIBS]) AC_MSG_NOTICE([ dlopen: $DLOPEN_LIBS])
if test "$with_esx" = "yes" ; then if test "$have_curl" = "yes" ; then
AC_MSG_NOTICE([ libcurl: $LIBCURL_CFLAGS $LIBCURL_LIBS]) AC_MSG_NOTICE([ libcurl: $LIBCURL_CFLAGS $LIBCURL_LIBS])
else else
AC_MSG_NOTICE([ libcurl: no]) AC_MSG_NOTICE([ libcurl: no])
......
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
# include <winsock2.h> # include <winsock2.h>
#endif #endif
#ifdef HAVE_LIBCURL
# include <curl/curl.h>
#endif
#include "virterror_internal.h" #include "virterror_internal.h"
#include "logging.h" #include "logging.h"
#include "datatypes.h" #include "datatypes.h"
...@@ -418,6 +422,10 @@ virInitialize(void) ...@@ -418,6 +422,10 @@ virInitialize(void)
virNetTLSInit(); virNetTLSInit();
#if HAVE_LIBCURL
curl_global_init(CURL_GLOBAL_DEFAULT);
#endif
VIR_DEBUG("register drivers"); VIR_DEBUG("register drivers");
#if HAVE_WINSOCK2_H #if HAVE_WINSOCK2_H
......
...@@ -171,7 +171,6 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, ...@@ -171,7 +171,6 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth,
xmlInitParser(); xmlInitParser();
xmlKeepBlanksDefault(0); xmlKeepBlanksDefault(0);
xen_init(); xen_init();
curl_global_init(CURL_GLOBAL_ALL);
privP->session = xen_session_login_with_password(call_func, privP, username, privP->session = xen_session_login_with_password(call_func, privP, username,
password, xen_api_latest_version); password, xen_api_latest_version);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册