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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/* upstart
*
* Copyright © 2010 Canonical Ltd.
* Author: Scott James Remnant <scott@netsplit.com>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef INIT_EVENT_H
#define INIT_EVENT_H
#include <nih/macros.h>
#include <nih/list.h>
#include "session.h"
#include "state.h"
#include <json.h>
/**
* EventProgress:
*
* This is used to record the progress of an event, starting at
* being pending, then being handled and finally waiting for the callback
* to be called and any cleanup performed.
**/
typedef enum event_progress {
EVENT_PENDING,
EVENT_HANDLING,
EVENT_FINISHED
} EventProgress;
/**
* Event:
* @entry: list header,
* @session: session the event is attached to,
* @name: string name of the event,
* @env: NULL-terminated array of environment variables,
* @fd: open file descriptor associated with a particular
* socket-bridge socket (see socket-event(8)),
* @progress: progress of event,
* @failed: whether this event has failed,
* @blockers: number of blockers for finishing,
* @blocking: messages and jobs we're blocking.
*
* Events are one of the core concepts of upstart; they occur whenever
* something, somewhere changes state. They are idenitied by a unique
* @name string, and can carry further information in the form of @env
* which are passed to any jobs whose goal is changed by this event.
*
* This structure holds all the information on an active event, including
* the information contained within the event and the current progress of
* that event through the queue.
*
* Events remain in the handling state while @blockers is non-zero.
**/
typedef struct event {
NihList entry;
Session * session;
char *name;
char **env;
int fd;
EventProgress progress;
int failed;
unsigned int blockers;
NihList blocking;
} Event;
NIH_BEGIN_EXTERN
extern int paused;
extern NihList *events;
void event_init (void);
Event *event_new (const void *parent, const char *name, char **env);
void event_block (Event *event);
void event_unblock (Event *event);
void event_poll (void);
json_object *event_serialise (const Event *event)
__attribute__ ((warn_unused_result));
Event *event_deserialise (json_object *json)
__attribute__ ((warn_unused_result));
json_object * event_serialise_all (void)
__attribute__ ((warn_unused_result));
int event_deserialise_all (json_object *json)
__attribute__ ((warn_unused_result));
int event_to_index (const Event *event)
__attribute__ ((warn_unused_result));
Event * event_from_index (int event_index)
__attribute__ ((warn_unused_result));
NIH_END_EXTERN
#endif /* INIT_EVENT_H */
|