File: Signal_Task.cpp

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (83 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// $Id: Signal_Task.cpp 80826 2008-03-04 14:51:23Z wotte $

#include "ace/OS_NS_signal.h"
#include "ace/OS_NS_Thread.h"
#include "ace/Thread.h"

#ifndef JAWS_BUILD_DLL
#define JAWS_BUILD_DLL
#endif

#include "jaws3/Signal_Task.h"
#include "jaws3/Event_Dispatcher.h"
#include "jaws3/THYBRID_Concurrency.h"
#include "jaws3/TPOOL_Concurrency.h"
#include "jaws3/TPR_Concurrency.h"


ACE_THR_FUNC_RETURN
JAWS_Signal_Task_function (void *)
{
  int done = 0;

  while (! done)
    {
      int signo = ACE_OS::sigwait (JAWS_Signal_Task::instance ()->sigset ());

      switch (signo)
        {
        case SIGINT:
        case SIGTERM:

           JAWS_Concurrency::instance ()->shutdown ();
           JAWS_Event_Dispatcher::end_event_loop ();

           done = 1;

          break;
# if !defined (ACE_WIN32)
        case SIGHUP:
          // In the future, re-read jaws.conf and svc.conf,
          // and then reset the JAWS singletons.
          // For now, just ignore it.
          break;

        case SIGPIPE:
#endif // !defined (ACE_WIN32)
        default:
          break;

        }

    }

  return 0;
}


JAWS_Signal_Task::JAWS_Signal_Task (void)
{
  // Set our signal mask.
  this->sigset_.empty_set ();

  this->sigset_.sig_add (SIGINT);
  this->sigset_.sig_add (SIGTERM);
  this->sigset_.sig_add (SIGPIPE);

#if 0
  this->sigset_.fill_set ();
#endif

  ACE_OS::sigprocmask (SIG_BLOCK, this->sigset_, 0);

  int result;
  result = ACE_Thread::spawn ( JAWS_Signal_Task_function
                             , 0
                             , THR_BOUND
                             );
  if (result < 0)
    {
      ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn"));
      return;
    }
}