2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Managing the reference counter of a slave
25 SLAVE_EVENT_DEACTIVATE, /* deactivate callback, can return REACTIVATE, DEFAULT */
27 SLAVE_EVENT_FAULT, /* Critical fault */
32 SLAVE_NEED_TO_REACTIVATE
37 * Launch the slave but not yet receives "hello" packet
39 SLAVE_REQUEST_TO_LAUNCH,
43 * Terminate the slave but not yet receives dead signal
45 SLAVE_REQUEST_TO_TERMINATE,
49 * No slave process exists, just slave object created
55 * State change request is sent,
57 SLAVE_REQUEST_TO_PAUSE,
58 SLAVE_REQUEST_TO_RESUME,
62 * Request an action for disconnecting to master from the provider side.
63 * This flag should be treated as an activated state.
65 SLAVE_REQUEST_TO_DISCONNECT,
69 * SLAVE_ACTIVATED = { SLAVE_PAUSED, SLAVE_RESUMED }
74 SLAVE_ERROR = 0xFF /* Explicitly define the size of this enum type */
78 PROVIDER_CTRL_DEFAULT = 0x00, /*!< Set default control operation */
79 PROVIDER_CTRL_MANUAL_TERMINATION = 0x01, /*!< Terminate process manually */
80 PROVIDER_CTRL_MANUAL_REACTIVATION = 0x02, /*!< Reactivate process manually */
83 extern struct slave_node *slave_ref(struct slave_node *slave);
84 extern struct slave_node *slave_unref(struct slave_node *slave);
85 extern const int const slave_refcnt(struct slave_node *slave);
89 * Create a new slave object or destroy it
92 * \param[in] is_secured
98 extern struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network);
105 extern void slave_destroy(struct slave_node *slave);
109 * Launch or terminate a slave
113 extern int slave_activate(struct slave_node *slave);
116 * \brief After this function call, the slave object can be deleted
119 extern struct slave_node *slave_deactivate(struct slave_node *slave, int direct) __attribute__((warn_unused_result));
122 * To check the slave's activation state
124 extern const int const slave_is_activated(struct slave_node *slave);
125 extern int slave_activated(struct slave_node *slave);
127 extern int slave_give_more_ttl(struct slave_node *slave);
128 extern int slave_freeze_ttl(struct slave_node *slave);
129 extern int slave_thaw_ttl(struct slave_node *slave);
130 extern int slave_expired_ttl(struct slave_node *slave);
134 * To mangage the unexpected termination of a slave
135 * After this function call, the slave object can be deleted
137 extern struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) __attribute__((warn_unused_result));
141 * After this function, the slave object can be deleted
143 extern struct slave_node *slave_deactivated(struct slave_node *slave) __attribute__((warn_unused_result));
145 extern int slave_event_callback_add(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
146 extern int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
148 extern int slave_set_data(struct slave_node *slave, const char *tag, void *data);
149 extern void *slave_del_data(struct slave_node *slave, const char *tag);
150 extern void *slave_data(struct slave_node *slave, const char *tag);
152 extern struct slave_node *slave_find_by_pid(pid_t pid);
153 extern struct slave_node *slave_find_by_name(const char *name);
154 extern struct slave_node *slave_find_by_pkgname(const char *pkgname);
155 extern struct slave_node *slave_find_by_rpc_handle(int handle);
157 extern void slave_dead_handler(struct slave_node *slave);
158 extern const int const slave_is_secured(const struct slave_node *slave);
159 extern const char * const slave_name(const struct slave_node *slave);
160 extern const pid_t const slave_pid(const struct slave_node *slave);
161 extern const char * const slave_abi(const struct slave_node *slave);
162 extern int slave_set_pid(struct slave_node *slave, pid_t pid);
166 * Used for making decision of destroying a slave or not
167 * Used for balancing load of the slave.
169 extern void slave_load_package(struct slave_node *slave);
170 extern void slave_unload_package(struct slave_node *slave);
171 extern int const slave_loaded_package(struct slave_node *slave);
172 extern struct slave_node *slave_find_available(const char *abi, int secured, int network);
174 extern double const slave_ttl(const struct slave_node *slave);
178 * Used for making decision of activating a slave or not
180 extern void slave_load_instance(struct slave_node *slave);
184 * After this function call, the slave object can be deleted.
186 extern struct slave_node *slave_unload_instance(struct slave_node *slave) __attribute__((warn_unused_result));
188 extern int const slave_loaded_instance(struct slave_node *slave);
190 extern int slave_resume(struct slave_node *slave);
191 extern int slave_pause(struct slave_node *slave);
193 extern const char *slave_pkgname(const struct slave_node *slave);
194 extern enum slave_state slave_state(const struct slave_node *slave);
195 extern const char *slave_state_string(const struct slave_node *slave);
197 extern const void *slave_list(void);
198 extern int const slave_fault_count(const struct slave_node *slave);
200 extern int slave_need_to_reactivate_instances(struct slave_node *slave);
201 extern void slave_set_reactivate_instances(struct slave_node *slave, int reactivate);
203 extern void slave_set_reactivation(struct slave_node *slave, int flag);
204 extern int slave_need_to_reactivate(struct slave_node *slave);
206 extern int slave_network(const struct slave_node *slave);
207 extern void slave_set_network(struct slave_node *slave, int network);
209 extern int slave_deactivate_all(int reactivate, int reactivate_instances, int no_timer);
210 extern int slave_activate_all(void);
212 extern void slave_set_control_option(struct slave_node *slave, int ctrl);
213 extern int slave_control_option(struct slave_node *slave);