Commit 0c53e463 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

server: remove unused property SoupSocket:is-server

SoupSocket is only used on the server side now.
parent 1cdea700
......@@ -1056,7 +1056,6 @@ soup_server_listen_internal (SoupServer *server, SoupSocket *listener,
GError **error)
{
SoupServerPrivate *priv = soup_server_get_instance_private (server);
gboolean is_listening;
if (options & SOUP_SERVER_LISTEN_HTTPS) {
if (!priv->tls_cert) {
......@@ -1072,10 +1071,7 @@ soup_server_listen_internal (SoupServer *server, SoupSocket *listener,
NULL);
}
g_object_get (G_OBJECT (listener),
"is-server", &is_listening,
NULL);
if (!is_listening) {
if (soup_socket_get_gsocket (listener) == NULL) {
if (!soup_socket_listen (listener, error)) {
GInetSocketAddress *addr = soup_socket_get_local_address (listener);
GInetAddress *inet_addr = g_inet_socket_address_get_address (addr);
......
......@@ -45,7 +45,6 @@ enum {
PROP_REMOTE_ADDRESS,
PROP_REMOTE_CONNECTABLE,
PROP_IPV6_ONLY,
PROP_IS_SERVER,
PROP_SSL_CREDENTIALS,
LAST_PROP
......@@ -64,7 +63,6 @@ typedef struct {
GOutputStream *ostream;
guint ipv6_only:1;
guint is_server:1;
guint ssl:1;
gpointer ssl_creds;
......@@ -252,9 +250,6 @@ soup_socket_get_property (GObject *object, guint prop_id,
case PROP_IPV6_ONLY:
g_value_set_boolean (value, priv->ipv6_only);
break;
case PROP_IS_SERVER:
g_value_set_boolean (value, priv->is_server);
break;
case PROP_SSL_CREDENTIALS:
g_value_set_pointer (value, priv->ssl_creds);
break;
......@@ -367,24 +362,6 @@ soup_socket_class_init (SoupSocketClass *socket_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* SoupSocket:is-server:
*
* Whether or not the socket is a server socket.
*
* Note that for "ordinary" #SoupSockets this will be set for
* both listening sockets and the sockets emitted by
* #SoupSocket::new-connection.
**/
g_object_class_install_property (
object_class, PROP_IS_SERVER,
g_param_spec_boolean ("is-server",
"Server",
"Whether or not the socket is a server socket",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/* For historical reasons, there's only a single property
* here, which is a GTlsDatabase for client sockets, and
* a GTlsCertificate for server sockets. Whee!
......@@ -518,7 +495,6 @@ listen_watch (GObject *pollable, gpointer data)
new_priv = soup_socket_get_instance_private (new);
new_priv->gsock = new_gsock;
new_priv->async_context = g_main_context_ref (priv->async_context);
new_priv->is_server = TRUE;
new_priv->ssl = priv->ssl;
if (priv->ssl_creds)
new_priv->ssl_creds = g_object_ref (priv->ssl_creds);
......@@ -542,7 +518,6 @@ finish_listener_setup (SoupSocket *sock)
{
SoupSocketPrivate *priv = soup_socket_get_instance_private (sock);
priv->is_server = TRUE;
priv->watch_src = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (priv->istream), NULL);
g_source_set_callback (priv->watch_src, (GSourceFunc)listen_watch, sock, NULL);
g_source_attach (priv->watch_src, priv->async_context);
......
......@@ -116,67 +116,6 @@ socket_get_fd (SoupSocket *socket)
return g_socket_get_fd (soup_socket_get_gsocket (socket));
}
static void
do_socket_from_fd_client_test (void)
{
SoupServer *server;
GUri *uri;
GSocket *gsock;
SoupSocket *sock;
GInetSocketAddress *local, *remote;
GSocketAddress *gaddr;
gboolean is_server;
GError *error = NULL;
server = soup_test_server_new (SOUP_TEST_SERVER_DEFAULT);
uri = soup_test_server_get_uri (server, "http", "127.0.0.1");
gsock = g_socket_new (G_SOCKET_FAMILY_IPV4,
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_DEFAULT,
&error);
g_assert_no_error (error);
gaddr = g_inet_socket_address_new_from_string ("127.0.0.1", g_uri_get_port (uri));
g_socket_connect (gsock, gaddr, NULL, &error);
g_object_unref (gaddr);
g_assert_no_error (error);
g_assert_true (g_socket_is_connected (gsock));
gaddr = g_socket_get_local_address (gsock, &error);
g_assert_no_error (error);
sock = g_initable_new (SOUP_TYPE_SOCKET, NULL, &error,
"gsocket", gsock,
NULL);
g_assert_no_error (error);
g_assert_nonnull (sock);
g_object_get (G_OBJECT (sock),
"local-address", &local,
"remote-address", &remote,
"is-server", &is_server,
NULL);
g_assert_cmpint (socket_get_fd (sock), ==, g_socket_get_fd (gsock));
g_assert_false (is_server);
g_assert_true (soup_socket_is_connected (sock));
assert_host_equals (local, "127.0.0.1");
g_assert_cmpint (g_inet_socket_address_get_port (local), ==, g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (gaddr)));
assert_host_equals (remote, "127.0.0.1");
g_assert_cmpint (g_inet_socket_address_get_port (remote), ==, g_uri_get_port (uri));
g_object_unref (local);
g_object_unref (remote);
g_object_unref (gaddr);
g_object_unref (sock);
g_object_unref (gsock);
soup_test_server_quit_unref (server);
g_uri_unref (uri);
}
static void
do_socket_from_fd_server_test (void)
{
......@@ -184,7 +123,6 @@ do_socket_from_fd_server_test (void)
SoupSocket *sock;
GInetSocketAddress *local;
GSocketAddress *gaddr;
gboolean is_server;
GError *error = NULL;
gsock = g_socket_new (G_SOCKET_FAMILY_IPV4,
......@@ -212,10 +150,8 @@ do_socket_from_fd_server_test (void)
g_object_get (G_OBJECT (sock),
"local-address", &local,
"is-server", &is_server,
NULL);
g_assert_cmpint (socket_get_fd (sock), ==, g_socket_get_fd (gsock));
g_assert_true (is_server);
g_assert_true (soup_socket_is_connected (sock));
assert_host_equals (local, "127.0.0.1");
......@@ -238,7 +174,6 @@ do_socket_from_fd_bad_test (void)
SoupSocket *sock, *sock2;
GInetSocketAddress *local, *remote;
GSocketAddress *gaddr;
gboolean is_server;
GError *error = NULL;
/* Importing an unconnected socket gives an error */
......@@ -257,9 +192,6 @@ do_socket_from_fd_bad_test (void)
g_assert_null (sock);
g_object_unref (gsock);
/* Importing a non-listening server-side socket works, but
* gives the wrong answer for soup_socket_is_server().
*/
gsock = g_socket_new (G_SOCKET_FAMILY_IPV4,
G_SOCKET_TYPE_STREAM,
G_SOCKET_PROTOCOL_DEFAULT,
......@@ -300,12 +232,9 @@ do_socket_from_fd_bad_test (void)
g_object_get (G_OBJECT (sock2),
"local-address", &local,
"remote-address", &remote,
"is-server", &is_server,
NULL);
g_assert_cmpint (socket_get_fd (sock2), ==, g_socket_get_fd (gsock2));
g_assert_true (soup_socket_is_connected (sock2));
/* This is wrong, but can't be helped. */
g_assert_false (is_server);
assert_host_equals (local, "127.0.0.1");
g_assert_cmpint (g_inet_socket_address_get_port (local), ==, g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (gaddr)));
......@@ -335,7 +264,6 @@ main (int argc, char **argv)
test_init (argc, argv, NULL);
g_test_add_func ("/sockets/unconnected", do_unconnected_socket_test);
g_test_add_func ("/sockets/from-fd/client", do_socket_from_fd_client_test);
g_test_add_func ("/sockets/from-fd/server", do_socket_from_fd_server_test);
g_test_add_func ("/sockets/from-fd/bad", do_socket_from_fd_bad_test);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment