projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2010-02-19 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git]
/
mono
/
io-layer
/
collection.c
diff --git
a/mono/io-layer/collection.c
b/mono/io-layer/collection.c
index c3e72f48cfe1385079e1f776bff4e11317d78430..c8ec28e4c8ebd0d10be40c5b47634dd0411567fe 100644
(file)
--- a/
mono/io-layer/collection.c
+++ b/
mono/io-layer/collection.c
@@
-18,7
+18,8
@@
#include <mono/io-layer/collection.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/collection.h>
#include <mono/io-layer/handles-private.h>
-#undef DEBUG
+#define LOGDEBUG(...)
+// #define LOGDEBUG(...) g_message(__VA_ARGS__)
static pthread_t collection_thread_id;
static pthread_t collection_thread_id;
@@
-51,21
+52,32
@@
void _wapi_collection_init (void)
{
pthread_attr_t attr;
int ret;
{
pthread_attr_t attr;
int ret;
-
- ret = pthread_attr_init (&attr);
- g_assert (ret == 0);
-
+ int set_stacksize = 0;
+
+ retry:
+ ret = pthread_attr_init (&attr);
+ g_assert (ret == 0);
+
#ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
#ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
+ if (set_stacksize == 0) {
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__)
- ret = pthread_attr_setstacksize (&attr, 65536);
+
ret = pthread_attr_setstacksize (&attr, 65536);
#else
#else
- ret = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+
ret = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
#endif
#endif
- g_assert (ret == 0);
+ g_assert (ret == 0);
+ } else if (set_stacksize == 1) {
+ ret = pthread_attr_setstacksize (&attr, 131072);
+ g_assert (ret == 0);
+ }
#endif
#endif
- ret = pthread_create (&collection_thread_id, &attr, collection_thread,
- NULL);
+ ret = pthread_create (&collection_thread_id, &attr, collection_thread,
+ NULL);
+ if (ret != 0 && set_stacksize < 2) {
+ set_stacksize++;
+ goto retry;
+ }
if (ret != 0) {
g_error ("%s: Couldn't create handle collection thread: %s",
__func__, g_strerror (ret));
if (ret != 0) {
g_error ("%s: Couldn't create handle collection thread: %s",
__func__, g_strerror (ret));
@@
-77,18
+89,13
@@
void _wapi_handle_collect (void)
guint32 count = _wapi_shared_layout->collection_count;
int i, thr_ret;
guint32 count = _wapi_shared_layout->collection_count;
int i, thr_ret;
-#ifdef DEBUG
- g_message ("%s: (%d) Starting a collection", __func__,
- _wapi_getpid ());
-#endif
+ LOGDEBUG ("%s: (%d) Starting a collection", __func__, _wapi_getpid ());
/* Become the collection master */
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
/* Become the collection master */
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: (%d) Master set", __func__, _wapi_getpid ());
-#endif
+ LOGDEBUG ("%s: (%d) Master set", __func__, _wapi_getpid ());
/* If count has changed, someone else jumped in as master */
if (count == _wapi_shared_layout->collection_count) {
/* If count has changed, someone else jumped in as master */
if (count == _wapi_shared_layout->collection_count) {
@@
-99,9
+106,7
@@
void _wapi_handle_collect (void)
data = &_wapi_shared_layout->handles[i];
if (data->timestamp < too_old) {
data = &_wapi_shared_layout->handles[i];
if (data->timestamp < too_old) {
-#ifdef DEBUG
- g_message ("%s: (%d) Deleting handle 0x%x", __func__, _wapi_getpid (), i);
-#endif
+ LOGDEBUG ("%s: (%d) Deleting handle 0x%x", __func__, _wapi_getpid (), i);
memset (&_wapi_shared_layout->handles[i], '\0', sizeof(struct _WapiHandleShared));
}
}
memset (&_wapi_shared_layout->handles[i], '\0', sizeof(struct _WapiHandleShared));
}
}
@@
-120,7
+125,5
@@
void _wapi_handle_collect (void)
_wapi_handle_unlock_shared_handles ();
_wapi_handle_unlock_shared_handles ();
-#ifdef DEBUG
- g_message ("%s: (%d) Collection done", __func__, _wapi_getpid ());
-#endif
+ LOGDEBUG ("%s: (%d) Collection done", __func__, _wapi_getpid ());
}
}