mogilefs.py threading coredump patch

17 views
Skip to first unread message

Justin Mason

unread,
Oct 16, 2008, 11:22:37 AM10/16/08
to mogile, ja6...@albany.edu
Hi all --

The Python mogilefs.py class at http://www.albany.edu/~ja6447/mogilefs.py
has an issue -- when called from threaded code on Linux, it'll
intermittently dump core due to unhandled, stray SIGALRM signals.

This thread notes the fix:
http://python-forum.org/pythonforum/viewtopic.php?f=5&t=9395 .
pycurl needs the NOSIGNAL option to operate thread-safely.

http://curl.haxx.se/mail/lib-2002-12/0103.html notes that NOSIGNAL
is required to abort slow DNS name resolution. Is it safe to
assume that mogstored nodes' names will always resolve speedily?
fwiw, I would guess so, and it's better than coredumping, but ymmv ;)

patch for mogilefs.py is below. cheers,

--j.

--- ../external/linux/zips/mogilefs.2007-09-05.py 2008-09-25
15:46:07.000000000 +0000
+++ mogilefs.new.py 2008-10-16 13:13:46.000000000 +0000
@@ -668,6 +668,11 @@
curl.setopt(pycurl.LOW_SPEED_TIME, 5)
curl.setopt(pycurl.LOW_SPEED_LIMIT, 1)
curl.setopt(pycurl.WRITEFUNCTION, ofp.write)
+
+ # Oct 16 2008 jm: avoid segfaults when
multithreaded, see
+ # http://python-forum.org/pythonforum/viewtopic.php?f=5&t=9395
+ curl.setopt(pycurl.NOSIGNAL, 1)
+
curl.perform()
curl.close()
if fp is None:

Paul Baker™

unread,
Oct 16, 2008, 12:37:32 PM10/16/08
to mog...@googlegroups.com, ja6...@albany.edu
The recommended practice is to use IPs for nodenames instead of hostnames, so dns shouldn't be an issue at all, if you are following best practice.

Justin Mason

unread,
Oct 17, 2008, 4:51:19 AM10/17/08
to mogile
Sounds reasonable. ;)

(PS: slight typo in the original mail. where I said 'NOSIGNAL is
required to abort slow DNS name resolution', I got that backwards --
it's 'NOSIGNAL=0', ie. the use of SIGALRM, is required to timeout DNS
lookups.)

--j.

On Oct 16, 5:37 pm, "Paul Baker™" <bak...@google.com> wrote:
> The recommended practice is to use IPs for nodenames instead of hostnames,
> so dns shouldn't be an issue at all, if you are following best practice.
>
> On Thu, Oct 16, 2008 at 10:22 AM, Justin Mason <jma...@gmail.com> wrote:
>
> > Hi all --
>
> > The Python mogilefs.py class athttp://www.albany.edu/~ja6447/mogilefs.py
> > has an issue -- when called from threaded code on Linux, it'll
> > intermittently dump core due to unhandled, stray SIGALRM signals.
>
> > This thread notes the fix:
> >http://python-forum.org/pythonforum/viewtopic.php?f=5&t=9395.
> > pycurl needs the NOSIGNAL option to operate thread-safely.
>
> >http://curl.haxx.se/mail/lib-2002-12/0103.htmlnotes that NOSIGNAL
Reply all
Reply to author
Forward
0 new messages