Skip to content

Commit

Permalink
avoid double-close fds that were either collected or disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhuw committed Apr 10, 2012
1 parent 5d2bba5 commit 3954dd2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mread.c
Expand Up @@ -25,6 +25,8 @@
#define SOCKET_READ 3
#define SOCKET_POLLIN 4

#define SOCKET_ALIVE SOCKET_SUSPEND

struct socket {
int fd;
struct ringbuffer_block * node;
Expand Down Expand Up @@ -144,7 +146,7 @@ mread_close(struct mread_pool *self) {
int i;
struct socket * s = self->sockets;
for (i=0;i<self->max_connection;i++) {
if (s[i].status != SOCKET_INVALID) {
if (s[i].status >= SOCKET_ALIVE) {
close(s[i].fd);
}
}
Expand Down

0 comments on commit 3954dd2

Please sign in to comment.