The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.
Rename to qemu_set_nonblock() just like qemu_set_cloexec().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
/* Now that we're connected, set the socket to be non-blocking and
* kick the reply mechanism. */
- socket_set_nonblock(sock);
+ qemu_set_nonblock(sock);
qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL,
nbd_have_request, s);
qerror_report_err(err);
error_free(err);
} else {
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
}
return fd;
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int socket_set_cork(int fd, int v);
int socket_set_nodelay(int fd);
-void socket_set_block(int fd);
-void socket_set_nonblock(int fd);
+void qemu_set_block(int fd);
+void qemu_set_nonblock(int fd);
int send_all(int fd, const void *buf, int len1);
int recv_all(int fd, void *buf, int len1, bool single_read);
int fd = qemu_get_fd(f);
assert(fd != -1);
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
qemu_coroutine_enter(co, f);
}
[28 .. 151] reserved (0)
*/
- socket_set_block(csock);
+ qemu_set_block(csock);
rc = -EINVAL;
TRACE("Beginning negotiation.");
TRACE("Negotiation succeeded.");
rc = 0;
fail:
- socket_set_nonblock(csock);
+ qemu_set_nonblock(csock);
return rc;
}
TRACE("Receiving negotiation.");
- socket_set_block(csock);
+ qemu_set_block(csock);
rc = -EINVAL;
if (read_sync(csock, buf, 8) != 8) {
rc = 0;
fail:
- socket_set_nonblock(csock);
+ qemu_set_nonblock(csock);
return rc;
}
}
}
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
return fd;
fail:
if (fd >= 0)
perror("socket");
return -1;
}
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
/* allow fast reuse */
val = 1;
perror("socket");
return -1;
}
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
connected = 0;
for(;;) {
if (s->fd != -1)
return -1;
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
if (s->do_nodelay)
socket_set_nodelay(fd);
s->fd = fd;
printf("QEMU waiting for connection on: %s\n",
chr->filename);
tcp_chr_accept(s->listen_chan, G_IO_IN, chr);
- socket_set_nonblock(s->listen_fd);
+ qemu_set_nonblock(s->listen_fd);
}
return chr;
}
}
if (!is_waitconnect)
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
chr = qemu_chr_open_socket_fd(fd, do_nodelay, is_listen, is_telnet,
is_waitconnect, &local_err);
if (error_is_set(errp)) {
return NULL;
}
- socket_set_nonblock(fd);
+ qemu_set_nonblock(fd);
return qemu_chr_open_tty_fd(fd);
#else
error_setg(errp, "character device backend type 'serial' not supported");
s->fd = fd;
if (mode[0] == 'w') {
- socket_set_block(s->fd);
+ qemu_set_block(s->fd);
s->file = qemu_fopen_ops(s, &socket_write_ops);
} else {
s->file = qemu_fopen_ops(s, &socket_read_ops);
qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
opt = 1;
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
- socket_set_nonblock(so->s);
+ qemu_set_nonblock(so->s);
/* Append the telnet options now */
if (so->so_m != NULL && do_pty == 1) {
int opt, s=so->s;
struct sockaddr_in addr;
- socket_set_nonblock(s);
+ qemu_set_nonblock(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
opt = 1;
tcp_close(sototcpcb(so)); /* This will sofree() as well */
return;
}
- socket_set_nonblock(s);
+ qemu_set_nonblock(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
opt = 1;
VNC_DEBUG("New client on socket %d\n", csock);
vd->dcl.idle = 0;
- socket_set_nonblock(vs->csock);
+ qemu_set_nonblock(vs->csock);
#ifdef CONFIG_VNC_WS
if (websocket) {
vs->websocket = 1;
free(ptr);
}
-void socket_set_block(int fd)
+void qemu_set_block(int fd)
{
int f;
f = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
}
-void socket_set_nonblock(int fd)
+void qemu_set_nonblock(int fd)
{
int f;
f = fcntl(fd, F_GETFL);
return p;
}
-void socket_set_block(int fd)
+void qemu_set_block(int fd)
{
unsigned long opt = 0;
WSAEventSelect(fd, NULL, 0);
ioctlsocket(fd, FIONBIO, &opt);
}
-void socket_set_nonblock(int fd)
+void qemu_set_nonblock(int fd)
{
unsigned long opt = 1;
ioctlsocket(fd, FIONBIO, &opt);
}
qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (connect_state != NULL) {
- socket_set_nonblock(sock);
+ qemu_set_nonblock(sock);
}
/* connect to peer */
do {
connect_state = g_malloc0(sizeof(*connect_state));
connect_state->callback = callback;
connect_state->opaque = opaque;
- socket_set_nonblock(sock);
+ qemu_set_nonblock(sock);
}
memset(&un, 0, sizeof(un));