lib9p: defer freeing srv for listensrv()
use the Srv.end callback for freeing the srv and closing the file descriptor of a connection. this makes sure we wont free the srv while there are still outstanding requests that would access the srv when doing the respond() call.
This commit is contained in:
parent
2c62f8dc67
commit
6b4c5380d8
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
static void listenproc(void*);
|
static void listenproc(void*);
|
||||||
static void srvproc(void*);
|
static void srvproc(void*);
|
||||||
|
static void srvend(Srv *);
|
||||||
static char *getremotesys(char*);
|
static char *getremotesys(char*);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -57,6 +58,7 @@ listenproc(void *v)
|
||||||
s->rpool = nil;
|
s->rpool = nil;
|
||||||
s->rbuf = nil;
|
s->rbuf = nil;
|
||||||
s->wbuf = nil;
|
s->wbuf = nil;
|
||||||
|
s->end = srvend;
|
||||||
_forker(srvproc, s, 0);
|
_forker(srvproc, s, 0);
|
||||||
}
|
}
|
||||||
free(os->addr);
|
free(os->addr);
|
||||||
|
@ -66,13 +68,13 @@ listenproc(void *v)
|
||||||
static void
|
static void
|
||||||
srvproc(void *v)
|
srvproc(void *v)
|
||||||
{
|
{
|
||||||
int data;
|
srv((Srv*)v);
|
||||||
Srv *s;
|
}
|
||||||
|
|
||||||
s = v;
|
static void
|
||||||
data = s->infd;
|
srvend(Srv *s)
|
||||||
srv(s);
|
{
|
||||||
close(data);
|
close(s->infd);
|
||||||
free(s->addr);
|
free(s->addr);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue