summaryrefslogtreecommitdiff
path: root/pod/perlipc.pod
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-11-22 19:18:49 +0000
committerDavid Mitchell <davem@iabyn.com>2010-11-26 16:01:34 +0000
commitabf9167d3fff002ddaed53abb44d638387bca978 (patch)
treef81a5b1c720adff647b3866f0a7b7890b444534b /pod/perlipc.pod
parentcc6623a84b782d30463b9046c2916f35064a7e3f (diff)
downloadperl-abf9167d3fff002ddaed53abb44d638387bca978.tar.gz
Make PerlIO marginally reentrant
Currently if an operation on a file handle is interrupted, and if the signal handler accesses that same file handle (e.g. closes it), then perl will crash. See [perl #75556]. This commit provides some basic infrastructure to avoid segfaults. Basically it adds a lock count field to each handle (by re-purposing the unused flags field in the PL_perlio array), then each time a signal handler is called, the count is incremented. Then various parts of PerlIO use a positive count to change behaviour. Most importantly, when layers are popped, the PerlIOl structure is cleared, but not freed, and is left in the chain of layers. This means that callers still holding pointers to the various layers won't access freed structures. It does however mean that PerlIOl structs may be leaked, and possibly slots in PL_perlio. But this is better than crashing. Not much has been done to give sensible behaviour on re-entrancy; for example, a buffer that has already been written once might get written again. Fixing this sort of thing would require a large-scale audit of perlio.c.
Diffstat (limited to 'pod/perlipc.pod')
-rw-r--r--pod/perlipc.pod6
1 files changed, 6 insertions, 0 deletions
diff --git a/pod/perlipc.pod b/pod/perlipc.pod
index 8aa500584c..5e9f408a62 100644
--- a/pod/perlipc.pod
+++ b/pod/perlipc.pod
@@ -408,6 +408,12 @@ operation.)
The default in Perl 5.7.3 and later is to automatically use
the C<:perlio> layer.
+Note that it is not advisable to access a file handle within a signal
+handler where that signal has interrupted an I/O operation on that same
+handle. While perl will at least try hard not to crash, there are no
+guarantees of data integrity; for example, some data might get dropped or
+written twice.
+
Some networking library functions like gethostbyname() are known to have
their own implementations of timeouts which may conflict with your
timeouts. If you have problems with such functions, try using the POSIX