aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-03-22 01:02:52 +0100
committerJan Kiszka <jan.kiszka@siemens.com>2012-03-28 20:33:26 +0200
commit1fd0f46da28127e457f0a96c1682d89d1b3043e7 (patch)
treeb33a91e44a7f2b5f929ee13e08b7c377834ba734
parent2e37cbed7cb15e6287d07ab0ceb60a2738eb2ce1 (diff)
downloadslirp-1fd0f46da28127e457f0a96c1682d89d1b3043e7.zip
slirp-1fd0f46da28127e457f0a96c1682d89d1b3043e7.tar.gz
slirp-1fd0f46da28127e457f0a96c1682d89d1b3043e7.tar.bz2
slirp: use socket_set_nonblock
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
-rw-r--r--misc.c44
-rw-r--r--tcp_subr.c4
2 files changed, 3 insertions, 45 deletions
diff --git a/misc.c b/misc.c
index e234ea9..50ff2b4 100644
--- a/misc.c
+++ b/misc.c
@@ -210,7 +210,7 @@ int fork_exec(struct socket *so, const char *ex, int do_pty)
setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
opt = 1;
setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
- fd_nonblock(so->s);
+ socket_set_nonblock(so->s);
/* Append the telnet options now */
if (so->so_m != NULL && do_pty == 1) {
@@ -259,48 +259,6 @@ void u_sleep(int usec)
select(0, &fdset, &fdset, &fdset, &t);
}
-/*
- * Set fd blocking and non-blocking
- */
-
-void fd_nonblock(int fd)
-{
-#ifdef FIONBIO
-#ifdef _WIN32
- unsigned long opt = 1;
-#else
- int opt = 1;
-#endif
-
- ioctlsocket(fd, FIONBIO, &opt);
-#else
- int opt;
-
- opt = fcntl(fd, F_GETFL, 0);
- opt |= O_NONBLOCK;
- fcntl(fd, F_SETFL, opt);
-#endif
-}
-
-void fd_block(int fd)
-{
-#ifdef FIONBIO
-#ifdef _WIN32
- unsigned long opt = 0;
-#else
- int opt = 0;
-#endif
-
- ioctlsocket(fd, FIONBIO, &opt);
-#else
- int opt;
-
- opt = fcntl(fd, F_GETFL, 0);
- opt &= ~O_NONBLOCK;
- fcntl(fd, F_SETFL, opt);
-#endif
-}
-
void slirp_connection_info(Slirp *slirp, Monitor *mon)
{
const char *const tcpstates[] = {
diff --git a/tcp_subr.c b/tcp_subr.c
index d57c142..6349d74 100644
--- a/tcp_subr.c
+++ b/tcp_subr.c
@@ -334,7 +334,7 @@ int tcp_fconnect(struct socket *so)
int opt, s = so->s;
struct sockaddr_in addr;
- fd_nonblock(s);
+ socket_set_nonblock(s);
opt = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
opt = 1;
@@ -422,7 +422,7 @@ void tcp_connect(struct socket *inso)
tcp_close(sototcpcb(so)); /* This will sofree() as well */
return;
}
- fd_nonblock(s);
+ socket_set_nonblock(s);
opt = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
opt = 1;