mirror of https://github.com/ericonr/sndio.git
In the "reply" code path, lock the socket while invoking the
write-end code from the read-end code, and don't forget to check if the socket was not destroyed. Fixes very rare random crashes.
This commit is contained in:
parent
2775f46e12
commit
10efdd93f3
26
aucat/sock.c
26
aucat/sock.c
|
@ -1554,6 +1554,8 @@ sock_buildmsg(struct sock *f)
|
|||
int
|
||||
sock_read(struct sock *f)
|
||||
{
|
||||
int rc;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug_level >= 4) {
|
||||
sock_dbg(f);
|
||||
|
@ -1597,7 +1599,14 @@ sock_read(struct sock *f)
|
|||
/*
|
||||
* send pending ACKs, initial positions, initial volumes
|
||||
*/
|
||||
if (!sock_write(f))
|
||||
f->pipe.file.state |= FILE_WINUSE;
|
||||
rc = sock_write(f);
|
||||
f->pipe.file.state &= ~FILE_WINUSE;
|
||||
if (f->pipe.file.state & FILE_ZOMB) {
|
||||
file_del(&f->pipe.file);
|
||||
return 0;
|
||||
}
|
||||
if (!rc)
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
@ -1631,13 +1640,24 @@ sock_return(struct sock *f)
|
|||
* wsock.
|
||||
*/
|
||||
rp = f->pipe.file.rproc;
|
||||
if (!rp || !rp->ops->in(rp, NULL))
|
||||
if (!rp)
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
if (debug_level >= 4) {
|
||||
aproc_dbg(rp);
|
||||
dbg_puts(": in\n");
|
||||
}
|
||||
#endif
|
||||
if (!rp->ops->in(rp, NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
f->pipe.file.state &= ~FILE_RINUSE;
|
||||
if (f->pipe.file.wproc == NULL)
|
||||
if (f->pipe.file.state & FILE_ZOMB) {
|
||||
file_del(&f->pipe.file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue