xref: /titanic_50/usr/src/cmd/svc/startd/protocol.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*f6e214c7SGavin Maltby  * Common Development and Distribution License (the "License").
6*f6e214c7SGavin Maltby  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*f6e214c7SGavin Maltby  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_PROTOCOL_H
267c478bd9Sstevel@tonic-gate #define	_PROTOCOL_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <startd.h>
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate typedef enum {
357c478bd9Sstevel@tonic-gate 	GRAPH_UPDATE_RELOAD_GRAPH,
367c478bd9Sstevel@tonic-gate 	GRAPH_UPDATE_ADD_INSTANCE,
377c478bd9Sstevel@tonic-gate 	GRAPH_UPDATE_STATE_CHANGE
387c478bd9Sstevel@tonic-gate } graph_event_type_t;
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate typedef struct protocol_states {
417c478bd9Sstevel@tonic-gate 	restarter_instance_state_t	ps_state;
427c478bd9Sstevel@tonic-gate 	restarter_instance_state_t	ps_state_next;
437c478bd9Sstevel@tonic-gate 	restarter_error_t		ps_err;
44*f6e214c7SGavin Maltby 	restarter_str_t			ps_reason;
457c478bd9Sstevel@tonic-gate } protocol_states_t;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate typedef struct graph_protocol_event {
497c478bd9Sstevel@tonic-gate 	char			*gpe_inst;
507c478bd9Sstevel@tonic-gate 	size_t			gpe_inst_sz;
517c478bd9Sstevel@tonic-gate 	graph_event_type_t	gpe_type;
527c478bd9Sstevel@tonic-gate 	protocol_states_t	*gpe_data;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 	uu_list_node_t		gpe_link;
557c478bd9Sstevel@tonic-gate 	pthread_mutex_t		gpe_lock;
567c478bd9Sstevel@tonic-gate } graph_protocol_event_t;
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef struct graph_update {
597c478bd9Sstevel@tonic-gate 	pthread_mutex_t			gu_lock;
607c478bd9Sstevel@tonic-gate 	pthread_cond_t			gu_cv;
617c478bd9Sstevel@tonic-gate 	int				gu_wakeup;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 	pthread_mutex_t			gu_freeze_lock;
647c478bd9Sstevel@tonic-gate 	pthread_cond_t			gu_freeze_cv;
657c478bd9Sstevel@tonic-gate 	int				gu_freeze_wakeup;
667c478bd9Sstevel@tonic-gate } graph_update_t;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate typedef struct restarter_protocol_event {
697c478bd9Sstevel@tonic-gate 	char			*rpe_inst;
707c478bd9Sstevel@tonic-gate 	restarter_event_type_t	rpe_type;
71*f6e214c7SGavin Maltby 	int32_t			rpe_reason;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate 	uu_list_node_t		rpe_link;
747c478bd9Sstevel@tonic-gate } restarter_protocol_event_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate typedef struct restarter_update {
777c478bd9Sstevel@tonic-gate 	pthread_mutex_t			restarter_update_lock;
787c478bd9Sstevel@tonic-gate 	pthread_cond_t			restarter_update_cv;
797c478bd9Sstevel@tonic-gate 	int				restarter_update_wakeup;
807c478bd9Sstevel@tonic-gate } restarter_update_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate extern restarter_update_t *ru;
837c478bd9Sstevel@tonic-gate extern graph_update_t *gu;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate void graph_protocol_init();
867c478bd9Sstevel@tonic-gate void graph_protocol_send_event(const char *, graph_event_type_t,
877c478bd9Sstevel@tonic-gate     protocol_states_t *);
887c478bd9Sstevel@tonic-gate graph_protocol_event_t *graph_event_dequeue();
897c478bd9Sstevel@tonic-gate void graph_event_requeue(graph_protocol_event_t *);
907c478bd9Sstevel@tonic-gate void graph_event_release(graph_protocol_event_t *);
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate void restarter_protocol_init();
937c478bd9Sstevel@tonic-gate evchan_t *restarter_protocol_init_delegate(char *);
947c478bd9Sstevel@tonic-gate void restarter_protocol_send_event(const char *, evchan_t *,
95*f6e214c7SGavin Maltby     restarter_event_type_t, int32_t);
967c478bd9Sstevel@tonic-gate restarter_protocol_event_t *restarter_event_dequeue();
977c478bd9Sstevel@tonic-gate void restarter_event_requeue(restarter_protocol_event_t *);
987c478bd9Sstevel@tonic-gate void restarter_event_release(restarter_protocol_event_t *);
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1017c478bd9Sstevel@tonic-gate }
1027c478bd9Sstevel@tonic-gate #endif
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #endif	/* _PROTOCOL_H */
105