Re: Using roadrunner in unthreaded apps

Jonas Borgström <[email protected]> 02 May 2003 12:49:19 +0200
Newsgroups gmane.network.beep.roadrunner.general
Organization CodeFactory AB
Message-ID <1051872558.943.86.camel@blinky>
On Thu, 2003-05-01 at 14:10, Sandro Poppi wrote:
> Hi all,

Hi,

> I'm currently trying to incorporate our roadrunner based profile
> (RRTLSIDXP) into the snort idmef plugin (for those who don't know snort:
> It's a great Open Source Intrusion Detection System). Snort is
> unthreaded.
> 
> Whenever rr_init is called 2 new threads are created (although
> rr_get_max_work_threads reports 1) and after 2 or 3 times of running
> snort against our test server the tls handshake doesn't happen anymore,
> processes seem to hang what I suppose is based on a deadlock within the
> threads.
> 
if you call rr_init when max_work_threads is set to 1, only one "work"
thread will be started. RoadRunner will also start one thread which will
run the GLib event loop. So at least two thread will always be started
when calling rr_init (some OS:s like Linux will also start a pthread
"maintenance" thread on the first pthread_create call).

> Doing the same with snort running in a debugger (ddd which is a GUI for
> gdb) doesn't cause any trouble.
> 
This is probably because gdb will slow things down so it is harder to
hit some race condition, the problem is probably still there.

> Is there a chance to disable roadrunner threads, or to make rodrunner
> run in conjunction with non-threaded apps and if yes how is this
> achieved?

It isn't possible to run RoadRunner in a "non-threaded" mode but it _is_
definitely possible to make it run in conjunction with non-threaded
apps.

Without looking at your code I can only give you a general answer:
The non thread safe functions/resources have to be protected by a mutex.

/* Create a mutex somewhere */
snort_mutex = g_mutex_new ();
...
/* claim the mutex */
g_mutex_lock (snort_mutex);
...
*** call some snort functions ***
...
/* unlock the mutex when done */
g_mutex_unlock (snort_mutex);


/ Jonas
-- 
Jonas Borgström                  [email protected]
CodeFactory AB                   http://www.codefactory.se/
Office: +46 (0)90 71 86 14