Author: gonzalo
Date: 2005-04-14 05:11:17 -0400 (Thu, 14 Apr 2005)
New Revision: 42990

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/threadpool.c
Log:
2005-04-14 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * threadpool.c: sometimes we get EBADF from epoll but the epollfd is
        not closed, so don't cleanup when it happens.



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2005-04-14 07:50:39 UTC (rev 42989)
+++ trunk/mono/mono/metadata/ChangeLog  2005-04-14 09:11:17 UTC (rev 42990)
@@ -1,3 +1,8 @@
+2005-04-14 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * threadpool.c: sometimes we get EBADF from epoll but the epollfd is
+       not closed, so don't cleanup when it happens.
+
 2005-04-13  Chris Toshok  <[EMAIL PROTECTED]>
 
        * mono-debug-debugger.h: change prototype for

Modified: trunk/mono/mono/metadata/threadpool.c
===================================================================
--- trunk/mono/mono/metadata/threadpool.c       2005-04-14 07:50:39 UTC (rev 
42989)
+++ trunk/mono/mono/metadata/threadpool.c       2005-04-14 09:11:17 UTC (rev 
42990)
@@ -48,6 +48,7 @@
 #include "threadpool.h"
 
 #undef EPOLL_DEBUG
+
 /* maximum number of worker threads */
 static int mono_max_worker_threads = THREADS_PER_CPU;
 static int mono_min_worker_threads = 0;
@@ -506,7 +507,7 @@
 #ifdef EPOLL_DEBUG
                        {
                        int err = errno;
-                       g_print ("epoll_wait end with %d ready sockets.\n", 
ready);
+                       g_print ("epoll_wait end with %d ready sockets (%d 
%s).\n", ready, err, (err) ? g_strerror (err) : "");
                        errno = err;
                        }
 #endif
@@ -557,26 +558,20 @@
                                g_print ("MOD %d to %d\n", fd, evt->events);
 #endif
                                if (epoll_ctl (epollfd, EPOLL_CTL_MOD, fd, 
evt)) {
-                                       int err = errno;
-                                       if (err == EBADF) {
-                                               g_free (events);
-                                               return; /* epollfd closed */
+                                       if (epoll_ctl (epollfd, EPOLL_CTL_ADD, 
fd, evt) == -1) {
+#ifdef EPOLL_DEBUG
+                                               int err = errno;
+                                               g_message ("epoll_ctl(MOD): %d 
%s fd: %d events: %d", err, g_strerror (err), fd, evt->events);
+                                               errno = err;
+#endif
                                        }
-                                       g_message ("epoll_ctl(MOD): %d %s fd: 
%d events: %d", err, g_strerror (err), fd, evt->events);
                                }
                        } else {
                                g_hash_table_remove (data->sock_to_state, 
GINT_TO_POINTER (fd));
 #ifdef EPOLL_DEBUG
                                g_print ("DEL %d\n", fd);
 #endif
-                               if (epoll_ctl (epollfd, EPOLL_CTL_DEL, fd, 
evt)) {
-                                       int err = errno;
-                                       if (err == EBADF) {
-                                               g_free (events);
-                                               return; /* epollfd closed */
-                                       }
-                                       g_message ("epoll_ctl(DEL): %d %s", 
err, g_strerror (err));
-                               }
+                               epoll_ctl (epollfd, EPOLL_CTL_DEL, fd, evt);
                        }
                }
                LeaveCriticalSection (&data->io_lock);
@@ -759,10 +754,11 @@
 #endif
        if (epoll_ctl (data->epollfd, epoll_op, fd, &event) == -1) {
                int err = errno;
-               g_message ("epoll_ctl(ADD): %d %s\n", err, g_strerror (err));
-               epoll_op = EPOLL_CTL_MOD;
-               if (epoll_ctl (data->epollfd, epoll_op, fd, &event) == -1) {
-                       g_message ("epoll_ctl(MOD): %d %s\n", err, g_strerror 
(err));
+               if (epoll_op == EPOLL_CTL_ADD && err == EEXIST) {
+                       epoll_op = EPOLL_CTL_MOD;
+                       if (epoll_ctl (data->epollfd, epoll_op, fd, &event) == 
-1) {
+                               g_message ("epoll_ctl(MOD): %d %s\n", err, 
g_strerror (err));
+                       }
                }
        }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to