[libsoup/gresolver: 2/2] Allow use without g_thread_init() if not using non-default async contexts.
- From: Dan Winship <danw src gnome org>
- To: svn-commits-list gnome org
- Subject: [libsoup/gresolver: 2/2] Allow use without g_thread_init() if not using non-default async contexts.
- Date: Sat, 2 May 2009 17:04:14 -0400 (EDT)
commit 535d6c52010b24f0a0baa3fed3a763431d248434
Author: Dan Winship <danw gnome org>
Date: Wed Nov 19 22:20:41 2008 -0500
Allow use without g_thread_init() if not using non-default async contexts.
Currently soup-proxy-resolver-gnome also requires thread support
---
libsoup/soup-logger.c | 3 ++-
libsoup/soup-message-queue.c | 3 ++-
libsoup/soup-session-sync.c | 6 ++++--
libsoup/soup-session.c | 3 ++-
libsoup/soup-socket.c | 6 ++++--
tests/chunk-test.c | 1 +
tests/context-test.c | 1 +
tests/dns.c | 1 -
tests/forms-test.c | 1 +
tests/getbug.c | 1 -
tests/misc-test.c | 1 +
tests/redirect-test.c | 1 +
tests/simple-httpd.c | 1 -
tests/simple-proxy.c | 1 -
tests/test-utils.c | 1 -
tests/timeout-test.c | 1 +
16 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index b38cb87..1e31663 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -123,7 +123,8 @@ soup_logger_init (SoupLogger *logger)
{
SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
- priv->lock = g_mutex_new ();
+ if (g_thread_supported ())
+ priv->lock = g_mutex_new ();
priv->tag = g_quark_from_static_string (g_strdup_printf ("SoupLogger-%p", logger));
priv->ids = g_hash_table_new (NULL, NULL);
}
diff --git a/libsoup/soup-message-queue.c b/libsoup/soup-message-queue.c
index 7e73c80..2371182 100644
--- a/libsoup/soup-message-queue.c
+++ b/libsoup/soup-message-queue.c
@@ -42,7 +42,8 @@ soup_message_queue_new (SoupSession *session)
queue = g_slice_new0 (SoupMessageQueue);
queue->session = session;
- queue->mutex = g_mutex_new ();
+ if (g_thread_supported ())
+ queue->mutex = g_mutex_new ();
return queue;
}
diff --git a/libsoup/soup-session-sync.c b/libsoup/soup-session-sync.c
index bb8e336..51fff3e 100644
--- a/libsoup/soup-session-sync.c
+++ b/libsoup/soup-session-sync.c
@@ -60,8 +60,10 @@ soup_session_sync_init (SoupSessionSync *ss)
{
SoupSessionSyncPrivate *priv = SOUP_SESSION_SYNC_GET_PRIVATE (ss);
- priv->lock = g_mutex_new ();
- priv->cond = g_cond_new ();
+ if (g_thread_supported ()) {
+ priv->lock = g_mutex_new ();
+ priv->cond = g_cond_new ();
+ }
}
static void
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index d4774f3..1ed2ae2 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -154,7 +154,8 @@ soup_session_init (SoupSession *session)
priv->queue = soup_message_queue_new (session);
- priv->host_lock = g_mutex_new ();
+ if (g_thread_supported ())
+ priv->host_lock = g_mutex_new ();
priv->hosts = g_hash_table_new (soup_address_hash_by_ip,
soup_address_equal_by_ip);
priv->conns = g_hash_table_new (NULL, NULL);
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index d3f77f9..51a0668 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -111,8 +111,10 @@ soup_socket_init (SoupSocket *sock)
priv->sockfd = -1;
priv->non_blocking = TRUE;
- priv->addrlock = g_mutex_new ();
- priv->iolock = g_mutex_new ();
+ if (g_thread_supported ()) {
+ priv->addrlock = g_mutex_new ();
+ priv->iolock = g_mutex_new ();
+ }
priv->timeout = 0;
}
diff --git a/tests/chunk-test.c b/tests/chunk-test.c
index 97c3ed5..f87e784 100644
--- a/tests/chunk-test.c
+++ b/tests/chunk-test.c
@@ -357,6 +357,7 @@ main (int argc, char **argv)
guint port;
SoupURI *base_uri;
+ g_thread_init (NULL);
test_init (argc, argv, NULL);
server = soup_test_server_new (TRUE);
diff --git a/tests/context-test.c b/tests/context-test.c
index fc203b3..35c62d7 100644
--- a/tests/context-test.c
+++ b/tests/context-test.c
@@ -259,6 +259,7 @@ main (int argc, char **argv)
{
SoupServer *server;
+ g_thread_init (NULL);
test_init (argc, argv, NULL);
server = soup_test_server_new (TRUE);
diff --git a/tests/dns.c b/tests/dns.c
index d0101ee..b6b6c55 100644
--- a/tests/dns.c
+++ b/tests/dns.c
@@ -41,7 +41,6 @@ main (int argc, char **argv)
if (argc < 2)
usage ();
- g_thread_init (NULL);
g_type_init ();
for (i = 1; i < argc; i++) {
diff --git a/tests/forms-test.c b/tests/forms-test.c
index e48c9c9..57a7ddf 100644
--- a/tests/forms-test.c
+++ b/tests/forms-test.c
@@ -400,6 +400,7 @@ main (int argc, char **argv)
guint port;
char *uri_str;
+ g_thread_init (NULL);
test_init (argc, argv, no_test_entry);
server = soup_test_server_new (TRUE);
diff --git a/tests/getbug.c b/tests/getbug.c
index 86ae304..c1bd566 100644
--- a/tests/getbug.c
+++ b/tests/getbug.c
@@ -95,7 +95,6 @@ main (int argc, char **argv)
const char *uri = "http://bugzilla.redhat.com/bugzilla/xmlrpc.cgi";
int opt, bug;
- g_thread_init (NULL);
g_type_init ();
while ((opt = getopt (argc, argv, "p:")) != -1) {
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 70415d3..04dc235 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -289,6 +289,7 @@ main (int argc, char **argv)
SoupServer *server;
SoupAuthDomain *auth_domain;
+ g_thread_init (NULL);
test_init (argc, argv, NULL);
server = soup_test_server_new (TRUE);
diff --git a/tests/redirect-test.c b/tests/redirect-test.c
index 9d5d9b8..adb90fa 100644
--- a/tests/redirect-test.c
+++ b/tests/redirect-test.c
@@ -299,6 +299,7 @@ main (int argc, char **argv)
guint port;
SoupURI *base_uri;
+ g_thread_init (NULL);
test_init (argc, argv, no_test_entry);
server = soup_test_server_new (TRUE);
diff --git a/tests/simple-httpd.c b/tests/simple-httpd.c
index b63ad04..c776d36 100644
--- a/tests/simple-httpd.c
+++ b/tests/simple-httpd.c
@@ -264,7 +264,6 @@ main (int argc, char **argv)
int ssl_port = SOUP_ADDRESS_ANY_PORT;
const char *ssl_cert_file = NULL, *ssl_key_file = NULL;
- g_thread_init (NULL);
g_type_init ();
signal (SIGINT, quit);
diff --git a/tests/simple-proxy.c b/tests/simple-proxy.c
index b8cd164..9942f40 100644
--- a/tests/simple-proxy.c
+++ b/tests/simple-proxy.c
@@ -135,7 +135,6 @@ main (int argc, char **argv)
int opt;
int port = SOUP_ADDRESS_ANY_PORT;
- g_thread_init (NULL);
g_type_init ();
signal (SIGINT, quit);
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 0b13ca1..dc66416 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -85,7 +85,6 @@ test_init (int argc, char **argv, GOptionEntry *entries)
char *name;
GError *error = NULL;
- g_thread_init (NULL);
g_type_init ();
name = strrchr (argv[0], '/');
diff --git a/tests/timeout-test.c b/tests/timeout-test.c
index 73cad70..3c06069 100644
--- a/tests/timeout-test.c
+++ b/tests/timeout-test.c
@@ -86,6 +86,7 @@ main (int argc, char **argv)
SoupServer *server;
char *fast_uri, *slow_uri;
+ g_thread_init (NULL);
test_init (argc, argv, NULL);
debug_printf (1, "http\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]