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

ruby-changes:24145

From: akr <ko1@a...>
Date: Sat, 23 Jun 2012 16:30:48 +0900 (JST)
Subject: [ruby-changes:24145] akr:r36196 (trunk): * internal.h (rb_execarg): add rlimit_limits field.

akr	2012-06-23 16:30:26 +0900 (Sat, 23 Jun 2012)

  New Revision: 36196

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

  Log:
    * internal.h (rb_execarg): add rlimit_limits field.
    
    * process.c (EXEC_OPTION_RLIMIT): removed.
      (mark_exec_arg): mark rlimit_limits field.
      (rb_execarg_addopt): update the new fields, instead of options array.
      (run_exec_rlimit): use the new field.
      (rb_execarg_run_options): clear sarg using MEMZERO.  use the new
      field.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36195)
+++ ChangeLog	(revision 36196)
@@ -1,3 +1,14 @@
+Sat Jun 23 16:27:01 2012  Tanaka Akira  <akr@f...>
+
+	* internal.h (rb_execarg): add rlimit_limits field.
+
+	* process.c (EXEC_OPTION_RLIMIT): removed.
+	  (mark_exec_arg): mark rlimit_limits field.
+	  (rb_execarg_addopt): update the new fields, instead of options array.
+	  (run_exec_rlimit): use the new field.
+	  (rb_execarg_run_options): clear sarg using MEMZERO.  use the new
+	  field.
+
 Sat Jun 23 14:29:25 2012  Tanaka Akira  <akr@f...>
 
 	* internal.h (rb_execarg): add chdir_given and chdir_dir fields.
Index: process.c
===================================================================
--- process.c	(revision 36195)
+++ process.c	(revision 36196)
@@ -1254,7 +1254,6 @@
 }
 
 enum {
-    EXEC_OPTION_RLIMIT,
     EXEC_OPTION_ENV,
     EXEC_OPTION_DUP2,
     EXEC_OPTION_CLOSE,
@@ -1280,6 +1279,7 @@
     rb_gc_mark(eargp->envp_str);
     rb_gc_mark(eargp->envp_buf);
     rb_gc_mark(eargp->dup2_tmpbuf);
+    rb_gc_mark(eargp->rlimit_limits);
     rb_gc_mark(eargp->chdir_dir);
 }
 
@@ -1588,12 +1588,12 @@
 #if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
         if (strncmp("rlimit_", rb_id2name(id), 7) == 0 &&
             (rtype = rlimit_type_by_lname(rb_id2name(id)+7)) != -1) {
-            VALUE ary = rb_ary_entry(options, EXEC_OPTION_RLIMIT);
+            VALUE ary = eargp->rlimit_limits;
             VALUE tmp, softlim, hardlim;
-            if (NIL_P(ary)) {
-                ary = hide_obj(rb_ary_new());
-                rb_ary_store(options, EXEC_OPTION_RLIMIT, ary);
-            }
+            if (eargp->rlimit_limits == Qfalse)
+                ary = eargp->rlimit_limits = hide_obj(rb_ary_new());
+            else
+                ary = eargp->rlimit_limits;
             tmp = rb_check_array_type(val);
             if (!NIL_P(tmp)) {
                 if (RARRAY_LEN(tmp) == 1)
@@ -2665,7 +2665,6 @@
         int rtype = NUM2INT(RARRAY_PTR(elt)[0]);
         struct rlimit rlim;
         if (sargp) {
-	    VALUE soptions = sargp->options;
             VALUE tmp, newary;
             if (getrlimit(rtype, &rlim) == -1) {
                 ERRMSG("getrlimit");
@@ -2674,11 +2673,10 @@
             tmp = hide_obj(rb_ary_new3(3, RARRAY_PTR(elt)[0],
                                        RLIM2NUM(rlim.rlim_cur),
                                        RLIM2NUM(rlim.rlim_max)));
-            newary = rb_ary_entry(soptions, EXEC_OPTION_RLIMIT);
-            if (NIL_P(newary)) {
-                newary = hide_obj(rb_ary_new());
-                rb_ary_store(soptions, EXEC_OPTION_RLIMIT, newary);
-            }
+            if (sargp->rlimit_limits == Qfalse)
+                newary = sargp->rlimit_limits = hide_obj(rb_ary_new());
+            else 
+                newary = sargp->rlimit_limits;
             rb_ary_push(newary, tmp);
         }
         rlim.rlim_cur = NUM2RLIM(RARRAY_PTR(elt)[1]);
@@ -2732,9 +2730,9 @@
 
     if (sargp) {
         /* assume that sargp is always NULL on fork-able environments */
+        MEMZERO(sargp, struct rb_execarg, 1);
         sargp->options = hide_obj(rb_ary_new());
         sargp->redirect_fds = Qnil;
-	sargp->envp_str = sargp->envp_buf = 0;
     }
 
 #ifdef HAVE_SETPGID
@@ -2745,8 +2743,8 @@
 #endif
 
 #if defined(HAVE_SETRLIMIT) && defined(RLIM2NUM)
-    obj = rb_ary_entry(options, EXEC_OPTION_RLIMIT);
-    if (!NIL_P(obj)) {
+    obj = eargp->rlimit_limits;
+    if (obj != Qfalse) {
         if (run_exec_rlimit(obj, sargp, errmsg, errmsg_buflen) == -1) /* hopefully async-signal-safe */
             return -1;
     }
Index: internal.h
===================================================================
--- internal.h	(revision 36195)
+++ internal.h	(revision 36196)
@@ -184,6 +184,7 @@
     unsigned close_others_do : 1;
     unsigned chdir_given : 1;
     pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
+    VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
     mode_t umask_mask;
     int close_others_maxhint;
     VALUE chdir_dir;

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

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