1 From c1609942ea9d9ff9b04560405162fda008e38e44 Mon Sep 17 00:00:00 2001
2 From: Dan Winship <danw@gnome.org>
3 Date: Tue, 20 Nov 2012 04:13:29 +0000
4 Subject: Revert "Return correct value for g_socket_get_available_bytes() on Windows and OSX"
6 This neither compiles nor does what it's supposed to on Windows.
8 This reverts commit 49ad4e9494e4497cffcf145d3515231bcf05de29.
10 diff --git a/gio/gsocket.c b/gio/gsocket.c
11 index 1a8ed50..13dff46 100644
14 @@ -2368,10 +2368,7 @@ g_socket_check_connect_result (GSocket *socket,
15 * g_socket_get_available_bytes:
18 - * Get the amount of data that can be read from the socket without
19 - * blocking. In the case of datagram sockets this returns the size
20 - * of the first datagram and not the sum of the sizes of all currently
22 + * Get the amount of data pending in the OS input buffer.
24 * Returns: the number of bytes that can be read from the socket
25 * without blocking or -1 on error.
26 @@ -2385,19 +2382,15 @@ g_socket_get_available_bytes (GSocket *socket)
30 - gsize avail_len = sizeof (avail);
33 g_return_val_if_fail (G_IS_SOCKET (socket), -1);
35 -#if defined(G_OS_WIN32)
36 - if (WSAIoctl (socket->priv->fd, FIONREAD, NULL, 0, &avail, sizeof (avail), 0, 0) == SOCKET_ERROR)
38 -#elif defined(SO_NREAD)
39 - if (getsockopt (socket->priv->fd, SOL_SOCKET, SO_NREAD, &avail, &avail_len) < 0)
41 + if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0)
44 - if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0)
45 + if (ioctlsocket (socket->priv->fd, FIONREAD, &avail) == SOCKET_ERROR)
49 diff --git a/gio/tests/socket.c b/gio/tests/socket.c
50 index 3790415..0a61c9f 100644
51 --- a/gio/tests/socket.c
52 +++ b/gio/tests/socket.c
53 @@ -813,58 +813,6 @@ test_unix_connection_ancillary_data (void)
55 #endif /* G_OS_UNIX */
58 -test_datagram_get_available (void)
61 - GSocket *server, *client;
63 - GSocketAddress *saddr;
64 - gchar data[] = "0123456789abcdef";
66 - server = g_socket_new (G_SOCKET_FAMILY_IPV4,
67 - G_SOCKET_TYPE_DATAGRAM,
68 - G_SOCKET_PROTOCOL_DEFAULT,
70 - g_assert_no_error (err);
71 - g_assert (G_IS_SOCKET (server));
73 - client = g_socket_new (G_SOCKET_FAMILY_IPV4,
74 - G_SOCKET_TYPE_DATAGRAM,
75 - G_SOCKET_PROTOCOL_DEFAULT,
77 - g_assert_no_error (err);
78 - g_assert (G_IS_SOCKET (client));
80 - addr = g_inet_address_new_any (G_SOCKET_FAMILY_IPV4);
81 - saddr = g_inet_socket_address_new (addr, 0);
83 - g_socket_bind (server, saddr, TRUE, &err);
84 - g_assert_no_error (err);
85 - g_object_unref (saddr);
86 - g_object_unref (addr);
88 - saddr = g_socket_get_local_address (server, &err);
89 - g_assert_no_error (err);
91 - g_socket_send_to (client, saddr, data, sizeof (data), NULL, &err);
92 - g_assert_no_error (err);
94 - g_assert_cmpint (g_socket_get_available_bytes (server), ==, sizeof (data));
96 - g_socket_send_to (client, saddr, data, sizeof (data), NULL, &err);
97 - g_assert_no_error (err);
99 - g_assert_cmpint (g_socket_get_available_bytes (server), ==, sizeof (data));
101 - g_socket_close (server, &err);
102 - g_assert_no_error (err);
104 - g_object_unref (saddr);
105 - g_object_unref (server);
106 - g_object_unref (client);
112 @@ -887,7 +835,6 @@ main (int argc,
113 g_test_add_func ("/socket/unix-connection", test_unix_connection);
114 g_test_add_func ("/socket/unix-connection-ancillary-data", test_unix_connection_ancillary_data);
116 - g_test_add_func ("/socket/datagram_get_available", test_datagram_get_available);