mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-14 17:12:34 +00:00
Handle NULL callbacks in cpg, evs and confdb lib
Attached patches handle NULL callbacks in *_initialize and *_dispatch. Handling is same as in quorum service. Now, when callback is NULL -> no memcpy -> instance callbacks will have all items set to NULL and in *_dispatch function is not called. It changes cfg so now we are using continue instead of exit. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2392 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
d11f1f90c2
commit
8eeeccbf00
@ -202,10 +202,12 @@ corosync_cfg_dispatch (
|
||||
*/
|
||||
switch (dispatch_data->id) {
|
||||
case MESSAGE_RES_CFG_TESTSHUTDOWN:
|
||||
if (callbacks.corosync_cfg_shutdown_callback) {
|
||||
res_lib_cfg_testshutdown = (struct res_lib_cfg_testshutdown *)dispatch_data;
|
||||
callbacks.corosync_cfg_shutdown_callback(cfg_handle, res_lib_cfg_testshutdown->flags);
|
||||
if (callbacks.corosync_cfg_shutdown_callback == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_lib_cfg_testshutdown = (struct res_lib_cfg_testshutdown *)dispatch_data;
|
||||
callbacks.corosync_cfg_shutdown_callback(cfg_handle, res_lib_cfg_testshutdown->flags);
|
||||
break;
|
||||
default:
|
||||
coroipcc_dispatch_put (cfg_instance->handle);
|
||||
|
16
lib/confdb.c
16
lib/confdb.c
@ -158,7 +158,9 @@ cs_error_t confdb_initialize (
|
||||
if (error != CS_OK)
|
||||
goto error_put_destroy;
|
||||
|
||||
memcpy (&confdb_inst->callbacks, callbacks, sizeof (confdb_callbacks_t));
|
||||
if (callbacks) {
|
||||
memcpy (&confdb_inst->callbacks, callbacks, sizeof (confdb_callbacks_t));
|
||||
}
|
||||
|
||||
list_init (&confdb_inst->object_find_head);
|
||||
list_init (&confdb_inst->object_iter_head);
|
||||
@ -336,6 +338,10 @@ cs_error_t confdb_dispatch (
|
||||
*/
|
||||
switch (dispatch_data->id) {
|
||||
case MESSAGE_RES_CONFDB_KEY_CHANGE_CALLBACK:
|
||||
if (callbacks.confdb_key_change_notify_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_key_changed_pt = (struct res_lib_confdb_key_change_callback *)dispatch_data;
|
||||
|
||||
callbacks.confdb_key_change_notify_fn(handle,
|
||||
@ -351,6 +357,10 @@ cs_error_t confdb_dispatch (
|
||||
break;
|
||||
|
||||
case MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK:
|
||||
if (callbacks.confdb_object_create_change_notify_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_object_created_pt = (struct res_lib_confdb_object_create_callback *)dispatch_data;
|
||||
|
||||
callbacks.confdb_object_create_change_notify_fn(handle,
|
||||
@ -361,6 +371,10 @@ cs_error_t confdb_dispatch (
|
||||
break;
|
||||
|
||||
case MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK:
|
||||
if (callbacks.confdb_object_delete_change_notify_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_object_destroyed_pt = (struct res_lib_confdb_object_destroy_callback *)dispatch_data;
|
||||
|
||||
callbacks.confdb_object_delete_change_notify_fn(handle,
|
||||
|
12
lib/cpg.c
12
lib/cpg.c
@ -101,7 +101,9 @@ cs_error_t cpg_initialize (
|
||||
goto error_put_destroy;
|
||||
}
|
||||
|
||||
memcpy (&cpg_inst->callbacks, callbacks, sizeof (cpg_callbacks_t));
|
||||
if (callbacks) {
|
||||
memcpy (&cpg_inst->callbacks, callbacks, sizeof (cpg_callbacks_t));
|
||||
}
|
||||
|
||||
hdb_handle_put (&cpg_handle_t_db, *handle);
|
||||
|
||||
@ -268,6 +270,10 @@ cs_error_t cpg_dispatch (
|
||||
*/
|
||||
switch (dispatch_data->id) {
|
||||
case MESSAGE_RES_CPG_DELIVER_CALLBACK:
|
||||
if (callbacks.cpg_deliver_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_cpg_deliver_callback = (struct res_lib_cpg_deliver_callback *)dispatch_data;
|
||||
|
||||
marshall_from_mar_cpg_name_t (
|
||||
@ -283,6 +289,10 @@ cs_error_t cpg_dispatch (
|
||||
break;
|
||||
|
||||
case MESSAGE_RES_CPG_CONFCHG_CALLBACK:
|
||||
if (callbacks.cpg_confchg_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_cpg_confchg_callback = (struct res_lib_cpg_confchg_callback *)dispatch_data;
|
||||
|
||||
for (i = 0; i < res_cpg_confchg_callback->member_list_entries; i++) {
|
||||
|
12
lib/evs.c
12
lib/evs.c
@ -116,7 +116,9 @@ evs_error_t evs_initialize (
|
||||
goto error_put_destroy;
|
||||
}
|
||||
|
||||
memcpy (&evs_inst->callbacks, callbacks, sizeof (evs_callbacks_t));
|
||||
if (callbacks) {
|
||||
memcpy (&evs_inst->callbacks, callbacks, sizeof (evs_callbacks_t));
|
||||
}
|
||||
|
||||
hdb_handle_put (&evs_handle_t_db, *handle);
|
||||
|
||||
@ -277,6 +279,10 @@ evs_error_t evs_dispatch (
|
||||
*/
|
||||
switch (dispatch_data->id) {
|
||||
case MESSAGE_RES_EVS_DELIVER_CALLBACK:
|
||||
if (callbacks.evs_deliver_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_evs_deliver_callback = (struct res_evs_deliver_callback *)dispatch_data;
|
||||
callbacks.evs_deliver_fn (
|
||||
handle,
|
||||
@ -286,6 +292,10 @@ evs_error_t evs_dispatch (
|
||||
break;
|
||||
|
||||
case MESSAGE_RES_EVS_CONFCHG_CALLBACK:
|
||||
if (callbacks.evs_confchg_fn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res_evs_confchg_callback = (struct res_evs_confchg_callback *)dispatch_data;
|
||||
callbacks.evs_confchg_fn (
|
||||
handle,
|
||||
|
Loading…
Reference in New Issue
Block a user