[前][次][番号順一覧][スレッド一覧]

ruby-changes:30539

From: nobu <ko1@a...>
Date: Mon, 19 Aug 2013 17:02:04 +0900 (JST)
Subject: [ruby-changes:30539] nobu:r42618 (trunk): process.c: retry fork if ENOMEM

nobu	2013-08-19 17:01:26 +0900 (Mon, 19 Aug 2013)

  New Revision: 42618

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42618

  Log:
    process.c: retry fork if ENOMEM
    
    * process.c (retry_fork): retry with GC if ENOMEM occurred, to free
      swap/kernel space.

  Modified files:
    trunk/ChangeLog
    trunk/process.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42617)
+++ ChangeLog	(revision 42618)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Aug 19 17:00:53 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (retry_fork): retry with GC if ENOMEM occurred, to free
+	  swap/kernel space.
+
 Mon Aug 19 13:28:47 2013  NAKAMURA Usaku  <usa@r...>
 
 	* include/ruby/win32.h (CLOCK_MONOTONIC): typo.
Index: process.c
===================================================================
--- process.c	(revision 42617)
+++ process.c	(revision 42618)
@@ -3246,6 +3246,7 @@ retry_fork(int *status, int *ep, int chf https://github.com/ruby/ruby/blob/trunk/process.c#L3246
 {
     rb_pid_t pid;
     int state = 0;
+    int try_gc = 1;
 
 #define prefork() (		\
 	rb_io_flush(rb_stdout), \
@@ -3265,6 +3266,12 @@ retry_fork(int *status, int *ep, int chf https://github.com/ruby/ruby/blob/trunk/process.c#L3266
             return pid;
         /* fork failed */
 	switch (errno) {
+	  case ENOMEM:
+	    if (try_gc-- > 0 && !rb_during_gc()) {
+		rb_gc();
+		continue;
+	    }
+	    break;
 	  case EAGAIN:
 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
 	  case EWOULDBLOCK:
@@ -3278,14 +3285,13 @@ retry_fork(int *status, int *ep, int chf https://github.com/ruby/ruby/blob/trunk/process.c#L3285
 		if (status) *status = state;
 		if (!state) continue;
 	    }
-            /* fall through */
-	  default:
-	    if (ep) {
-		preserving_errno((close(ep[0]), close(ep[1])));
-	    }
-	    if (state && !status) rb_jump_tag(state);
-	    return -1;
+	    break;
+	}
+	if (ep) {
+	    preserving_errno((close(ep[0]), close(ep[1])));
 	}
+	if (state && !status) rb_jump_tag(state);
+	return -1;
     }
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]