Re: GIO will link with -pthread soon

On Fri, Nov 20, 2009 at 11:27 AM, Tor Lillqvist <tml iki fi> wrote:
>> We really need to get our story together here. Either we do our very
>> best to handle late g_thread_init(), or we should fail spectactularly.
> Agree 100%.
> My own humble opinion is that even GLib (not just GIO) should link to
> -lpthread and work as if g_thread_init(NULL) would have been
> implicitly called before any other GLib calls.
> g_threads_got_initialized would be TRUE always. But I certainly admit
> I don't understand all the implications of this, and implementation
> details it would require, especially on Linux. (On Windows, ~all code
> compiled by modern C compilers, certainly including the GTK+ stack,
> use a multi-thread-aware C library always anyway, which corresponds
> more or less to linking with -lpthread on Linux, I think.)
>> I guess orbit needing this is the main reason why we can't just make it fail?
> I attempted last year to make ORBit2 *not* call g_thread_init()
> itself, "as it is usually too late", but had to revert it. See bug
> #547885 .

   Personally I strongly feel that we should make g_thread_init() fail when
called late at the risk of crashing/locking another initialized thread
aware library.

While its possible to teach these libraries to do some really complex stuff,
I think fixing the thread aware libraries up to support late thread
misses the mark in as much as it sends a message to software developers
that they should support late thread initialization when writing a library.

I'm quite convinced this is only a situation we've put ourselves in by writing
modules that initialized threads late in the game (sure we were young and
didnt know anything about threads ;-D), I'm a little scared that the complex
fix for this internally - will inevitably become the standard implementation
externally, which IMO is more scary than the bug itself; we should encourage
people to get it right the first time instead.


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