Re: Crash when using libsoup-gnome from multiple threads



On Thu, 2009-06-18 at 08:27 -0400, Dan Winship wrote:
> > 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. :)

Well that makes it easier to fix!

> 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.)

Okay, I've just added soup_server_quit(server) after I've joined all of
the client threads, and the test certainly runs for longer now.

> 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.

Good point, fixed.

Thanks,
Ross
-- 
Ross Burton                                 mail: ross burtonini com
                                          jabber: ross burtonini com
                                           www: http://burtonini.com

Attachment: signature.asc
Description: This is a digitally signed message part



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