s->s_error = ne.ret;
wakeup_all(s);
break;
+ case NE_UNHOOK:
+ if (s->s_state == SS_DEAD)
+ sock_closed(s);
+ else
+ kputs("bad unhook (in use)\n");
+ break;
default:
kprintf("netbad %d\n", ne.event);
udata.u_error = EOPNOTSUPP;
selwake_dev(4, 65, SELECT_IN);
do {
- if( s->s_state == SS_CLOSED )
+ kprintf("Wait %d in %d\n", state, s->s_state);
+ if( s->s_state == SS_CLOSED || s->s_state == SS_DEAD)
return -1;
psleep_nosig(s);
} while (sd->event & NEVW_STATE);
*/
int net_init(struct socket *s)
{
- int x;
struct sockdata *sd = sockdata + s->s_num;
if (!net_ino) {
udata.u_error = ENETDOWN;
* implementation has longer lived resources (eg a TCP port moving
* into TIME_WAIT) then the socket and internal resources must be
* disconnected from one another.
+ *
+ * Fuzix close() methods are not permitted to block.
*/
void net_close(struct socket *s)
{
struct sockdata *sd = s->s_priv;
/* Caution here - the native tcp socket will hang around longer */
- sd->newstate = SS_CLOSED;
+ sd->newstate = SS_DEAD;
netn_asynchronous_event(s, NEV_STATE|NEVW_STATE);
- /* Don't block. We won't reuse the entry until it moves to
- CLOSED state */
+ /* The stack will see the closed state and then we will
+ progress to SS_DEAD. When the stack is finished with us it
+ will send an UNHOOK message which will do the final resource
+ clean up and allow the socket to be reused */
}
/*