Hi Long,

I see one problem if B.01.01 application frees the memory in pg tracking 
callback.
Please see inline.

Thanks,
Praveen
On 19-Aug-16 12:00 PM, Long HB Nguyen wrote:
>  osaf/libs/agents/saf/amfa/amf_agent.cc |  1 +
>  osaf/libs/agents/saf/amfa/ava_hdl.cc   |  2 --
>  2 files changed, 1 insertions(+), 2 deletions(-)
>
>
> diff --git a/osaf/libs/agents/saf/amfa/amf_agent.cc 
> b/osaf/libs/agents/saf/amfa/amf_agent.cc
> --- a/osaf/libs/agents/saf/amfa/amf_agent.cc
> +++ b/osaf/libs/agents/saf/amfa/amf_agent.cc
> @@ -2450,6 +2450,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTra
>            ava_cpy_protection_group_ntf(buf->notification, 
> rsp_buf->notification,
>                                         buf->numberOfItems, 
> SA_AMF_HARS_READY_FOR_ASSIGNMENT);
>            rc = SA_AIS_ERR_NO_SPACE;
> +               buf->numberOfItems = rsp_buf->numberOfItems;
>          }
>        } else {       /* if(create_memory == false) */
>
> diff --git a/osaf/libs/agents/saf/amfa/ava_hdl.cc 
> b/osaf/libs/agents/saf/amfa/ava_hdl.cc
> --- a/osaf/libs/agents/saf/amfa/ava_hdl.cc
> +++ b/osaf/libs/agents/saf/amfa/ava_hdl.cc
> @@ -697,7 +697,6 @@ uint32_t ava_hdl_cbk_rec_prc(AVSV_AMF_CB
>                                               
> ((SaAmfCallbacksT_4*)reg_cbk)->saAmfProtectionGroupTrackCallback(&pg_track->csi_name,
>                                                                               
>                         &buf,
>                                                                               
>                           pg_track->mem_num, pg_track->err);
> -                                             free(buf.notification);
>                                       } else {
>                                               pg_track->err = 
> SA_AIS_ERR_NO_MEMORY;
>                                               LOG_CR("Notification is NULL: 
> Invoking PGTrack Callback with error SA_AIS_ERR_NO_MEMORY");
> @@ -740,7 +739,6 @@ uint32_t ava_hdl_cbk_rec_prc(AVSV_AMF_CB
>                                               ((SaAmfCallbacksT 
> *)reg_cbk)->saAmfProtectionGroupTrackCallback(&pg_track->csi_name,
>                                                                               
>            &buf,
>                                                                               
>            pg_track->mem_num, pg_track->err);
> -                                             free(buf.notification);
For B.04.01 API, saAmfProtectionGroupNotificationFree_4() is taking care 
of freeing any extended name. For 
saAmfProtectionGroupNotificationFree(), it is the application's 
responsibility to free the memory. But how it will free any extended name.
I think there is no API equivalent to osaf_extended_name_free() for 
application. Is there any way?
Otherwise we can document it that:
-if compName is not long dn in the notification buffer, then application 
has to free the memory.This will provide backward compatibility and spec 
compliance.

  -if compName is longdn in notification then application should not 
free the memory. Agent will free the memory after callback is completed. 
So any B.01.01 application adapting to long dn will take care of this 
when modifying the application. In that case we need to do something 
like this :
for i in notificationBuffer->notification[i]
   if 
(osaf_is_an_extended_name(notificationBuffer->notification[i].member.compName)){
        longdn_found = true;
        osaf_extended_name_free();
     }
}
if(longdn_found)
        free(buf.notification)
                

Also there is a Todo in amf_agent.cc " // TODO (minhchau): memleak if 
notification is an array".

Thanks,
Praveen

>                                       } else {
>                                               pg_track->err = 
> SA_AIS_ERR_NO_MEMORY;
>                                               LOG_CR("Notification is NULL: 
> Invoking PGTrack Callback with error SA_AIS_ERR_NO_MEMORY");
>

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to