MCPcopy Create free account
hub / github.com/corosync/corosync / cmap_dispatch

Function cmap_dispatch

lib/cmap.c:229–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229cs_error_t cmap_dispatch (
230 cmap_handle_t handle,
231 cs_dispatch_flags_t dispatch_types)
232{
233 int timeout = -1;
234 cs_error_t error;
235 int cont = 1; /* always continue do loop except when set to 0 */
236 struct cmap_inst *cmap_inst;
237 struct qb_ipc_response_header *dispatch_data;
238 char dispatch_buf[IPC_DISPATCH_SIZE];
239 struct res_lib_cmap_notify_callback *res_lib_cmap_notify_callback;
240 struct cmap_track_inst *cmap_track_inst;
241 struct cmap_notify_value old_val;
242 struct cmap_notify_value new_val;
243
244 error = hdb_error_to_cs(hdb_handle_get (&cmap_handle_t_db, handle, (void *)&cmap_inst));
245 if (error != CS_OK) {
246 return (error);
247 }
248
249 /*
250 * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and
251 * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING
252 */
253 if (dispatch_types == CS_DISPATCH_ALL || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
254 timeout = 0;
255 }
256
257 dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
258 do {
259 error = qb_to_cs_error(qb_ipcc_event_recv (
260 cmap_inst->c,
261 dispatch_buf,
262 IPC_DISPATCH_SIZE,
263 timeout));
264
265 if (error == CS_ERR_BAD_HANDLE) {
266 error = CS_OK;
267 goto error_put;
268 }
269 if (error == CS_ERR_TRY_AGAIN) {
270 if (dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) {
271 /*
272 * Don't mask error
273 */
274 goto error_put;
275 }
276 error = CS_OK;
277 if (dispatch_types == CS_DISPATCH_ALL) {
278 break; /* exit do while cont is 1 loop */
279 } else {
280 continue; /* next poll */
281 }
282 }
283
284 if (error != CS_OK) {
285 goto error_put;
286 }

Callers 3

_cs_cmap_dispatchFunction · 0.85
track_changesFunction · 0.85
dispatchFunction · 0.85

Calls 4

hdb_error_to_csFunction · 0.85
hdb_handle_getFunction · 0.85
qb_to_cs_errorFunction · 0.85
hdb_handle_putFunction · 0.85

Tested by

no test coverage detected