From: Andreas Rottmann <a.rottmann@gmx.at>
Subject: Add 'soup_server_disconnect' method

This is primarily useful for language bindings, where you don't have
explicit control over reference counts, and hence cannot just use
'g_object_unref' on the server object.

See https://bugzilla.gnome.org/show_bug.cgi?id=638576

---
 libsoup/soup-server.c |   32 ++++++++++++++++++++++++++++++++
 libsoup/soup-server.h |    1 +
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 80ad546..43c0f04 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -991,6 +991,38 @@ soup_server_quit (SoupServer *server)
 }
 
 /**
+ * soup_server_disconnect:
+ * @server: a #SoupServer
+ *
+ * Stops processing for @server and closes its socket. This implies
+ * the effects of soup_server_quit(), but additionally closes the
+ * listening socket.  Note that messages currently in progress will
+ * continue to be handled, if the main loop associated with the
+ * server is resumed or kept running.
+ *
+ * After calling this function, @server is no longer functional, so it
+ * has nearly the same effect as destroying @server entirely. The
+ * function is thus useful mainly for language bindings without
+ * explicit control over object lifetime.
+ **/
+void
+soup_server_disconnect (SoupServer *server)
+{
+	SoupServerPrivate *priv;
+
+	g_return_if_fail (SOUP_IS_SERVER (server));
+	priv = SOUP_SERVER_GET_PRIVATE (server);
+
+	soup_server_quit (server);
+
+	if (priv->listen_sock) {
+		soup_socket_disconnect (priv->listen_sock);
+		g_object_unref (priv->listen_sock);
+		priv->listen_sock = NULL;
+	}
+}
+
+/**
  * soup_server_get_async_context:
  * @server: a #SoupServer
  *
diff --git a/libsoup/soup-server.h b/libsoup/soup-server.h
index 88c1570..4ea17ad 100644
--- a/libsoup/soup-server.h
+++ b/libsoup/soup-server.h
@@ -75,6 +75,7 @@ SoupSocket        *soup_server_get_listener   (SoupServer            *server);
 void               soup_server_run            (SoupServer            *server);
 void               soup_server_run_async      (SoupServer            *server);
 void               soup_server_quit           (SoupServer            *server);
+void               soup_server_disconnect     (SoupServer            *server);
 
 GMainContext      *soup_server_get_async_context (SoupServer         *server);
 
-- 
tg: (cfdd3e8..) t/server-shutdown (depends on: master t/build-fixes)
