Main problem is,
that sometimes message_handler_req_lib_lck_resourcelock(async) ask to
deleted handle. So this patch test result of hdb_get... and if it is not
0, it should return error to caller -> ipc send. So from my point of
view, it's just easier to introduce more universal function (and call it
in old function) to send IPC reply.
Ryan O'Hara wrote:
> NACK. What is the purpose of introducing a new function?
>
> On Tue, Jun 02, 2009 at 05:34:07PM +0200, Jan Friesse wrote:
>> This patch also split lck_resourcelock_response_send to two
>> functions, because it looks like easy way how to avoid
>> code duplication.
>> ---
>> trunk/services/lck.c | 56
>> ++++++++++++++++++++++++++++++++++---------------
>> 1 files changed, 39 insertions(+), 17 deletions(-)
>>
>> diff --git a/trunk/services/lck.c b/trunk/services/lck.c
>> index 383e862..055c8ad 100644
>> --- a/trunk/services/lck.c
>> +++ b/trunk/services/lck.c
>> @@ -1572,32 +1572,43 @@ static struct resource_lock *lck_resource_lock_find (
>> return (0);
>> }
>>
>> +static void lck_resourcelock_response_send_int(
>> + void *conn,
>> + mar_uint32_t lock_status,
>> + SaAisErrorT error)
>> +{
>> + struct res_lib_lck_resourcelock res_lib_lck_resourcelock;
>> +
>> + res_lib_lck_resourcelock.header.size =
>> + sizeof (struct res_lib_lck_resourcelock);
>> + res_lib_lck_resourcelock.header.id =
>> + MESSAGE_RES_LCK_RESOURCELOCK;
>> + res_lib_lck_resourcelock.header.error = error;
>> + res_lib_lck_resourcelock.lock_status =
>> + lock_status;
>> +
>> + api->ipc_response_send (
>> + conn,
>> + &res_lib_lck_resourcelock,
>> + sizeof (struct res_lib_lck_resourcelock));
>> +}
>> +
>> static void lck_resourcelock_response_send (
>> struct resource_lock *resource_lock,
>> SaAisErrorT error)
>> {
>> - struct res_lib_lck_resourcelock res_lib_lck_resourcelock;
>>
>> /* DEBUG */
>> log_printf (LOGSYS_LEVEL_DEBUG, "[DEBUG]:
>> lck_resourcelock_response_send\n");
>>
>> + assert (resource_lock != NULL);
>> +
>> if (api->ipc_source_is_local (&resource_lock->response_source))
>> {
>> - res_lib_lck_resourcelock.header.size =
>> - sizeof (struct res_lib_lck_resourcelock);
>> - res_lib_lck_resourcelock.header.id =
>> - MESSAGE_RES_LCK_RESOURCELOCK;
>> - res_lib_lck_resourcelock.header.error = error;
>> -
>> - if (resource_lock != NULL) {
>> - res_lib_lck_resourcelock.lock_status =
>> - resource_lock->lock_status;
>> - }
>> -
>> - api->ipc_response_send (
>> + lck_resourcelock_response_send_int(
>> resource_lock->response_source.conn,
>> - &res_lib_lck_resourcelock,
>> - sizeof (struct res_lib_lck_resourcelock));
>> + resource_lock->lock_status,
>> + error);
>> }
>> }
>>
>> @@ -2045,6 +2056,7 @@ error_exit:
>> sizeof (*resource_instance), &resource_id);
>> hdb_handle_get (&resource_hdb,
>> resource_id, (void *)&resource_instance);
>> + fprintf(stderr,"Resource id = %lld\n",resource_id);
>> memcpy (&resource_instance->source,
>> &req_exec_lck_resourceopen->source,
>> sizeof (mar_message_source_t));
>> @@ -2997,6 +3009,7 @@ static void message_handler_req_lib_lck_resourcelock (
>> struct req_exec_lck_resourcelock req_exec_lck_resourcelock;
>> struct resource_instance *resource_instance;
>> struct iovec iovec;
>> + int res;
>>
>> /* DEBUG */
>> log_printf (LOGSYS_LEVEL_DEBUG, "LIB request: saLckResourceLock\n");
>> @@ -3027,8 +3040,12 @@ static void message_handler_req_lib_lck_resourcelock (
>> req_exec_lck_resourcelock.timeout =
>> req_lib_lck_resourcelock->timeout;
>>
>> - hdb_handle_get (&resource_hdb, req_lib_lck_resourcelock->resource_id,
>> + res = hdb_handle_get (&resource_hdb,
>> req_lib_lck_resourcelock->resource_id,
>> (void *)&resource_instance);
>> + if (res != 0) {
>> + lck_resourcelock_response_send_int(conn, 0,
>> SA_AIS_ERR_BAD_HANDLE);
>> + return ;
>> + }
>>
>> memcpy (&req_exec_lck_resourcelock.callback_source,
>> &resource_instance->source, sizeof (mar_message_source_t));
>> @@ -3049,6 +3066,7 @@ static void
>> message_handler_req_lib_lck_resourcelockasync (
>> struct req_exec_lck_resourcelockasync req_exec_lck_resourcelockasync;
>> struct resource_instance *resource_instance;
>> struct iovec iovec;
>> + int res;
>>
>> /* DEBUG */
>> log_printf (LOGSYS_LEVEL_DEBUG, "LIB request:
>> saLckResourceLockAsync\n");
>> @@ -3079,8 +3097,12 @@ static void
>> message_handler_req_lib_lck_resourcelockasync (
>> req_exec_lck_resourcelockasync.invocation =
>> req_lib_lck_resourcelockasync->invocation;
>>
>> - hdb_handle_get (&resource_hdb,
>> req_lib_lck_resourcelockasync->resource_id,
>> + res = hdb_handle_get (&resource_hdb,
>> req_lib_lck_resourcelockasync->resource_id,
>> (void *)&resource_instance);
>> + if (res != 0) {
>> + lck_resourcelock_response_send_int(conn, 0,
>> SA_AIS_ERR_BAD_HANDLE);
>> + return ;
>> + }
>>
>> memcpy (&req_exec_lck_resourcelockasync.callback_source,
>> &resource_instance->source, sizeof (mar_message_source_t));
>> --
>> 1.5.5.6
>>
>> _______________________________________________
>> 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