Guard against closing clients in a couple of places.
In particular, not guarding in flushWrites() meant that we could end up trying to write to an uninitialized writer (where writer->service == c->service == NULL) and crashing.
This commit is contained in:
parent
8d1df036ae
commit
c7722f2b97
4
net_io.c
4
net_io.c
|
@ -273,6 +273,8 @@ static void flushWrites(struct net_writer *writer) {
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
for (c = Modes.clients; c; c = c->next) {
|
for (c = Modes.clients; c; c = c->next) {
|
||||||
|
if (!c->service)
|
||||||
|
continue;
|
||||||
if (c->service == writer->service) {
|
if (c->service == writer->service) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
int nwritten = write(c->fd, writer->data, writer->dataUsed);
|
int nwritten = write(c->fd, writer->data, writer->dataUsed);
|
||||||
|
@ -1662,6 +1664,8 @@ void modesNetPeriodicWork(void) {
|
||||||
|
|
||||||
// Read from clients
|
// Read from clients
|
||||||
for (c = Modes.clients; c; c = c->next) {
|
for (c = Modes.clients; c; c = c->next) {
|
||||||
|
if (!c->service)
|
||||||
|
continue;
|
||||||
if (c->service->read_handler)
|
if (c->service->read_handler)
|
||||||
modesReadFromClient(c);
|
modesReadFromClient(c);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue