>>>>> "S" == Sean O'Dell <sean / celsoft.com> writes:

S> I believe, at least under Windows, that rb_protect didn't protect me 
S> quite as well as I needed (I still got longjmp'd past), so I abandonded 
S> C++ entirely.

 With C++, never try to mix 'try {} catch {}' with rb_protect() even with C
 be carefull. For example, look at plruby to see how it made the call to
 rb_protect() with a setjmp()/longjmp() need by postgres

static VALUE
pl_protect(plth)
    struct pl_thread_st *plth;
{
    Datum retval;
    VALUE result;

    if (sigsetjmp(Warn_restart, 1) != 0) {
	return pl_eCatch;
    }
/* ... */
}


static VALUE
pl_real_handler(struct pl_thread_st *plth)
{
    VALUE result;
    int state;
/* ... */
    state = 0;
    pl_call_level++;
    result = rb_protect(pl_protect, (VALUE)plth, &state);
    pl_call_level--;
/* ... */
}


 the order is really important : after this I can safely use rb_raise() in
 plruby and I can catch the error given by postgres (when it use longjmp())



Guy Decoux