[XML-SIG] Advice on how to deal with locking problems using python-wrapped C libs in MT frameworks like Zope/Twisted?

Daniel Veillard veillard@redhat.com
Sun, 30 Mar 2003 16:29:47 -0500


On Sun, Mar 30, 2003 at 03:53:10PM -0500, Craeg K Strong wrote:
> sin_addr=inet_addr("127.0.0.1")}}, 16) = -1 EINPROGRESS (Operation now 
> in progress)
> select(12, NULL, [11], NULL, {60, 0})   = 1 (out [11], left {60, 0})
> getsockopt(11, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
> send(11, "GET /testFolder_1_/arielpartners"..., 88, 0) = 88
> brk(0)                                  = 0x8b4d000
> brk(0x8b5d000)                          = 0x8b5d000
> recv(11, 0x8b4cfd8, 4096, 0)            = -1 EAGAIN (Resource 
> temporarily unavailable)
> select(12, [11], NULL, NULL, {60, 0})   = 0 (Timeout)       
> <================  LENGTHY TIMEOUT HAPPENS HERE
> recv(11, 0x8b4cfd8, 4096, 0)            = -1 EAGAIN (Resource 
> temporarily unavailable)
> select(12, [11], NULL, NULL, {60, 0})   = 0 (Timeout)       
> <================ AND AGAIN HERE
> kill(12063, SIGRTMIN)                   = 0
> rt_sigprocmask(SIG_SETMASK, NULL, [RTMIN], 8) = 0
> rt_sigsuspend([] <unfinished ...>
> --- SIGRTMIN (Unknown signal 32) ---
> <... rt_sigsuspend resumed> )           = -1 EINTR (Interrupted system call)
> sigreturn()                             = ? (mask now [RTMIN])
> close(11)                               = 0
> kill(12063, SIGRTMIN)                   = 0
> write(2, "^\n\n", 3^
> 
> )                    = 3
> write(2, "FAIL", 4FAIL) 
> 
> .... lots of messages follow to print out the errors
> 
> When libxslt tries to resolve the relative URL, a request is going out 
> to grab:
> 
> http://127.0.0.1:55068/testFolder_1_/arielpartners/propfolder/foo/properties
> 
> which ends up coming back in to Zope.  Zope is multi-threaded, so why
> shouldn't that be able to return successfully?  Is libxslt-python somehow
> holding on to the GIL or-- maybe it is still in the middle of the "read"
> call and is therefore holding a lock on that resource?

  Hum, libxslt does a direct recv() on the socket then a select wait
if data is not available. Theorically another thread should be able to make
the read() process and write back unlocking the select with data to read.
  However, why go through the OS and suffer such synchronization and threading
overhead. Simply install a resolver for libxml2/libxslt and when an
http resource to the local host and port is required provide the data
directly and return the file or the resulting string. See 
   python/tests/resolver.py
in libxml2 source or docs to see how to install a resolver.

Daniel


-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/