mirror of https://github.com/xqemu/xqemu.git
slirp: slirp/slirp.c coding style cleanup
The slirp glue code uses tabs in some places. Since the next patch will modify the file, convert tabs to spaces and fix checkpatch.pl issues. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-id: 1361356113-11049-5-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
48ce11ff97
commit
cf1d078e4e
|
@ -307,15 +307,17 @@ void slirp_select_fill(int *pnfds,
|
|||
/*
|
||||
* See if we need a tcp_fasttimo
|
||||
*/
|
||||
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
|
||||
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) {
|
||||
time_fasttimo = curtime; /* Flag when we want a fasttimo */
|
||||
}
|
||||
|
||||
/*
|
||||
* NOFDREF can include still connecting to local-host,
|
||||
* newly socreated() sockets etc. Don't want to select these.
|
||||
*/
|
||||
if (so->so_state & SS_NOFDREF || so->s == -1)
|
||||
if (so->so_state & SS_NOFDREF || so->s == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set for reading sockets which are accepting
|
||||
|
@ -348,7 +350,8 @@ void slirp_select_fill(int *pnfds,
|
|||
* Set for reading (and urgent data) if we are connected, can
|
||||
* receive more, and we have room for it XXX /2 ?
|
||||
*/
|
||||
if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
|
||||
if (CONN_CANFRCV(so) &&
|
||||
(so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
|
||||
FD_SET(so->s, readfds);
|
||||
FD_SET(so->s, xfds);
|
||||
UPD_NFDS(so->s);
|
||||
|
@ -369,9 +372,10 @@ void slirp_select_fill(int *pnfds,
|
|||
if (so->so_expire <= curtime) {
|
||||
udp_detach(so);
|
||||
continue;
|
||||
} else
|
||||
} else {
|
||||
do_slowtimo = 1; /* Let socket expire */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When UDP packets are received from over the
|
||||
|
@ -464,16 +468,18 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
* FD_ISSET is meaningless on these sockets
|
||||
* (and they can crash the program)
|
||||
*/
|
||||
if (so->so_state & SS_NOFDREF || so->s == -1)
|
||||
if (so->so_state & SS_NOFDREF || so->s == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for URG data
|
||||
* This will soread as well, so no need to
|
||||
* test for readfds below if this succeeds
|
||||
*/
|
||||
if (FD_ISSET(so->s, xfds))
|
||||
if (FD_ISSET(so->s, xfds)) {
|
||||
sorecvoob(so);
|
||||
}
|
||||
/*
|
||||
* Check sockets for reading
|
||||
*/
|
||||
|
@ -488,9 +494,10 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
ret = soread(so);
|
||||
|
||||
/* Output it if we read something */
|
||||
if (ret > 0)
|
||||
if (ret > 0) {
|
||||
tcp_output(sototcpcb(so));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check sockets for writing
|
||||
|
@ -507,8 +514,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
if (ret < 0) {
|
||||
/* XXXXX Must fix, zero bytes is a NOP */
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
||||
errno == EINPROGRESS || errno == ENOTCONN)
|
||||
errno == EINPROGRESS || errno == ENOTCONN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* else failed */
|
||||
so->so_state &= SS_PERSISTENT_MASK;
|
||||
|
@ -521,8 +529,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
*/
|
||||
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
|
||||
/* continue; */
|
||||
} else
|
||||
} else {
|
||||
ret = sowrite(so);
|
||||
}
|
||||
/*
|
||||
* XXXXX If we wrote something (a lot), there
|
||||
* could be a need for a window update.
|
||||
|
@ -537,13 +546,14 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
*/
|
||||
#ifdef PROBE_CONN
|
||||
if (so->so_state & SS_ISFCONNECTING) {
|
||||
ret = qemu_recv(so->s, &ret, 0,0);
|
||||
ret = qemu_recv(so->s, &ret, 0, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
/* XXX */
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
||||
errno == EINPROGRESS || errno == ENOTCONN)
|
||||
errno == EINPROGRESS || errno == ENOTCONN) {
|
||||
continue; /* Still connecting, continue */
|
||||
}
|
||||
|
||||
/* else failed */
|
||||
so->so_state &= SS_PERSISTENT_MASK;
|
||||
|
@ -551,20 +561,22 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
|
|||
|
||||
/* tcp_input will take care of it */
|
||||
} else {
|
||||
ret = send(so->s, &ret, 0,0);
|
||||
ret = send(so->s, &ret, 0, 0);
|
||||
if (ret < 0) {
|
||||
/* XXX */
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
||||
errno == EINPROGRESS || errno == ENOTCONN)
|
||||
errno == EINPROGRESS || errno == ENOTCONN) {
|
||||
continue;
|
||||
}
|
||||
/* else failed */
|
||||
so->so_state &= SS_PERSISTENT_MASK;
|
||||
so->so_state |= SS_NOFDREF;
|
||||
} else
|
||||
} else {
|
||||
so->so_state &= ~SS_ISFCONNECTING;
|
||||
}
|
||||
|
||||
}
|
||||
tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
|
||||
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
|
||||
} /* SS_ISFCONNECTING */
|
||||
#endif
|
||||
}
|
||||
|
@ -857,11 +869,13 @@ size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
|
|||
|
||||
so = slirp_find_ctl_socket(slirp, guest_addr, guest_port);
|
||||
|
||||
if (!so || so->so_state & SS_NOFDREF)
|
||||
if (!so || so->so_state & SS_NOFDREF) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2))
|
||||
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sopreprbuf(so, iov, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue