Merge remote branch 'gvdb/master'
[platform/upstream/glib.git] / gio / gsocketclient.c
index 74e6e80..7908aec 100644 (file)
@@ -514,7 +514,7 @@ g_socket_client_connect (GSocketClient       *client,
            }
          else if (last_error)
            {
-             g_propagate_error (error, tmp_error);
+             g_propagate_error (error, last_error);
            }
          else
             g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -528,7 +528,7 @@ g_socket_client_connect (GSocketClient       *client,
       socket = create_socket (client, address, &last_error);
       if (socket != NULL)
        {
-         if (g_socket_connect (socket, address, &last_error))
+         if (g_socket_connect (socket, address, cancellable, &last_error))
            connection = g_socket_connection_factory_create_connection (socket);
 
          g_object_unref (socket);
@@ -587,7 +587,7 @@ g_socket_client_connect (GSocketClient       *client,
 GSocketConnection *
 g_socket_client_connect_to_host (GSocketClient  *client,
                                 const gchar    *host_and_port,
-                                gint            default_port,
+                                guint16         default_port,
                                 GCancellable   *cancellable,
                                 GError        **error)
 {
@@ -676,6 +676,7 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
       g_socket_set_blocking (data->current_socket, TRUE);
 
       connection = g_socket_connection_factory_create_connection (data->current_socket);
+      g_object_unref (data->current_socket);
       g_simple_async_result_set_op_res_gpointer (data->result,
                                                 connection,
                                                 g_object_unref);
@@ -683,6 +684,8 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
 
   g_simple_async_result_complete (data->result);
   g_object_unref (data->result);
+  g_object_unref (data->enumerator);
+  g_slice_free (GSocketClientAsyncConnectData, data);
 }
 
 
@@ -776,7 +779,7 @@ g_socket_client_enumerator_callback (GObject      *object,
   if (socket != NULL)
     {
       g_socket_set_blocking (socket, FALSE);
-      if (g_socket_connect (socket, address, &tmp_error))
+      if (g_socket_connect (socket, address, data->cancellable, &tmp_error))
        {
          data->current_socket = socket;
          g_socket_client_async_connect_complete (data);
@@ -796,7 +799,7 @@ g_socket_client_enumerator_callback (GObject      *object,
          g_source_set_callback (source,
                                 (GSourceFunc) g_socket_client_socket_callback,
                                 data, NULL);
-         g_source_attach (source, NULL);
+         g_source_attach (source, g_main_context_get_thread_default ());
          g_source_unref (source);
 
          g_object_unref (address);
@@ -881,7 +884,7 @@ g_socket_client_connect_async (GSocketClient       *client,
 void
 g_socket_client_connect_to_host_async (GSocketClient        *client,
                                       const gchar          *host_and_port,
-                                      gint                  default_port,
+                                      guint16               default_port,
                                       GCancellable         *cancellable,
                                       GAsyncReadyCallback   callback,
                                       gpointer              user_data)