Permalink
Browse files

Avoid possible duplicate fds in the list

  • Loading branch information...
1 parent 4702486 commit 782e336a499e75d32ddbb021662416e15d06a0db @gonzalop gonzalop committed Jul 24, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 mono/metadata/tpool-poll.c
View
@@ -216,11 +216,22 @@ tp_poll_wait (gpointer p)
/* Got a new socket */
if ((pfds->revents & MONO_POLLIN) != 0) {
int nread;
+ gboolean found = FALSE;
for (i = 1; i < allocated; i++) {
pfd = &pfds [i];
- if (pfd->fd == -1 || pfd->fd == data->newpfd.fd)
+ if (pfd->fd == data->newpfd.fd) {
+ found = TRUE;
break;
+ }
+ }
+
+ if (!found) {
+ for (i = 1; i < allocated; i++) {
+ pfd = &pfds [i];
+ if (pfd->fd == -1)
+ break;
+ }
}
if (i == allocated) {

0 comments on commit 782e336

Please sign in to comment.