Commit 9fb30820 authored by Dan Winship's avatar Dan Winship

Revert "Return correct value for g_socket_get_available_bytes() on Windows and OSX"

This neither compiles nor does what it's supposed to on Windows.

This reverts commit 1e598600.
parent 4651ec77
......@@ -2388,10 +2388,7 @@ g_socket_check_connect_result (GSocket *socket,
* g_socket_get_available_bytes:
* @socket: a #GSocket
*
* Get the amount of data that can be read from the socket without
* blocking. In the case of datagram sockets this returns the size
* of the first datagram and not the sum of the sizes of all currently
* queued datagrams.
* Get the amount of data pending in the OS input buffer.
*
* Returns: the number of bytes that can be read from the socket
* without blocking or -1 on error.
......@@ -2405,19 +2402,15 @@ g_socket_get_available_bytes (GSocket *socket)
gulong avail = 0;
#else
gint avail = 0;
gsize avail_len = sizeof (avail);
#endif
g_return_val_if_fail (G_IS_SOCKET (socket), -1);
#if defined(G_OS_WIN32)
if (WSAIoctl (socket->priv->fd, FIONREAD, NULL, 0, &avail, sizeof (avail), 0, 0) == SOCKET_ERROR)
return -1;
#elif defined(SO_NREAD)
if (getsockopt (socket->priv->fd, SOL_SOCKET, SO_NREAD, &avail, &avail_len) < 0)
#ifndef G_OS_WIN32
if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0)
return -1;
#else
if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0)
if (ioctlsocket (socket->priv->fd, FIONREAD, &avail) == SOCKET_ERROR)
return -1;
#endif
......
......@@ -813,58 +813,6 @@ test_unix_connection_ancillary_data (void)
}
#endif /* G_OS_UNIX */
static void
test_datagram_get_available (void)
{
GError *err = NULL;
GSocket *server, *client;
GInetAddress *addr;
GSocketAddress *saddr;
gchar data[] = "0123456789abcdef";
server = g_socket_new (G_SOCKET_FAMILY_IPV4,
G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_DEFAULT,
&err);
g_assert_no_error (err);
g_assert (G_IS_SOCKET (server));
client = g_socket_new (G_SOCKET_FAMILY_IPV4,
G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_DEFAULT,
&err);
g_assert_no_error (err);
g_assert (G_IS_SOCKET (client));
addr = g_inet_address_new_any (G_SOCKET_FAMILY_IPV4);
saddr = g_inet_socket_address_new (addr, 0);
g_socket_bind (server, saddr, TRUE, &err);
g_assert_no_error (err);
g_object_unref (saddr);
g_object_unref (addr);
saddr = g_socket_get_local_address (server, &err);
g_assert_no_error (err);
g_socket_send_to (client, saddr, data, sizeof (data), NULL, &err);
g_assert_no_error (err);
g_assert_cmpint (g_socket_get_available_bytes (server), ==, sizeof (data));
g_socket_send_to (client, saddr, data, sizeof (data), NULL, &err);
g_assert_no_error (err);
g_assert_cmpint (g_socket_get_available_bytes (server), ==, sizeof (data));
g_socket_close (server, &err);
g_assert_no_error (err);
g_object_unref (saddr);
g_object_unref (server);
g_object_unref (client);
}
int
main (int argc,
char *argv[])
......@@ -886,7 +834,6 @@ main (int argc,
g_test_add_func ("/socket/unix-connection", test_unix_connection);
g_test_add_func ("/socket/unix-connection-ancillary-data", test_unix_connection_ancillary_data);
#endif
g_test_add_func ("/socket/datagram_get_available", test_datagram_get_available);
return g_test_run();
}
......
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