diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2009-06-24 14:42:29 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-29 08:52:45 -0500 |
commit | f932b6ce717e65687c3095e3e41a6c18972f996c (patch) | |
tree | 44d74bc4164e3c43d2ac9a7b372b842cd8db2537 /slirp/socket.c | |
parent | 3c6a05803c8f33b2ce6f704df87c98983029befd (diff) |
slirp: Prepare for persistent socket state flags
This prepares for adding flags to socket.so_state that must not be
removed during the lifetime of a socket.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp/socket.c')
-rw-r--r-- | slirp/socket.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/slirp/socket.c b/slirp/socket.c index 936021e84d..6b3da0a112 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -581,7 +581,8 @@ sosendto(struct socket *so, struct mbuf *m) */ if (so->so_expire) so->so_expire = curtime + SO_EXPIRE; - so->so_state = SS_ISFCONNECTED; /* So that it gets select()ed */ + so->so_state &= SS_PERSISTENT_MASK; + so->so_state |= SS_ISFCONNECTED; /* So that it gets select()ed */ return 0; } @@ -620,7 +621,8 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags if (flags & SS_FACCEPTONCE) so->so_tcpcb->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT*2; - so->so_state = (SS_FACCEPTCONN|flags); + so->so_state &= SS_PERSISTENT_MASK; + so->so_state |= (SS_FACCEPTCONN | flags); so->so_lport = lport; /* Kept in network format */ so->so_laddr.s_addr = laddr; /* Ditto */ @@ -715,10 +717,12 @@ sofcantrcvmore(struct socket *so) } } so->so_state &= ~(SS_ISFCONNECTING); - if (so->so_state & SS_FCANTSENDMORE) - so->so_state = SS_NOFDREF; /* Don't select it */ /* XXX close() here as well? */ - else + if (so->so_state & SS_FCANTSENDMORE) { + so->so_state &= SS_PERSISTENT_MASK; + so->so_state |= SS_NOFDREF; /* Don't select it */ + } else { so->so_state |= SS_FCANTRCVMORE; + } } static void @@ -734,10 +738,12 @@ sofcantsendmore(struct socket *so) } } so->so_state &= ~(SS_ISFCONNECTING); - if (so->so_state & SS_FCANTRCVMORE) - so->so_state = SS_NOFDREF; /* as above */ - else + if (so->so_state & SS_FCANTRCVMORE) { + so->so_state &= SS_PERSISTENT_MASK; + so->so_state |= SS_NOFDREF; /* as above */ + } else { so->so_state |= SS_FCANTSENDMORE; + } } void |