gweb: Add null pointer checks to avoid connman unstability
[framework/connectivity/connman.git] / gweb / giognutls.c
index 887109a..d92ae95 100644 (file)
@@ -54,11 +54,11 @@ struct _GIOGnuTLSWatch {
        GIOCondition condition;
 };
 
-static volatile gint global_init_done = 0;
+static volatile int global_init_done = 0;
 
 static inline void g_io_gnutls_global_init(void)
 {
-       if (g_atomic_int_compare_and_exchange(&global_init_done, 0, 1) == TRUE)
+       if (__sync_bool_compare_and_swap(&global_init_done, 0, 1) == TRUE)
                gnutls_global_init();
 }
 
@@ -446,10 +446,13 @@ GIOChannel *g_io_channel_gnutls_new(int fd)
                                                g_io_gnutls_pull_func);
 #if GNUTLS_VERSION_NUMBER < 0x020c00
        gnutls_transport_set_lowat(gnutls_channel->session, 0);
-#endif
 
        gnutls_priority_set_direct(gnutls_channel->session,
-                               "NORMAL:!VERS-TLS1.1:!VERS-TLS1.0", NULL);
+                                               "NORMAL:%COMPAT", NULL);
+#else
+       gnutls_priority_set_direct(gnutls_channel->session,
+               "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:+VERS-SSL3.0:%COMPAT", NULL);
+#endif
 
        gnutls_certificate_allocate_credentials(&gnutls_channel->cred);
        gnutls_credentials_set(gnutls_channel->session,