igraph-help
[Top][All Lists]
Advanced

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

[igraph] Multithreading and GraphML


From: Chris Wj
Subject: [igraph] Multithreading and GraphML
Date: Tue, 18 Aug 2009 17:19:49 -0400

Hi all, this is just a FYI for anyone working with igraph and doing multithreading. I fixed a bug where igraph crashes in multithreaded apps using libxml2 by adding the following line to 'foreign-graphml.c', line 997 in 'igraph_read_graph_graphml' after the variable declarations.
 
xmlInitParser();

From http://xmlsoft.org/threads.html:
call xmlInitParser() in the "main" thread before using any of the libxml2 API

While  'igraph_read_graph_graphml' may be called multiple times, I checked the 'xmlInitParser' function to find this source:
void
xmlInitParser(void) {
    if (xmlParserInitialized != 0)
    return;
 #ifdef LIBXML_THREAD_ENABLED
    __xmlGlobalInitMutexLock();
    if (xmlParserInitialized == 0) {
...
 
Where it a) locks on __xmlGlobalInitMutexLock(); and b) subsequently sets xmlParserInitialized to 1, so calling it multiple times doesn't really hurt (I am fairly sure of this and will report back if otherwise).

This bug manifested itself using the Python library and Python threads, which are pthreads after all.

-Chris

reply via email to

[Prev in Thread] Current Thread [Next in Thread]