linux threads support
This commit is contained in:
@@ -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
|
||||
|
||||
+7
-2
@@ -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
|
||||
|
||||
+32
-5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user