Fix call to mono_sgen_gc_unlock () in mono_gc_toggleref_add ().
[mono.git] / mono / metadata / tpool-epoll.c
index 18c6a204bfb30cdc093f78cde1ca1de5f67110bd..43a196dc9ede90ebb3cb5cc2d1a2123e10b44b23 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
  * Copyright 2004-2011 Novell, Inc (http://www.novell.com)
+ * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
  */
 
 struct _tp_epoll_data {
@@ -30,8 +31,18 @@ tp_epoll_init (SocketIOData *data)
        result->epollfd = epoll_create (256); /* The number does not really matter */
        fcntl (result->epollfd, F_SETFD, FD_CLOEXEC);
 #endif
-       if (result->epollfd == -1)
+       if (result->epollfd == -1) {
+               int err = errno;
+               if (g_getenv ("MONO_DEBUG")) {
+#ifdef EPOLL_CLOEXEC
+                       g_message ("epoll_create1(EPOLL_CLOEXEC) failed: %d %s", err, g_strerror (err));
+#else
+                       g_message ("epoll_create(256) failed: %d %s", err, g_strerror (err));
+#endif
+               }
+
                return NULL;
+       }
 
        data->shutdown = tp_epoll_shutdown;
        data->modify = tp_epoll_modify;
@@ -159,7 +170,7 @@ tp_epoll_wait (gpointer p)
                }
                LeaveCriticalSection (&socket_io_data->io_lock);
                threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results, nresults);
-               memset (async_results, 0, sizeof (gpointer) * nresults);
+               mono_gc_bzero (async_results, sizeof (gpointer) * nresults);
        }
 }
 #undef EPOLL_NEVENTS