About the patch, I have no clue why the indentation looks strange.
I just have a question below, otherwise ack:
+while (true) {
+/* Say Hello */
+rc = saClmInitialize_4(&cb->clm_hdl, &clm_cbk, &clm_version);
+if (rc == SA_AIS_OK)
+break;
+else if (rc == SA_AIS_ERR_TRY_AGAIN ||
+rc == SA_AIS_ERR_UNAVAILABLE) {
+osaf_nanosleep(&kHundredMilliseconds);
+continue;

IMM utils implement a global retry counter. I haven't thought through the
big picture yet, so leaving it to you to decide whether
such a retry counter makes sense here?

Thanks,
Mathi.

On Thu, Sep 5, 2019 at 9:21 PM Jones, Alex <ajo...@rbbn.com> wrote:

> Handle CLM-API errors during SC absence.
> ---
> src/evt/common/edsv_defs.h | 2 +-
> src/evt/evtd/eds_amf.c | 71 ++++++++++++++++++++++++++++++--------
> src/evt/evtd/eds_amf.h | 11 ++++--
> src/evt/evtd/eds_cb.c | 6 +++-
> 4 files changed, 72 insertions(+), 18 deletions(-)
>
> diff --git a/src/evt/common/edsv_defs.h b/src/evt/common/edsv_defs.h
> index 8372ce8a8..24604927c 100644
> --- a/src/evt/common/edsv_defs.h
> +++ b/src/evt/common/edsv_defs.h
> @@ -82,7 +82,7 @@
>
> #define m_EDSV_GET_CLM_VER(amf_ver) \
> amf_ver.releaseCode = 'B'; \
> - amf_ver.majorVersion = 0x01; \
> + amf_ver.majorVersion = 0x04; \
> amf_ver.minorVersion = 0x01;
>
> /* Define our limits */
> diff --git a/src/evt/evtd/eds_amf.c b/src/evt/evtd/eds_amf.c
> index fe90a6c62..97b71a5bd 100644
> --- a/src/evt/evtd/eds_amf.c
> +++ b/src/evt/evtd/eds_amf.c
> @@ -26,6 +26,7 @@ DESCRIPTION:
> This include file contains AMF interaction logic for health-check and other
> stuff.
>
> *******************************************************************************/
> +#include "base/osaf_time.h"
> #include "eds.h"
> #include "eds_dl_api.h"
>
> @@ -622,9 +623,9 @@ uint32_t eds_amf_register(EDS_CB *eds_cb)
> SaAisErrorT eds_clm_init(EDS_CB *cb)
> {
> SaVersionT clm_version;
> -SaClmCallbacksT clm_cbk;
> -SaClmClusterNodeT cluster_node;
> -SaClmClusterNotificationBufferT notify_buff;
> +SaClmCallbacksT_4 clm_cbk;
> +SaClmClusterNodeT_4 cluster_node;
> +SaClmClusterNotificationBufferT_4 notify_buff;
> SaAisErrorT rc = SA_AIS_OK;
> SaTimeT timeout = EDSV_CLM_TIMEOUT;
> TRACE_ENTER();
> @@ -639,13 +640,22 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> clm_cbk.saClmClusterNodeGetCallback = NULL;
> clm_cbk.saClmClusterTrackCallback = eds_clm_cluster_track_cbk;
>
> -/* Say Hello */
> -rc = saClmInitialize(&cb->clm_hdl, &clm_cbk, &clm_version);
> -if (rc != SA_AIS_OK) {
> -LOG_ER("saClmInitialize failed with error: %d", rc);
> -TRACE_LEAVE();
> -return rc;
> +while (true) {
> +/* Say Hello */
> +rc = saClmInitialize_4(&cb->clm_hdl, &clm_cbk, &clm_version);
> +if (rc == SA_AIS_OK)
> +break;
> +else if (rc == SA_AIS_ERR_TRY_AGAIN ||
> +rc == SA_AIS_ERR_UNAVAILABLE) {
> +osaf_nanosleep(&kHundredMilliseconds);
> +continue;
> +} else {
> +LOG_ER("saClmInitialize_4 failed with error: %d", rc);
> +TRACE_LEAVE();
> +return rc;
> +}
> }
> +
> /* Get the FD */
> if (SA_AIS_OK !=
> (rc = saClmSelectionObjectGet(cb->clm_hdl, &cb->clm_sel_obj))) {
> @@ -654,10 +664,10 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
> /* Get your own node id */
> -rc = saClmClusterNodeGet(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> +rc = saClmClusterNodeGet_4(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> &cluster_node);
> if (rc != SA_AIS_OK) {
> -LOG_ER("saClmClusterNodeGet failed with error: %d", rc);
> +LOG_ER("saClmClusterNodeGet_4 failed with error: %d", rc);
> TRACE_LEAVE();
> return rc;
> }
> @@ -665,7 +675,7 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> cb->node_id = cluster_node.nodeId;
>
> notify_buff.notification = NULL;
> -rc = saClmClusterTrack(cb->clm_hdl,
> +rc = saClmClusterTrack_4(cb->clm_hdl,
> (SA_TRACK_CURRENT | SA_TRACK_CHANGES), NULL);
> if (rc != SA_AIS_OK)
> LOG_ER("saClmClusterTrack failed with error: %d", rc);
> @@ -674,6 +684,33 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
>
> +static void * eds_clm_init_thread(void *arg) {
> + TRACE_ENTER();
> + EDS_CB *cb = (EDS_CB *)(arg);
> +
> + eds_clm_init(cb);
> +
> + TRACE_LEAVE();
> + return 0;
> +}
> +
> +SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb)
> +{
> +pthread_t thread;
> +pthread_attr_t attr;
> +pthread_attr_init(&attr);
> +pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
> +
> +if (pthread_create(&thread, &attr, eds_clm_init_thread, cb) != 0) {
> +LOG_ER("pthread_create FAILED: %s", strerror(errno));
> +exit(EXIT_FAILURE);
> +}
> +
> +pthread_attr_destroy(&attr);
> +
> +return SA_AIS_OK;
> +}
> +
> /**************************************************************************
> * Function: eds_clm_cluster_track_cbk
> *
> @@ -700,8 +737,14 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> **************************************************************************/
>
> void eds_clm_cluster_track_cbk(
> - const SaClmClusterNotificationBufferT *notificationBuffer,
> - SaUint32T numberOfMembers, SaAisErrorT error)
> +const SaClmClusterNotificationBufferT_4 *notificationBuffer,
> +SaUint32T numberOfMembers,
> +SaInvocationT invocation,
> +const SaNameT *rootCauseEntity,
> +const SaNtfCorrelationIdsT *correlationIds,
> +SaClmChangeStepT step,
> +SaTimeT timeSupervision,
> +SaAisErrorT error)
> {
> EDS_CB *cb = NULL;
> NODE_ID node_id;
> diff --git a/src/evt/evtd/eds_amf.h b/src/evt/evtd/eds_amf.h
> index 8b0b7b0a0..e9aeaa6c6 100644
> --- a/src/evt/evtd/eds_amf.h
> +++ b/src/evt/evtd/eds_amf.h
> @@ -81,9 +81,16 @@ void eds_amf_csi_rmv_callback(SaInvocationT invocation,
> const SaNameT *compName,
> uint32_t eds_amf_register(EDS_CB *);
>
> SaAisErrorT eds_clm_init(EDS_CB *cb);
> +SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb);
> void eds_clm_cluster_track_cbk(
> - const SaClmClusterNotificationBufferT *notificationBuffer,
> - SaUint32T numberOfMembers, SaAisErrorT error);
> +const SaClmClusterNotificationBufferT_4 *notificationBuffer,
> +SaUint32T numberOfMembers,
> +SaInvocationT invocation,
> +const SaNameT *rootCauseEntity,
> +const SaNtfCorrelationIdsT *correlationIds,
> +SaClmChangeStepT step,
> +SaTimeT timeSupervision,
> +SaAisErrorT error);
> void send_clm_status_change(EDS_CB *cb, SaClmClusterChangesT
> cluster_change,
> NODE_ID node_id);
>
> diff --git a/src/evt/evtd/eds_cb.c b/src/evt/evtd/eds_cb.c
> index ab5dee3c7..568d356d8 100644
> --- a/src/evt/evtd/eds_cb.c
> +++ b/src/evt/evtd/eds_cb.c
> @@ -273,7 +273,11 @@ void eds_main_process(SYSF_MBX *mbx)
> if (fds[FD_CLM].revents & POLLIN) {
> /* dispatch all the AMF pending callbacks */
> error = saClmDispatch(eds_cb->clm_hdl, SA_DISPATCH_ALL);
> -if (error != SA_AIS_OK)
> +if (error == SA_AIS_ERR_BAD_HANDLE) {
> +LOG_ER("saClmDispatch bad handle");
> +eds_cb->clm_sel_obj = -1;
> +eds_clm_reinit_bg(eds_cb);
> +} else if (error != SA_AIS_OK)
> LOG_ER("CLM Dispatch failed with rc = %d",
> error);
> }
> --
> 2.20.1
>
>
> ------------------------------
> Notice: This e-mail together with any attachments may contain information
> of Ribbon Communications Inc. that is confidential and/or proprietary for
> the sole use of the intended recipient. Any review, disclosure, reliance or
> distribution by others or forwarding without express permission is strictly
> prohibited. If you are not the intended recipient, please notify the sender
> immediately and then delete all copies, including any attachments.
> ------------------------------
>

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

Reply via email to