[libsoup] Add soup_socket_listen_full() internal API which returns an error
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Add soup_socket_listen_full() internal API which returns an error
- Date: Mon, 25 Apr 2016 20:57:25 +0000 (UTC)
commit 9d420062e9463839e830927be48aa88ab4b17003
Author: Stef Walter <stefw redhat com>
Date: Wed Mar 23 09:19:01 2016 +0100
Add soup_socket_listen_full() internal API which returns an error
The fact that soup_socket_listen() doesn't return a proper
error masks real failure modes.
https://bugzilla.gnome.org/show_bug.cgi?id=764057
libsoup/soup-socket-private.h | 4 ++++
libsoup/soup-socket.c | 23 ++++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-socket-private.h b/libsoup/soup-socket-private.h
index c0bb7a1..8677884 100644
--- a/libsoup/soup-socket-private.h
+++ b/libsoup/soup-socket-private.h
@@ -46,6 +46,10 @@ GIOStream *soup_socket_get_iostream (SoupSocket *sock);
SoupURI *soup_socket_get_http_proxy_uri (SoupSocket *sock);
+gboolean soup_socket_listen_full (SoupSocket *sock,
+ GError **error);
+
+
typedef struct {
GMainContext *async_context;
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 594e38b..1658471 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -1246,6 +1246,23 @@ finish_listener_setup (SoupSocket *sock)
**/
gboolean
soup_socket_listen (SoupSocket *sock)
+{
+ return soup_socket_listen_full (sock, NULL);
+}
+
+/**
+ * soup_socket_listen_full:
+ * @sock: a server #SoupSocket (which must not already be connected or listening)
+ * @error: error pointer
+ *
+ * Makes @sock start listening on its local address. When connections
+ * come in, @sock will emit #SoupSocket::new_connection.
+ *
+ * Return value: whether or not @sock is now listening.
+ **/
+gboolean
+soup_socket_listen_full (SoupSocket *sock,
+ GError **error)
{
SoupSocketPrivate *priv;
@@ -1268,7 +1285,7 @@ soup_socket_listen (SoupSocket *sock)
priv->gsock = g_socket_new (g_socket_address_get_family (addr),
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_DEFAULT,
- NULL);
+ error);
if (!priv->gsock)
goto cant_listen;
finish_socket_setup (sock);
@@ -1285,14 +1302,14 @@ soup_socket_listen (SoupSocket *sock)
#endif
/* Bind */
- if (!g_socket_bind (priv->gsock, addr, TRUE, NULL))
+ if (!g_socket_bind (priv->gsock, addr, TRUE, error))
goto cant_listen;
/* Force local_addr to be re-resolved now */
g_object_unref (priv->local_addr);
priv->local_addr = NULL;
/* Listen */
- if (!g_socket_listen (priv->gsock, NULL))
+ if (!g_socket_listen (priv->gsock, error))
goto cant_listen;
finish_listener_setup (sock);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]