~ubuntu-branches/ubuntu/karmic/pdnsd/karmic

« back to all changes in this revision

Viewing changes to src/thread.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2006-10-12 08:18:52 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061012081852-k70ha1vynt2vu7mg
Tags: 1.2.4par-0.2
* Non-maintainer upload.
* Check for bind named pidfile in initscript and do not
  try to startup, otherwise pdnsd installation bails
  out if named is running on the same host (Closes: #389609)
* add --no-create-home to adduser call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* thread.c - Threading helpers
 
2
 
2
3
   Copyright (C) 2000 Thomas Moestl
3
 
 
4
 
   With modifications by Paul Rombouts, 2002, 2003.
 
4
   Copyright (C) 2002, 2003 Paul A. Rombouts
5
5
 
6
6
This file is part of the pdnsd package.
7
7
 
38
38
static char rcsid[]="$Id: thread.c,v 1.5 2001/05/19 14:57:30 tmm Exp $";
39
39
#endif
40
40
 
 
41
#if (TARGET==TARGET_LINUX) && !defined(THREADLIB_NPTL)
41
42
volatile short int waiting=0; /* Has the main thread already done sigwait() ? */
 
43
#endif
42
44
pthread_attr_t attr_detached;
 
45
#if DEBUG>0
43
46
pthread_key_t thrid_key;
 
47
#endif
44
48
 
45
49
/* This is a handler for signals to the threads. We just hand the sigs on to the main thread.
46
50
 * Note that this may result in blocked locks. We have no means to open the locks here, because in LinuxThreads
47
51
 * the mutex functions are not async-signal safe. So, locks may still be active. We account for this by using
48
52
 * softlocks (see below) in any functions called after sigwait from main(). */
49
 
#if TARGET==TARGET_LINUX && !defined(THREADLIB_NPTL)
 
53
#if (TARGET==TARGET_LINUX) && !defined(THREADLIB_NPTL)
50
54
void thread_sig(int sig)
51
55
{
52
56
        if (sig==SIGTSTP || sig==SIGTTOU || sig==SIGTTIN) {
57
61
                log_warn("Caught signal %i.",sig);
58
62
                if (sig==SIGSEGV || sig==SIGILL || sig==SIGBUS)
59
63
                        crash_msg("A fatal signal occured.");
60
 
                pthread_kill(main_thread,SIGTERM);
 
64
                pthread_kill(main_thrid,SIGTERM);
61
65
                pthread_exit(NULL);
62
66
        } else {
63
67
                crash_msg("An error occured at startup.");
66
70
}
67
71
#endif
68
72
 
69
 
/* void usleep_r(unsigned long usec)
 
73
/* This is now defined as an inline function in thread.h */
 
74
#if 0
 
75
void usleep_r(unsigned long usec)
70
76
{
71
 
#if (TARGET==TARGET_LINUX || TARGET==TARGET_BSD) && defined(HAVE_USLEEP)
 
77
#if ((TARGET==TARGET_LINUX) || (TARGET==TARGET_BSD) || (TARGET==TARGET_CYGWIN)) && defined(HAVE_USLEEP)
72
78
        usleep(usec);
73
79
#else
74
80
        struct timeval tv;
77
83
        tv.tv_usec=usec%1000000;
78
84
        select(0, NULL, NULL, NULL, tv);
79
85
#endif
80
 
} */
 
86
}
 
87
#endif
81
88