xref: /titanic_50/usr/src/cmd/svc/startd/protocol.h (revision edb432dd16be68a2fea50d9a0a1e839f16c6bc65)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_PROTOCOL_H
26 #define	_PROTOCOL_H
27 
28 #include <startd.h>
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 typedef enum {
35 	GRAPH_UPDATE_RELOAD_GRAPH,
36 	GRAPH_UPDATE_ADD_INSTANCE,
37 	GRAPH_UPDATE_STATE_CHANGE
38 } graph_event_type_t;
39 
40 typedef struct protocol_states {
41 	restarter_instance_state_t	ps_state;
42 	restarter_instance_state_t	ps_state_next;
43 	restarter_error_t		ps_err;
44 	restarter_str_t			ps_reason;
45 } protocol_states_t;
46 
47 
48 typedef struct graph_protocol_event {
49 	char			*gpe_inst;
50 	size_t			gpe_inst_sz;
51 	graph_event_type_t	gpe_type;
52 	protocol_states_t	*gpe_data;
53 
54 	uu_list_node_t		gpe_link;
55 	pthread_mutex_t		gpe_lock;
56 } graph_protocol_event_t;
57 
58 typedef struct graph_update {
59 	pthread_mutex_t			gu_lock;
60 	pthread_cond_t			gu_cv;
61 	int				gu_wakeup;
62 
63 	pthread_mutex_t			gu_freeze_lock;
64 	pthread_cond_t			gu_freeze_cv;
65 	int				gu_freeze_wakeup;
66 } graph_update_t;
67 
68 typedef struct restarter_protocol_event {
69 	char			*rpe_inst;
70 	restarter_event_type_t	rpe_type;
71 	int32_t			rpe_reason;
72 
73 	uu_list_node_t		rpe_link;
74 } restarter_protocol_event_t;
75 
76 typedef struct restarter_update {
77 	pthread_mutex_t			restarter_update_lock;
78 	pthread_cond_t			restarter_update_cv;
79 	int				restarter_update_wakeup;
80 } restarter_update_t;
81 
82 extern restarter_update_t *ru;
83 extern graph_update_t *gu;
84 
85 void graph_protocol_init();
86 void graph_protocol_send_event(const char *, graph_event_type_t,
87     protocol_states_t *);
88 graph_protocol_event_t *graph_event_dequeue();
89 void graph_event_requeue(graph_protocol_event_t *);
90 void graph_event_release(graph_protocol_event_t *);
91 
92 void restarter_protocol_init();
93 evchan_t *restarter_protocol_init_delegate(char *);
94 void restarter_protocol_send_event(const char *, evchan_t *,
95     restarter_event_type_t, int32_t);
96 restarter_protocol_event_t *restarter_event_dequeue();
97 void restarter_event_requeue(restarter_protocol_event_t *);
98 void restarter_event_release(restarter_protocol_event_t *);
99 
100 #ifdef	__cplusplus
101 }
102 #endif
103 
104 #endif	/* _PROTOCOL_H */
105