~jamesodhunt/upstart/file-bridge-MP

« back to all changes in this revision

Viewing changes to init/quiesce.h

  • Committer: James Hunt
  • Date: 2013-02-25 09:28:24 UTC
  • mfrom: (1427.3.4 upstart-shutdown)
  • Revision ID: james.hunt@ubuntu.com-20130225092824-o1ju9qoryd53fijv
* Merge of lp:~jamesodhunt/upstart/upstart-shutdown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* upstart
 
2
 *
 
3
 * Copyright © 2013 Canonical Ltd.
 
4
 * Author: James Hunt <james.hunt@canonical.com>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License version 2, as
 
8
 * published by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
18
 */
 
19
 
 
20
#ifndef INIT_QUIESCE_H
 
21
#define INIT_QUIESCE_H
 
22
 
 
23
#include <nih/timer.h>
 
24
 
 
25
/**
 
26
 * QUIESCE_DEFAULT_JOB_RUNTIME:
 
27
 *
 
28
 * The default maximum length of time to wait after emitting the
 
29
 * SESSION_END_EVENT event before stopping all jobs.
 
30
 **/
 
31
#define QUIESCE_DEFAULT_JOB_RUNTIME 5
 
32
 
 
33
/**
 
34
 * QuiesceRequester:
 
35
 *
 
36
 * Reason for Session Init wishing to shutdown; either the Session Init
 
37
 * has been notified the system is being shutdown, or the session has
 
38
 * requested it be ended (for example due to a user logout request).
 
39
 **/
 
40
typedef enum quiesce_requester {
 
41
        QUIESCE_REQUESTER_INVALID = -1,
 
42
        QUIESCE_REQUESTER_SYSTEM = 0,
 
43
        QUIESCE_REQUESTER_SESSION,
 
44
} QuiesceRequester;
 
45
 
 
46
/**
 
47
 * QuiescePhase:
 
48
 *
 
49
 * Phase 0: No quiesce operation in progress.
 
50
 *
 
51
 * Phase 1: Wait: Period between SESSION_END_EVENT being emitted and
 
52
 *          QUIESCE_DEFAULT_JOB_RUNTIME being reached.
 
53
 *
 
54
 * Phase 2: Kill: Period between QUIESCE_DEFAULT_JOB_RUNTIME being
 
55
 *          reached and kill signal being sent to all jobs.
 
56
 *
 
57
 * Phase 3: Cleanup: Period between all jobs having ended
 
58
 *          (either naturally or by induction) and final exit.
 
59
 **/
 
60
typedef enum quiesce_phase {
 
61
        QUIESCE_PHASE_NOT_QUIESCED,
 
62
        QUIESCE_PHASE_WAIT,
 
63
        QUIESCE_PHASE_KILL,
 
64
        QUIESCE_PHASE_CLEANUP,
 
65
} QuiescePhase;
 
66
 
 
67
NIH_BEGIN_EXTERN
 
68
 
 
69
void    quiesce                (QuiesceRequester requester);
 
70
void    quiesce_wait_callback  (void *data, NihTimer *timer);
 
71
void    quiesce_show_slow_jobs (void);
 
72
void    quiesce_finalise       (void);
 
73
 
 
74
NIH_END_EXTERN
 
75
 
 
76
#endif /* INIT_QUIESCE_H */