diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-26 08:01:35 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-26 08:01:35 +0000 |
commit | 91aba07aff667eb31cf18d9b8849a60fcdc6e18a (patch) | |
tree | 8c702e33cf2973c88f84b2163ca576424689cbd5 /thread_pthread.c | |
parent | 5605afa5e218ea9ee62c4da358fab01b1bfa23e7 (diff) | |
download | ruby-91aba07aff667eb31cf18d9b8849a60fcdc6e18a.tar.gz |
* thread_pthread.c (register_cached_thread_and_wait):
return immediately if malloc() failed.
[ruby-core:43960] [ruby-trunk - Bug #6235]
* thread_pthread.c (USE_THREAD_CACHE): check already defined or not.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 06769bd293..9075314135 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -480,7 +480,9 @@ native_thread_destroy(rb_thread_t *th) #endif } +#ifndef USE_THREAD_CACHE #define USE_THREAD_CACHE 0 +#endif #if USE_THREAD_CACHE static rb_thread_t *register_cached_thread_and_wait(void); @@ -717,11 +719,15 @@ register_cached_thread_and_wait(void) { rb_thread_cond_t cond = { PTHREAD_COND_INITIALIZER, }; volatile rb_thread_t *th_area = 0; + struct timeval tv; + struct timespec ts; struct cached_thread_entry *entry = (struct cached_thread_entry *)malloc(sizeof(struct cached_thread_entry)); - struct timeval tv; - struct timespec ts; + if (entry == 0) { + return 0; /* failed -> terminate thread immediately */ + } + gettimeofday(&tv, 0); ts.tv_sec = tv.tv_sec + 60; ts.tv_nsec = tv.tv_usec * 1000; |