| 416 | } |
| 417 | |
| 418 | cs_error_t quorum_dispatch ( |
| 419 | quorum_handle_t handle, |
| 420 | cs_dispatch_flags_t dispatch_types) |
| 421 | { |
| 422 | int timeout = -1; |
| 423 | cs_error_t error; |
| 424 | int cont = 1; /* always continue do loop except when set to 0 */ |
| 425 | struct quorum_inst *quorum_inst; |
| 426 | struct quorum_inst quorum_inst_copy; |
| 427 | struct qb_ipc_response_header *dispatch_data; |
| 428 | char dispatch_buf[IPC_DISPATCH_SIZE]; |
| 429 | struct res_lib_quorum_notification *res_lib_quorum_notification; |
| 430 | struct res_lib_quorum_v1_quorum_notification *res_lib_quorum_v1_quorum_notification; |
| 431 | struct res_lib_quorum_v1_nodelist_notification *res_lib_quorum_v1_nodelist_notification; |
| 432 | struct quorum_ring_id ring_id; |
| 433 | mar_uint32_t *joined_list; |
| 434 | mar_uint32_t *left_list; |
| 435 | |
| 436 | if (dispatch_types != CS_DISPATCH_ONE && |
| 437 | dispatch_types != CS_DISPATCH_ALL && |
| 438 | dispatch_types != CS_DISPATCH_BLOCKING && |
| 439 | dispatch_types != CS_DISPATCH_ONE_NONBLOCKING) { |
| 440 | |
| 441 | return (CS_ERR_INVALID_PARAM); |
| 442 | } |
| 443 | |
| 444 | error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, |
| 445 | (void *)&quorum_inst)); |
| 446 | if (error != CS_OK) { |
| 447 | return (error); |
| 448 | } |
| 449 | |
| 450 | /* |
| 451 | * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and |
| 452 | * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING |
| 453 | */ |
| 454 | if (dispatch_types == CS_DISPATCH_ALL || dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) { |
| 455 | timeout = 0; |
| 456 | } |
| 457 | |
| 458 | dispatch_data = (struct qb_ipc_response_header *)dispatch_buf; |
| 459 | do { |
| 460 | error = qb_to_cs_error (qb_ipcc_event_recv ( |
| 461 | quorum_inst->c, |
| 462 | dispatch_buf, |
| 463 | IPC_DISPATCH_SIZE, |
| 464 | timeout)); |
| 465 | if (error == CS_ERR_BAD_HANDLE) { |
| 466 | error = CS_OK; |
| 467 | goto error_put; |
| 468 | } |
| 469 | if (error == CS_ERR_TRY_AGAIN) { |
| 470 | if (dispatch_types == CS_DISPATCH_ONE_NONBLOCKING) { |
| 471 | /* |
| 472 | * Don't mask error |
| 473 | */ |
| 474 | goto error_put; |
| 475 | } |