Re: Crash when using libsoup-gnome from multiple threads



On 06/18/2009 06:36 AM, Ross Burton wrote:
> Hi,
> 
> I have a test which spawns multiple threads, one for a server and then
> many clients, and makes requests from the clients to the server on
> localhost.  If I run this with libsoup 2.26.2 without GNOME integrate it
> works fine, but if I enable GNOME integration it occasionally crashes:

> If anyone wants to replicate this, then the code is in
> git://git.moblin.org/librest.  You'll need the ross/threaded branch, and
> the test case is tests/threaded.

Bug in the test case. :)

The problem is that you're running the server in a thread, which causes
the default main loop to be run in that thread, which causes all ORBit
I/O to be run in that thread. This would be fine *except* that you never
stop the server thread, and ORBit registers an atexit() handler, which
will get run in the main thread, and so when the program exits, it may
end up performing ORBit ops in two threads at once, which ORBit isn't
set up to deal with. So you need to rewrite it to either exit the server
thread before exiting main(), or else run the server from the main
thread. (Or else run the server with its own GMainContext, which will
mean no one is running the default main loop, and so the initial gconf
stuff will just happen in whatever thread calls it first, and then there
won't be any updates to it after that, which isn't really a problem in a
program like this.)

-- Dan

PS - also, you should say "127.0.0.1", not "localhost", in the URL,
because SoupServer only listens on IPv4 (by default), but "localhost"
may resolve to ::1 instead, causing the test to fail for the wrong reason.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]