BUGFIX : Possible linked list bug

This commit is contained in:
Malcolm Robb 2014-04-25 17:00:58 +01:00
parent 30ae45ec2b
commit d200099244
5 changed files with 10 additions and 9 deletions

Binary file not shown.

Binary file not shown.

11
anet.c
View file

@ -282,18 +282,15 @@ static int anetGenericAccept(char *err, int s, struct sockaddr *sa, socklen_t *l
while(1) { while(1) {
fd = accept(s,sa,len); fd = accept(s,sa,len);
if (fd == -1) { if (fd == -1) {
#ifdef _WIN32
errno = WSAGetLastError();
#endif
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
#ifndef _WIN32 #ifndef _WIN32
} else if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
#else
errno = WSAGetLastError();
if (errno == WSAEWOULDBLOCK) {
#endif #endif
} else { } else {
anetSetError(err, "accept: %s", strerror(errno)); anetSetError(err, "accept: %s", strerror(errno));
return ANET_ERR;
} }
} }
break; break;

View file

@ -178,7 +178,9 @@ void modesSendAllClients(int service, void *msg, int len) {
struct client *c = Modes.clients; struct client *c = Modes.clients;
while (c) { while (c) {
// Read next before servicing client incase the service routine deletes the client!
struct client *next = c->next; struct client *next = c->next;
if (c->service == service) { if (c->service == service) {
#ifndef _WIN32 #ifndef _WIN32
int nwritten = write(c->fd, msg, len); int nwritten = write(c->fd, msg, len);
@ -921,6 +923,9 @@ void modesReadFromClients(void) {
struct client *c = modesAcceptClients(); struct client *c = modesAcceptClients();
while (c) { while (c) {
// Read next before servicing client incase the service routine deletes the client!
struct client *next = c->next;
if (c->service == Modes.ris) { if (c->service == Modes.ris) {
modesReadFromClient(c,"\n",decodeHexMessage); modesReadFromClient(c,"\n",decodeHexMessage);
} else if (c->service == Modes.bis) { } else if (c->service == Modes.bis) {
@ -928,7 +933,7 @@ void modesReadFromClients(void) {
} else if (c->service == Modes.https) { } else if (c->service == Modes.https) {
modesReadFromClient(c,"\r\n\r\n",handleHTTPRequest); modesReadFromClient(c,"\r\n\r\n",handleHTTPRequest);
} }
c = c->next; c = next;
} }
} }
// //

View file

@ -101,7 +101,6 @@ _inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
#define STDIN_FILENO 0 #define STDIN_FILENO 0
#define EINPROGRESS WSAEINPROGRESS #define EINPROGRESS WSAEINPROGRESS
#define EWOULDBLOCK WSAEWOULDBLOCK
#ifdef __cplusplus #ifdef __cplusplus
} }