Changed:
- break to continue (in cfg too)
- (!something) to (something == NULL)
Committed as 2392.
Steven Dake napsal(a):
> On Wed, 2009-08-19 at 15:55 +0200, Jan Friesse wrote:
>> Attached patches handle NULL callbacks in [cpg|evs|confdb]_initialize
>> and *_dispatch. Handling is same as in cfg service (and SIMILAR (see
>> bellow) as in quorum and votequorum), so if callback is NULL -> no
>> memcpy -> instance callbacks will have all items set to NULL.
>>
>> In *_dispatch, if callbacks.$CALLBACK_NAME is NULL it will break. And
>> there is difference between CFG and QUORUM service, so I like to ask
>> what behavior is correct/better/...
>>
>> quorum and votequorum calls use continue -> ignore code:
>>
>
> should continue and ignore callback request from executive.
>
>> switch (dispatch_types) {
>> case CS_DISPATCH_ONE:
>> cont = 0;
>> break;
>> case CS_DISPATCH_ALL:
>> break;
>> case CS_DISPATCH_BLOCKING:
>> break;
>> }
>>
>> so if CS_DISPATCH is set to CS_DISPATCH_ONE, you will process more than
>> ONE dispatch.
>>
>> CFG will use break and doesn't ignore the code, this means,
>> CS_DISPATCH_ONE will process ONE dispatch.
>>
>> From a user point of view, it looks like QUORUM solution is more correct
>> (user wanted ONE dispatch, not zero), but I'm not sure.
>>
>> Is it possible to make behavior same?
>>
>>
>
> please compare to NULL rather then using the not (!) operator. ie:
> if (callback == NULL) {
> continue;
> }
>
> otherwise, looks good for merge.
>
> Regards
> -steve
>
>
>> Regards,
>> Honza
>> plain text document attachment
>> (0001-cpg_initialize-handle-NULL-as-callbacks.patch)
>> From 25e448fa78560fbdc7be5ad5ac460e8f9939d0ef Mon Sep 17 00:00:00 2001
>> From: Jan Friesse <[email protected]>
>> Date: Wed, 19 Aug 2009 15:29:30 +0200
>> Subject: [PATCH 1/3] cpg_initialize - handle NULL as callbacks
>>
>> ---
>> trunk/lib/cpg.c | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/trunk/lib/cpg.c b/trunk/lib/cpg.c
>> index e3ab8e6..b024549 100644
>> --- a/trunk/lib/cpg.c
>> +++ b/trunk/lib/cpg.c
>> @@ -142,7 +142,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));
>> + }
>>
>> list_init(&cpg_inst->iteration_list_head);
>>
>> @@ -310,6 +312,9 @@ cs_error_t cpg_dispatch (
>> */
>> switch (dispatch_data->id) {
>> case MESSAGE_RES_CPG_DELIVER_CALLBACK:
>> + if (!callbacks.cpg_deliver_fn)
>> + break;
>> +
>> res_cpg_deliver_callback = (struct
>> res_lib_cpg_deliver_callback *)dispatch_data;
>>
>> marshall_from_mar_cpg_name_t (
>> @@ -325,6 +330,9 @@ cs_error_t cpg_dispatch (
>> break;
>>
>> case MESSAGE_RES_CPG_CONFCHG_CALLBACK:
>> + if (!callbacks.cpg_confchg_fn)
>> + break;
>> +
>> res_cpg_confchg_callback = (struct
>> res_lib_cpg_confchg_callback *)dispatch_data;
>>
>> for (i = 0; i <
>> res_cpg_confchg_callback->member_list_entries; i++) {
>> plain text document attachment
>> (0002-confdb-lib-handle-NULL-as-callbacks.patch)
>> From d0e72cffcbc0868ef466c5fb1e83b00c84b88560 Mon Sep 17 00:00:00 2001
>> From: Jan Friesse <[email protected]>
>> Date: Wed, 19 Aug 2009 15:34:41 +0200
>> Subject: [PATCH 2/3] confdb lib - handle NULL as callbacks
>>
>> ---
>> trunk/lib/confdb.c | 13 ++++++++++++-
>> 1 files changed, 12 insertions(+), 1 deletions(-)
>>
>> diff --git a/trunk/lib/confdb.c b/trunk/lib/confdb.c
>> index 8402f32..507dde4 100644
>> --- a/trunk/lib/confdb.c
>> +++ b/trunk/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,9 @@ cs_error_t confdb_dispatch (
>> */
>> switch (dispatch_data->id) {
>> case MESSAGE_RES_CONFDB_KEY_CHANGE_CALLBACK:
>> + if (!callbacks.confdb_key_change_notify_fn)
>> + break;
>> +
>> res_key_changed_pt = (struct
>> res_lib_confdb_key_change_callback *)dispatch_data;
>>
>> callbacks.confdb_key_change_notify_fn(handle,
>> @@ -351,6 +356,9 @@ cs_error_t confdb_dispatch (
>> break;
>>
>> case MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK:
>> + if
>> (!callbacks.confdb_object_create_change_notify_fn)
>> + break;
>> +
>> res_object_created_pt = (struct
>> res_lib_confdb_object_create_callback *)dispatch_data;
>>
>>
>> callbacks.confdb_object_create_change_notify_fn(handle,
>> @@ -361,6 +369,9 @@ cs_error_t confdb_dispatch (
>> break;
>>
>> case MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK:
>> + if
>> (!callbacks.confdb_object_delete_change_notify_fn)
>> + break;
>> +
>> res_object_destroyed_pt = (struct
>> res_lib_confdb_object_destroy_callback *)dispatch_data;
>>
>>
>> callbacks.confdb_object_delete_change_notify_fn(handle,
>> plain text document attachment
>> (0003-evs-lib-handle-NULL-as-callbacks.patch)
>> From a112a99e8578159a1c697838a38b46d87c6066dd Mon Sep 17 00:00:00 2001
>> From: Jan Friesse <[email protected]>
>> Date: Wed, 19 Aug 2009 15:36:40 +0200
>> Subject: [PATCH 3/3] evs lib - handle NULL as callbacks
>>
>> ---
>> trunk/lib/evs.c | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/trunk/lib/evs.c b/trunk/lib/evs.c
>> index 6bf1448..7161cf3 100644
>> --- a/trunk/lib/evs.c
>> +++ b/trunk/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,9 @@ evs_error_t evs_dispatch (
>> */
>> switch (dispatch_data->id) {
>> case MESSAGE_RES_EVS_DELIVER_CALLBACK:
>> + if (!callbacks.evs_deliver_fn)
>> + break;
>> +
>> res_evs_deliver_callback = (struct
>> res_evs_deliver_callback *)dispatch_data;
>> callbacks.evs_deliver_fn (
>> handle,
>> @@ -286,6 +291,9 @@ evs_error_t evs_dispatch (
>> break;
>>
>> case MESSAGE_RES_EVS_CONFCHG_CALLBACK:
>> + if (!callbacks.evs_confchg_fn)
>> + break;
>> +
>> res_evs_confchg_callback = (struct
>> res_evs_confchg_callback *)dispatch_data;
>> callbacks.evs_confchg_fn (
>> handle,
>> _______________________________________________
>> Openais mailing list
>> [email protected]
>> https://lists.linux-foundation.org/mailman/listinfo/openais
>
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais