Commit a829555e authored by Bob Halley's avatar Bob Halley

linux threads support

parent afe7967b
......@@ -41,3 +41,6 @@
/* define on Solaris to get sigwait() to work using pthreads semantics */
#undef _POSIX_PTHREAD_SEMANTICS
/* define if LinuxThreads is in use */
#undef HAVE_LINUXTHREADS
......@@ -13,7 +13,7 @@ dnl PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dnl ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
dnl SOFTWARE.
AC_REVISION($Revision: 1.24 $)
AC_REVISION($Revision: 1.25 $)
AC_PREREQ(2.12)
......@@ -155,13 +155,18 @@ case "$host" in
;;
esac
dnl
dnl BSDI 3.1 needs pthread_init() to be called before certain pthreads
dnl calls.
dnl calls. LinuxThreads requires some changes to the way we deal with
dnl signals.
dnl
case "$host" in
*-bsdi3.1*)
AC_DEFINE(NEED_PTHREAD_INIT)
;;
*-linux*)
AC_DEFINE(HAVE_LINUXTHREADS)
;;
esac
dnl
......
......@@ -28,6 +28,7 @@
#include <signal.h>
#include <isc/app.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/task.h>
#include <isc/event.h>
......@@ -40,6 +41,10 @@ static isc_eventlist_t on_run;
static isc_mutex_t lock;
static isc_boolean_t shutdown_requested = ISC_FALSE;
#ifdef HAVE_LINUXTHREADS
static pthread_t main_thread;
#endif
#ifndef HAVE_SIGWAIT
static void
empty_action(int arg) {
......@@ -73,6 +78,10 @@ isc_app_start(void) {
}
#endif
#ifdef HAVE_LINUXTHREADS
main_thread = pthread_self();
#endif
result = isc_mutex_init(&lock);
if (result != ISC_R_SUCCESS)
return (result);
......@@ -147,6 +156,10 @@ isc_app_run(void) {
* Run an ISC library application.
*/
#ifdef HAVE_LINUXTHREADS
REQUIRE(main_thread == pthread_self());
#endif
#if 0
/*
* Post any on-run events (in LIFO order).
......@@ -210,11 +223,25 @@ isc_app_shutdown(void) {
UNLOCK(&lock);
if (want_kill && kill(getpid(), SIGTERM) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_shutdown() kill: %s",
strerror(errno));
return (ISC_R_UNEXPECTED);
if (want_kill) {
#ifdef HAVE_LINUXTHREADS
int result;
result = pthread_kill(main_thread, SIGTERM);
if (result != 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_shutdown() pthread_kill: %s",
strerror(result));
return (ISC_R_UNEXPECTED);
}
#else
if (kill(getpid(), SIGTERM) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_shutdown() kill: %s",
strerror(errno));
return (ISC_R_UNEXPECTED);
}
#endif
}
return (ISC_R_SUCCESS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment