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