slirp/tcp_subr.c: fix coding style in tcp_connect
Fix coding style in tcp_connect before the next patch. Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2c20e711de
commit
4ef7b8944c
@ -384,8 +384,7 @@ int tcp_fconnect(struct socket *so)
|
|||||||
* the time it gets to accept(), so... We simply accept
|
* the time it gets to accept(), so... We simply accept
|
||||||
* here and SYN the local-host.
|
* here and SYN the local-host.
|
||||||
*/
|
*/
|
||||||
void
|
void tcp_connect(struct socket *inso)
|
||||||
tcp_connect(struct socket *inso)
|
|
||||||
{
|
{
|
||||||
Slirp *slirp = inso->slirp;
|
Slirp *slirp = inso->slirp;
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
@ -405,9 +404,10 @@ tcp_connect(struct socket *inso)
|
|||||||
/* FACCEPTONCE already have a tcpcb */
|
/* FACCEPTONCE already have a tcpcb */
|
||||||
so = inso;
|
so = inso;
|
||||||
} else {
|
} else {
|
||||||
if ((so = socreate(slirp)) == NULL) {
|
so = socreate(slirp);
|
||||||
|
if (so == NULL) {
|
||||||
/* If it failed, get rid of the pending connection */
|
/* If it failed, get rid of the pending connection */
|
||||||
closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen));
|
closesocket(accept(inso->s, (struct sockaddr *)&addr, &addrlen));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tcp_attach(so) < 0) {
|
if (tcp_attach(so) < 0) {
|
||||||
@ -418,19 +418,20 @@ tcp_connect(struct socket *inso)
|
|||||||
so->so_lport = inso->so_lport;
|
so->so_lport = inso->so_lport;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) tcp_mss(sototcpcb(so), 0);
|
tcp_mss(sototcpcb(so), 0);
|
||||||
|
|
||||||
if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
|
s = accept(inso->s, (struct sockaddr *)&addr, &addrlen);
|
||||||
|
if (s < 0) {
|
||||||
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket_set_nonblock(s);
|
socket_set_nonblock(s);
|
||||||
opt = 1;
|
opt = 1;
|
||||||
setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
|
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
|
||||||
opt = 1;
|
opt = 1;
|
||||||
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
|
||||||
opt = 1;
|
opt = 1;
|
||||||
setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));
|
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, sizeof(int));
|
||||||
|
|
||||||
so->so_fport = addr.sin_port;
|
so->so_fport = addr.sin_port;
|
||||||
so->so_faddr = addr.sin_addr;
|
so->so_faddr = addr.sin_addr;
|
||||||
@ -443,9 +444,12 @@ tcp_connect(struct socket *inso)
|
|||||||
|
|
||||||
/* Close the accept() socket, set right state */
|
/* Close the accept() socket, set right state */
|
||||||
if (inso->so_state & SS_FACCEPTONCE) {
|
if (inso->so_state & SS_FACCEPTONCE) {
|
||||||
closesocket(so->s); /* If we only accept once, close the accept() socket */
|
/* If we only accept once, close the accept() socket */
|
||||||
so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */
|
closesocket(so->s);
|
||||||
|
|
||||||
|
/* Don't select it yet, even though we have an FD */
|
||||||
/* if it's not FACCEPTONCE, it's already NOFDREF */
|
/* if it's not FACCEPTONCE, it's already NOFDREF */
|
||||||
|
so->so_state = SS_NOFDREF;
|
||||||
}
|
}
|
||||||
so->s = s;
|
so->s = s;
|
||||||
so->so_state |= SS_INCOMING;
|
so->so_state |= SS_INCOMING;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user