RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm-5_3: rpm/ CHANGES rpm/rpmio/ rpmruby.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 19 Sep 2010 - 05:32:05 CEST
Message-Id: <20100919033205.CB2D5DA79C@rpm5.org>
  RPM Package Manager, CVS Repository
  /cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   19-Sep-2010 05:32:05
  Branch: rpm-5_3                          Handle: 2010091903320401

  Modified files:           (Branch: rpm-5_3)
    rpm                     CHANGES
    rpm/rpmio               rpmruby.c

  Log:
    - ruby: don't load stringio for now, there's a segfault here.
    - ruby: wire-up a global interpreter always.

  Summary:
    Revision    Changes     Path
    1.3296.2.75 +2  -0      rpm/CHANGES
    2.12.2.4    +46 -25     rpm/rpmio/rpmruby.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3296.2.74 -r1.3296.2.75 CHANGES
  --- rpm/CHANGES	19 Sep 2010 03:28:50 -0000	1.3296.2.74
  +++ rpm/CHANGES	19 Sep 2010 03:32:04 -0000	1.3296.2.75
  @@ -1,4 +1,6 @@
   5.3.3 -> 5.3.4:
  +    - jbj: ruby: don't load stringio for now, there's a segfault here.
  +    - jbj: ruby: wire-up a global interpreter always.
       - jbj: autofu: hot-wire ruby-1.9.2p0 embedding.
       - jbj: ruby: add a ruby-config helper for RPM_CHECK_LIB().
       - jbj: tests: mark mtree breakage on rhel6 for fixing.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmruby.c
  ============================================================================
  $ cvs diff -u -r2.12.2.3 -r2.12.2.4 rpmruby.c
  --- rpm/rpmio/rpmruby.c	16 Aug 2010 13:17:11 -0000	2.12.2.3
  +++ rpm/rpmio/rpmruby.c	19 Sep 2010 03:32:05 -0000	2.12.2.4
  @@ -29,6 +29,7 @@
   
   /*@unchecked@*/
   int _rpmruby_debug = 0;
  +#define RUBYDBG(_l) if (_rpmruby_debug) fprintf _l
   
   /*@unchecked@*/ /*@relnull@*/
   rpmruby _rpmrubyI = NULL;
  @@ -77,30 +78,40 @@
   {
       if (_rpmrubyI == NULL)
   	_rpmrubyI = rpmrubyNew(NULL, 0);
  +RUBYDBG((stderr, "<-- %s() I %p\n", __FUNCTION__, _rpmrubyI));
       return _rpmrubyI;
   }
   
   rpmruby rpmrubyNew(char ** av, uint32_t flags)
   {
  -    rpmruby ruby =
  -#ifdef	NOTYET
  -	(flags & 0x80000000) ? rpmrubyI() :
  -#endif
  -	rpmrubyGetPool(_rpmrubyPool);
  -
       static char * _av[] = { "rpmruby", NULL };
  +    rpmruby ruby = (flags & 0x80000000)
  +		? rpmrubyI() : rpmrubyGetPool(_rpmrubyPool);
  +
  +RUBYDBG((stderr, "--> %s(%p,0x%x) ruby %p\n", __FUNCTION__, av, flags, ruby));
  +
  +    /* If failure, or retrieving already initialized _rpmrubyI, just exit. */
  +    if (ruby == NULL || ruby == _rpmrubyI)
  +	goto exit;
   
       if (av == NULL) av = _av;
   
   #if defined(WITH_RUBYEMBED)
  +    RUBY_INIT_STACK;
       ruby_init();
       ruby_init_loadpath();
  +
       ruby_script((char *)av[0]);
  -    ruby_set_argv(argvCount((ARGV_t)av)-1, av+1);
  +    if (av[1])
  +	ruby_set_argv(argvCount((ARGV_t)av)-1, av+1);
  +
       rb_gv_set("$result", rb_str_new2(""));
  +#ifdef	NOTYET
       (void) rpmrubyRun(ruby, rpmrubyInitStringIO, NULL);
   #endif
  +#endif	/* WITH_RUBYEMBED */
   
  +exit:
       return rpmrubyLink(ruby);
   }
   
  @@ -108,20 +119,27 @@
   {
       rpmRC rc = RPMRC_FAIL;
   
  -if (_rpmruby_debug)
  -fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, ruby, fn);
  +RUBYDBG((stderr, "--> %s(%p,%s,%p)\n", __FUNCTION__, ruby, fn, resultp));
   
       if (ruby == NULL) ruby = rpmrubyI();
   
  -    if (fn != NULL) {
  +    if (fn == NULL)
  +	goto exit;
  +
   #if defined(WITH_RUBYEMBED)
  -	rb_load_file(fn);
  -	ruby->state = ruby_exec();
  -	if (resultp != NULL)
  -	    *resultp = RSTRING_PTR(rb_gv_get("$result"));
  -	rc = RPMRC_OK;
  -#endif
  -    }
  +#ifdef	DYING
  +    rb_load_file(fn);
  +    ruby->state = ruby_exec();
  +#else	/* DYING */
  +    ruby->state = ruby_exec_node(rb_load_file(fn));
  +#endif	/* DYING */
  +    if (resultp != NULL)
  +	*resultp = RSTRING_PTR(rb_gv_get("$result"));
  +    rc = RPMRC_OK;
  +#endif	/* WITH_RUBYEMBED */
  +
  +exit:
  +RUBYDBG((stderr, "<-- %s(%p,%s,%p) rc %d\n", __FUNCTION__, ruby, fn, resultp, rc));
       return rc;
   }
   
  @@ -129,18 +147,21 @@
   {
       rpmRC rc = RPMRC_FAIL;
   
  -if (_rpmruby_debug)
  -fprintf(stderr, "==> %s(%p,%s,%p)\n", __FUNCTION__, ruby, str, resultp);
  +RUBYDBG((stderr, "--> %s(%p,%s,%p)\n", __FUNCTION__, ruby, str, resultp));
   
       if (ruby == NULL) ruby = rpmrubyI();
   
  -    if (str != NULL) {
  +    if (str == NULL)
  +	goto exit;
  +
   #if defined(WITH_RUBYEMBED)
  -	ruby->state = rb_eval_string(str);
  -	if (resultp != NULL)
  -	    *resultp = RSTRING_PTR(rb_gv_get("$result"));
  -	rc = RPMRC_OK;
  +    ruby->state = rb_eval_string(str);
  +    if (resultp != NULL)
  +	*resultp = RSTRING_PTR(rb_gv_get("$result"));
  +    rc = RPMRC_OK;
   #endif
  -    }
  +
  +exit:
  +RUBYDBG((stderr, "<-- %s(%p,%s,%p) rc %d\n", __FUNCTION__, ruby, str, resultp, rc));
       return rc;
   }
  @@ .
Received on Sun Sep 19 05:32:05 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.