Skip to content
Snippets Groups Projects
Commit abc981bf authored by Daniel P. Berrangé's avatar Daniel P. Berrangé
Browse files

io: bind to socket before creating QIOChannelSocket


In the QIOChannelSocket test we create a socket file
descriptor and then try to create a QIOChannelSocket.
This works on Linux, but fails on Win32 because it is
not valid to call getsockname() on an unbound socket.

Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 5838d66e
No related branches found
No related tags found
No related merge requests found
......@@ -470,10 +470,20 @@ static void test_io_channel_ipv4_fd(void)
{
QIOChannel *ioc;
int fd = -1;
struct sockaddr_in sa = {
.sin_family = AF_INET,
.sin_addr = {
.s_addr = htonl(INADDR_LOOPBACK),
}
/* Leave port unset for auto-assign */
};
socklen_t salen = sizeof(sa);
fd = socket(AF_INET, SOCK_STREAM, 0);
g_assert_cmpint(fd, >, -1);
g_assert_cmpint(bind(fd, (struct sockaddr *)&sa, salen), ==, 0);
ioc = qio_channel_new_fd(fd, &error_abort);
g_assert_cmpstr(object_get_typename(OBJECT(ioc)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment