start page | rating of books | rating of authors | reviews | copyrights

Book HomeProgramming the Perl DBISearch this book

A.8. Further Information

A.8.1. Threads and Thread Safety

Perl versions 5.004_50 and later include optional experimental support for multiple threads on many platforms. If the DBI is built using a Perl that has threads enabled, then it will use a per-driver mutex to ensure that only one thread is with a driver at any one time. Please note that support for threads in Perl is still experimental and is known to have some significant problems. Its use is not recommended.

A.8.2. Signal Handling and Canceling Operations

The first thing to say is that signal handling in Perl is currently not safe. There is always a small risk of Perl crashing and/or core dumping during or after handling a signal. (The risk was reduced with 5.004_04 but is still present.)

The two most common uses of signals in relation to the DBI are for canceling operations when the user types Ctrl-C (interrupt), and for implementing a timeout using alarm() and $SIG{ALRM}.

To assist in implementing these operations, the DBI provides a cancel method for statement handles. The cancel method should abort the current operation and is designed to be called from a signal handler.

However, it must be stressed that: a) few drivers implement this functionality at the moment (the DBI provides a default method that just returns undef); and b) even if implemented, there is still a possibility that the statement handle, and possibly the parent database handle, will not be usable afterwards.

If cancel returns true, then it has successfully invoked the database engine's own cancel function. If it returns false, then cancel failed. If it returns undef, then the database engine does not have cancel implemented.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.