summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-10-13 23:03:00 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-10-13 23:03:00 +0200
commit9aefe4ae09722675552c9920310c9b1b481c8e72 (patch)
treedc79fb1754c39c37c41deeb5b342a531f504a381 /src
parent13a057f0b20c0e69c613e75b5750cb4a9aacf520 (diff)
downloadweechat-9aefe4ae09722675552c9920310c9b1b481c8e72.zip
core: call curl init and cleanup functions
This is to prevent issues when these functions are not thread-safe.
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-url.c20
-rw-r--r--src/core/wee-url.h2
-rw-r--r--src/core/weechat.c3
3 files changed, 25 insertions, 0 deletions
diff --git a/src/core/wee-url.c b/src/core/wee-url.c
index 8f77a048d..1eb7d026c 100644
--- a/src/core/wee-url.c
+++ b/src/core/wee-url.c
@@ -1573,3 +1573,23 @@ weeurl_option_add_to_infolist (struct t_infolist *infolist,
return 1;
}
+
+/*
+ * Initializes URL.
+ */
+
+void
+weeurl_init ()
+{
+ curl_global_init (CURL_GLOBAL_ALL);
+}
+
+/*
+ * Ends URL.
+ */
+
+void
+weeurl_end ()
+{
+ curl_global_cleanup ();
+}
diff --git a/src/core/wee-url.h b/src/core/wee-url.h
index cfa8f6f00..934e085d7 100644
--- a/src/core/wee-url.h
+++ b/src/core/wee-url.h
@@ -62,5 +62,7 @@ extern int weeurl_download (const char *url, struct t_hashtable *options,
struct t_hashtable *output);
extern int weeurl_option_add_to_infolist (struct t_infolist *infolist,
struct t_url_option *option);
+extern void weeurl_init ();
+extern void weeurl_end ();
#endif /* WEECHAT_URL_H */
diff --git a/src/core/weechat.c b/src/core/weechat.c
index d91a3300a..9c11dd16b 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -74,6 +74,7 @@
#include "wee-signal.h"
#include "wee-string.h"
#include "wee-upgrade.h"
+#include "wee-url.h"
#include "wee-utf8.h"
#include "wee-util.h"
#include "wee-version.h"
@@ -640,6 +641,7 @@ weechat_init (int argc, char *argv[], void (*gui_init_cb)())
* weechat_current_start_timeval.tv_usec)
^ getpid ());
+ weeurl_init (); /* initialize URL */
signal_init (); /* initialize signals */
hdata_init (); /* initialize hdata */
hook_init (); /* initialize hooks */
@@ -720,5 +722,6 @@ weechat_end (void (*gui_end_cb)(int clean_exit))
hdata_end (); /* end hdata */
secure_end (); /* end secured data */
string_end (); /* end string */
+ weeurl_end ();
weechat_shutdown (-1, 0); /* end other things */
}