"Fossies" - the Fresh Open Source Software Archive

Member "opensaf-5.21.09/src/ntf/ntfd/ntfs_evt.c" (14 Sep 2021, 23019 Bytes) of package /linux/misc/opensaf-5.21.09.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ntfs_evt.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.21.06_vs_5.21.09.

    1 /*      -*- OpenSAF  -*-
    2  *
    3  * (C) Copyright 2008 The OpenSAF Foundation
    4  *
    5  * This program is distributed in the hope that it will be useful, but
    6  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    7  * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
    8  * under the GNU Lesser General Public License Version 2.1, February 1999.
    9  * The complete license can be accessed from the following location:
   10  * http://opensource.org/licenses/lgpl-license.php
   11  * See the Copying file included with the OpenSAF distribution for full
   12  * licensing terms.
   13  *
   14  * Author(s): Ericsson AB
   15  *
   16  */
   17 #include "ntfs_com.h"
   18 #include <stdlib.h>
   19 #include <alloca.h>
   20 #include <time.h>
   21 #include <limits.h>
   22 #include "ntfs.h"
   23 #include "ntf/common/ntfsv_enc_dec.h"
   24 #include "base/osaf_extended_name.h"
   25 #include "ntfs_imcnutil.h"
   26 #include "osaf/saflog/saflog.h"
   27 
   28 #define m_NTFSV_FILL_ASYNC_UPDATE_FINALIZE(ckpt, client_id)                    \
   29     {                                                                      \
   30         ckpt.header.ckpt_rec_type = NTFS_CKPT_FINALIZE_REC;            \
   31         ckpt.header.num_ckpt_records = 1;                              \
   32         ckpt.header.data_len = 1;                                      \
   33         ckpt.ckpt_rec.finalize_rec.client_id = client_id;              \
   34     }
   35 
   36 static uint32_t process_api_evt(ntfsv_ntfs_evt_t *evt);
   37 static uint32_t proc_ntfa_updn_mds_msg(ntfsv_ntfs_evt_t *evt);
   38 static uint32_t proc_mds_quiesced_ack_msg(ntfsv_ntfs_evt_t *evt);
   39 static uint32_t proc_initialize_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   40 static uint32_t proc_finalize_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   41 static uint32_t proc_subscribe_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   42 static uint32_t proc_unsubscribe_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   43 static uint32_t proc_send_not_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   44 static uint32_t proc_reader_initialize_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   45 static uint32_t proc_reader_initialize_msg_2(ntfs_cb_t *,
   46                          ntfsv_ntfs_evt_t *evt);
   47 static uint32_t proc_reader_finalize_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   48 static uint32_t proc_read_next_msg(ntfs_cb_t *, ntfsv_ntfs_evt_t *evt);
   49 
   50 static int ntf_version_is_valid(SaVersionT *ver)
   51 {
   52     /* TODO: remove after upgrade to version A.02.01 */
   53     /* To be backward compatible during upgrade due to ticket (#544)(#634)
   54      */
   55     const SaVersionT alloved_ver = {'A', 0x02, 0x01};
   56     if (ver->releaseCode == alloved_ver.releaseCode &&
   57         ver->minorVersion == alloved_ver.minorVersion &&
   58         ver->majorVersion == alloved_ver.majorVersion)
   59         return 1;
   60 
   61     return ((ver->releaseCode == NTF_RELEASE_CODE) &&
   62         (0 < ver->majorVersion) &&
   63         (ver->majorVersion <= NTF_MAJOR_VERSION));
   64 }
   65 
   66 static const NTFSV_NTFS_EVT_HANDLER
   67     ntfs_ntfsv_top_level_evt_dispatch_tbl[NTFSV_NTFS_EVT_MAX] = {
   68     NULL, process_api_evt, proc_ntfa_updn_mds_msg, proc_ntfa_updn_mds_msg,
   69     proc_mds_quiesced_ack_msg};
   70 
   71 /* Dispatch table for NTFA_API realted messages */
   72 static const NTFSV_NTFS_NTFA_API_MSG_HANDLER
   73     ntfs_ntfa_api_msg_dispatcher[NTFSV_API_MAX] = {
   74     NULL,
   75     proc_initialize_msg,
   76     proc_finalize_msg,
   77     proc_subscribe_msg,
   78     proc_unsubscribe_msg,
   79     proc_send_not_msg,
   80     proc_reader_initialize_msg,
   81     proc_reader_finalize_msg,
   82     proc_read_next_msg,
   83     proc_reader_initialize_msg_2,
   84 };
   85 
   86 /****************************************************************************
   87  * Name          : proc_ntfa_updn_mds_msg
   88  *
   89  * Description   : This is the function which is called when ntfs receives any
   90  *                 a NTFA UP/DN message via MDS subscription.
   91  *
   92  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
   93  *
   94  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
   95  *
   96  * Notes         : None.
   97  *****************************************************************************/
   98 
   99 static uint32_t proc_ntfa_updn_mds_msg(ntfsv_ntfs_evt_t *evt)
  100 {
  101     TRACE_ENTER();
  102 
  103     switch (evt->evt_type) {
  104     case NTFSV_NTFS_EVT_NTFA_UP:
  105         break;
  106     case NTFSV_NTFS_EVT_NTFA_DOWN:
  107         // Remove the clients belong to the ntfa down with MDS_DEST
  108         if (ntfs_cb->ha_state == SA_AMF_HA_STANDBY) {
  109             ClientsDownRemoved(evt->fr_dest);
  110         } else {
  111             clientRemoveMDS(evt->fr_dest);
  112         }
  113     if (evt->internal_event == true) {
  114       // Internal down generated event in case of discarded ntf
  115       TRACE("Sending async update to standby");
  116       ntfsv_ckpt_msg_t ckpt;
  117       memset(&ckpt, 0, sizeof(ckpt));
  118       ckpt.header.ckpt_rec_type = NTFS_CKPT_AGENT_DOWN;
  119       ckpt.header.num_ckpt_records = 1;
  120       ckpt.header.data_len = 0;
  121       ckpt.ckpt_rec.agent_dest = evt->fr_dest;
  122       update_standby(&ckpt, NCS_MBCSV_ACT_RMV);
  123     }
  124 
  125         break;
  126     default:
  127         TRACE("Unknown evt type!!!");
  128         break;
  129     }
  130 
  131     TRACE_LEAVE();
  132     return NCSCC_RC_SUCCESS;
  133 }
  134 
  135 /****************************************************************************
  136  * Name          : proc_mds_quiesced_ack_msg
  137  *
  138  * Description   : This is the function which is called when ntfs receives an
  139  *                       quiesced ack event from MDS
  140  *
  141  * Arguments     : evt  - Message that was posted to the NTFS Mail box.
  142  *
  143  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  144  *
  145  * Notes         : None.
  146  *****************************************************************************/
  147 static uint32_t proc_mds_quiesced_ack_msg(ntfsv_ntfs_evt_t *evt)
  148 {
  149     TRACE_ENTER();
  150     if (ntfs_cb->is_quisced_set == true) {
  151         ntfs_cb->ha_state = SA_AMF_HA_QUIESCED;
  152         /* Inform MBCSV of HA state change */
  153         if (ntfs_mbcsv_change_HA_state(ntfs_cb, ntfs_cb->ha_state) !=
  154             NCSCC_RC_SUCCESS)
  155             TRACE("ntfs_mbcsv_change_HA_state FAILED");
  156 
  157         /* Update control block */
  158         saAmfResponse(ntfs_cb->amf_hdl, ntfs_cb->amf_invocation_id,
  159                   SA_AIS_OK);
  160         ntfs_cb->is_quisced_set = false;
  161     }
  162     TRACE_LEAVE();
  163     return NCSCC_RC_SUCCESS;
  164 }
  165 
  166 /****************************************************************************
  167  * Name          : proc_rda_cb_msg
  168  *
  169  * Description   : This function processes the role change message from RDE.
  170  *                 It will change role to active if requested to.
  171  *
  172  * Arguments     : evt  - Message that was posted to the NTFS Mail box.
  173  *
  174  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  175  *
  176  * Notes         : None.
  177  *****************************************************************************/
  178 static uint32_t proc_rda_cb_msg(ntfsv_ntfs_evt_t *evt)
  179 {
  180     uint32_t rc;
  181 
  182     TRACE_ENTER2("%d", (int)evt->info.rda_info.io_role);
  183     if ((rc = initialize_for_assignment(
  184          ntfs_cb, (SaAmfHAStateT)evt->info.rda_info.io_role)) !=
  185         NCSCC_RC_SUCCESS) {
  186         LOG_ER("initialize_for_assignment FAILED %u", (unsigned)rc);
  187         exit(EXIT_FAILURE);
  188     }
  189 
  190     if (evt->info.rda_info.io_role == PCS_RDA_ACTIVE &&
  191         ntfs_cb->ha_state != SA_AMF_HA_ACTIVE) {
  192         SaAmfHAStateT old_ha_state = ntfs_cb->ha_state;
  193         LOG_NO("ACTIVE request");
  194 
  195         ntfs_cb->mds_role = V_DEST_RL_ACTIVE;
  196         if ((rc = ntfs_mds_change_role()) != NCSCC_RC_SUCCESS) {
  197             LOG_ER("ntfs_mds_change_role FAILED %u", rc);
  198             goto done;
  199         }
  200 
  201         ntfs_cb->ha_state = SA_AMF_HA_ACTIVE;
  202         if ((rc = ntfs_mbcsv_change_HA_state(
  203              ntfs_cb, ntfs_cb->ha_state)) != NCSCC_RC_SUCCESS) {
  204             LOG_ER("ntfs_mbcsv_change_HA_state FAILED %u", rc);
  205             goto done;
  206         }
  207 
  208         if (old_ha_state == SA_AMF_HA_STANDBY) {
  209             /* check for unsent notifictions and if notifiction is
  210              * not logged */
  211             checkNotificationList();
  212         }
  213     }
  214 
  215     rc = NCSCC_RC_SUCCESS;
  216 
  217 done:
  218     TRACE_LEAVE();
  219     return rc;
  220 }
  221 
  222 /****************************************************************************
  223  * Name          : ntfs_cb_init
  224  *
  225  * Description   : This function initializes the NTFS_CB including the
  226  *                 Patricia trees.
  227  *
  228  *
  229  * Arguments     : ntfs_cb * - Pointer to the NTFS_CB.
  230  *
  231  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
  232  *
  233  * Notes         : None.
  234  *****************************************************************************/
  235 uint32_t ntfs_cb_init(ntfs_cb_t *ntfs_cb)
  236 {
  237     char *tmp;
  238     TRACE_ENTER();
  239     ntfs_cb->ntf_version.releaseCode = NTF_RELEASE_CODE;
  240     ntfs_cb->ntf_version.majorVersion = NTF_MAJOR_VERSION;
  241     ntfs_cb->ntf_version.minorVersion = NTF_MINOR_VERSION;
  242     ntfs_cb->amfSelectionObject = -1;
  243     ntfs_cb->logSelectionObject = -1;
  244     ntfs_cb->ha_state = NTFS_HA_INIT_STATE;
  245     ntfs_cb->mbcsv_sel_obj = -1;
  246     ntfs_cb->fully_initialized = false;
  247     ntfs_cb->clm_hdl = 0;
  248     ntfs_cb->clm_initialized = false;
  249     ntfs_cb->clmSelectionObject = -1;
  250 
  251     tmp = (char *)getenv("NTFSV_ENV_CACHE_SIZE");
  252     if (tmp) {
  253         ntfs_cb->cache_size = (unsigned int)atoi(tmp);
  254         TRACE("NTFSV_ENV_CACHE_SIZE configured value: %u",
  255               ntfs_cb->cache_size);
  256     } else {
  257         ntfs_cb->cache_size = NTFSV_READER_CACHE_DEFAULT;
  258     }
  259     TRACE_LEAVE();
  260     return NCSCC_RC_SUCCESS;
  261 }
  262 
  263 void update_standby(ntfsv_ckpt_msg_t *ckpt, uint32_t action)
  264 {
  265     uint32_t async_rc = NCSCC_RC_SUCCESS;
  266 
  267     if (ntfs_cb->ha_state == SA_AMF_HA_ACTIVE) {
  268         async_rc = ntfs_send_async_update(ntfs_cb, ckpt, action);
  269         if (async_rc != NCSCC_RC_SUCCESS)
  270             TRACE("send_async_update FAILED");
  271     }
  272 }
  273 
  274 /**
  275  * Handle a initialize message
  276  * @param cb
  277  * @param evt
  278  *
  279  * @return uns32
  280  */
  281 static uint32_t proc_initialize_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  282 {
  283     uint32_t rc = NCSCC_RC_SUCCESS;
  284     SaAisErrorT ais_rc = SA_AIS_OK;
  285     SaVersionT *version;
  286 
  287     TRACE_ENTER2("dest %" PRIx64, evt->fr_dest);
  288 
  289     /* Validate the version */
  290     version = &(evt->info.msg.info.api_info.param.init.version);
  291     if (!ntf_version_is_valid(version)) {
  292         ais_rc = SA_AIS_ERR_VERSION;
  293         TRACE("version FAILED");
  294         client_added_res_lib(ais_rc, 0, evt->fr_dest, &evt->mds_ctxt,
  295                      version);
  296         goto done;
  297     }
  298     // Do not initialize, if node of client is not CLM member.
  299     if (is_client_clm_member(evt->fr_node_id, version) == false) {
  300         ais_rc = SA_AIS_ERR_UNAVAILABLE;
  301         TRACE("New client node is not CLM member.");
  302         client_added_res_lib(ais_rc, 0, evt->fr_dest, &evt->mds_ctxt,
  303                      version);
  304         goto done;
  305     }
  306     clientAdded(0, evt->fr_dest, &evt->mds_ctxt, version);
  307 
  308 done:
  309     TRACE_LEAVE();
  310     return rc;
  311 }
  312 
  313 /**
  314  * Handle an finalize message
  315  * @param cb
  316  * @param evt
  317  *
  318  * @return uns32
  319  */
  320 static uint32_t proc_finalize_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  321 {
  322     uint32_t client_id =
  323         evt->info.msg.info.api_info.param.finalize.client_id;
  324 
  325     TRACE_ENTER2("client_id %u", client_id);
  326     clientRemoved(client_id);
  327     client_removed_res_lib(SA_AIS_OK, client_id, evt->fr_dest,
  328                    &evt->mds_ctxt);
  329     TRACE_LEAVE();
  330     return NCSCC_RC_SUCCESS;
  331 }
  332 
  333 /****************************************************************************
  334  * Name          : proc_subscribe_msg
  335  *
  336  * Description   : This is the function which is called when ntfs receives a
  337  *                 subscribe message.
  338  *
  339  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
  340  *
  341  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  342  *
  343  * Notes         : None.
  344  *****************************************************************************/
  345 
  346 static uint32_t proc_subscribe_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  347 {
  348     uint32_t rc = NCSCC_RC_SUCCESS;
  349 
  350     TRACE_ENTER();
  351     ntfsv_subscribe_req_t *subscribe_param =
  352         &(evt->info.msg.info.api_info.param.subscribe);
  353 
  354     // This may be a queued request, first verify CLM membership status of
  355     // client node.
  356     if (is_stale_client(subscribe_param->client_id) == true) {
  357         TRACE_5("Client node is not CLM member.");
  358         subscribe_res_lib(SA_AIS_ERR_UNAVAILABLE,
  359                   subscribe_param->subscriptionId, evt->fr_dest,
  360                   &evt->mds_ctxt);
  361         TRACE_LEAVE();
  362         return rc;
  363     }
  364 
  365     TRACE_4("subscriptionId: %u", subscribe_param->subscriptionId);
  366     subscriptionAdded(*subscribe_param, &evt->mds_ctxt);
  367 
  368     TRACE_LEAVE();
  369     return rc;
  370 }
  371 
  372 /**
  373  * Handle a unsubscribe message
  374  * @param cb
  375  * @param evt
  376  *
  377  * @return uns32
  378  */
  379 static uint32_t proc_unsubscribe_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  380 {
  381     uint32_t rc = NCSCC_RC_SUCCESS;
  382 
  383     ntfsv_unsubscribe_req_t *param =
  384         &(evt->info.msg.info.api_info.param.unsubscribe);
  385 
  386     TRACE_ENTER2("client_id %u, subscriptionId %u", param->client_id,
  387              param->subscriptionId);
  388 
  389     // This may be a queued request, first verify CLM membership status of
  390     // client node.
  391     if (is_stale_client(param->client_id) == true) {
  392         TRACE_5("Client node is not CLM member.");
  393         unsubscribe_res_lib(SA_AIS_ERR_UNAVAILABLE,
  394                     param->subscriptionId, evt->fr_dest,
  395                     &evt->mds_ctxt);
  396         TRACE_LEAVE();
  397         return rc;
  398     }
  399 
  400     subscriptionRemoved(param->client_id, param->subscriptionId,
  401                 &evt->mds_ctxt);
  402     TRACE_LEAVE();
  403     return rc;
  404 }
  405 
  406 static void print_header(SaNtfNotificationHeaderT *notificationHeader)
  407 {
  408     SaTimeT totalTime;
  409     SaTimeT ntfTime = (SaTimeT)0;
  410     char time_str[24];
  411     struct tm *tstamp_data, tm_info;
  412 
  413     /* Event type */
  414     TRACE_1("eventType = %d", (int)*notificationHeader->eventType);
  415 
  416     /* Notification Object */
  417     TRACE_1(
  418         "notificationObject.length = %zu\n",
  419         osaf_extended_name_length(notificationHeader->notificationObject));
  420 
  421     /* Notifying Object */
  422     TRACE_1("notifyingObject->length = %zu\n",
  423         osaf_extended_name_length(notificationHeader->notifyingObject));
  424 
  425     /* Notification Class ID */
  426     TRACE_1("VendorID = %d\nmajorID = %d\nminorID = %d\n",
  427         notificationHeader->notificationClassId->vendorId,
  428         notificationHeader->notificationClassId->majorId,
  429         notificationHeader->notificationClassId->minorId);
  430 
  431     /* Event Time */
  432     ntfTime = *notificationHeader->eventTime;
  433 
  434     totalTime = (ntfTime / (SaTimeT)SA_TIME_ONE_SECOND);
  435     tzset();
  436     tstamp_data = localtime_r((const time_t *)&totalTime, &tm_info);
  437     osafassert(tstamp_data);
  438 
  439     (void)strftime(time_str, sizeof(time_str), "%d-%m-%Y %T", tstamp_data);
  440 
  441     TRACE_1("eventTime = %lld = %s\n", (SaTimeT)ntfTime, time_str);
  442 
  443     /* Notification ID */
  444     TRACE_1("notificationID = %llu\n", *notificationHeader->notificationId);
  445 
  446     /* Length of Additional text */
  447     TRACE_1("lengthadditionalText = %d\n",
  448         notificationHeader->lengthAdditionalText);
  449 
  450     /* Additional text */
  451     TRACE_1("additionalText = %s\n", notificationHeader->additionalText);
  452 }
  453 
  454 /****************************************************************************
  455  * Name          : proc_send_not_msg
  456  *
  457  * Description   : This is the function which is called when ntfs receives a
  458  *                 NTFSV_SEND_NOT_REQ message.
  459  *
  460  * Arguments     : msg  - Message that was posted to the Mail box.
  461  *
  462  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  463  *
  464  * Notes         : None.
  465  *****************************************************************************/
  466 static uint32_t proc_send_not_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  467 {
  468     uint32_t rc = NCSCC_RC_SUCCESS;
  469 
  470     TRACE_ENTER();
  471     ntfsv_send_not_req_t *param =
  472         evt->info.msg.info.api_info.param.send_notification;
  473 
  474     // This may be a queued request, first verify CLM membership status of
  475     // client node.
  476     if (is_stale_client(param->client_id) == true) {
  477         TRACE_5("Client node is not CLM member.");
  478         notfication_result_lib(SA_AIS_ERR_UNAVAILABLE, 0,
  479                        &evt->mds_ctxt, evt->fr_dest);
  480         TRACE_LEAVE();
  481         return rc;
  482     }
  483     if (param->notificationType == SA_NTF_TYPE_ALARM) {
  484         print_header(&param->notification.alarm.notificationHeader);
  485     }
  486     notificationReceived(param->client_id, param->notificationType, param,
  487                  &evt->mds_ctxt);
  488 
  489     /* The allocated resources in ntfsv_enc_dec.c is freed in the destructor
  490      * in NtfNotification */
  491     TRACE_LEAVE();
  492     return rc;
  493 }
  494 
  495 /****************************************************************************
  496  * Name          : proc_reader_initialize_msg
  497  *
  498  * Description   : This is the function which is called when ntfs receives a
  499  *                 reader_initialize message.
  500  *
  501  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
  502  *
  503  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  504  *
  505  * Notes         : None.
  506  *****************************************************************************/
  507 
  508 static uint32_t proc_reader_initialize_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  509 {
  510     uint32_t rc = NCSCC_RC_SUCCESS;
  511 
  512     TRACE_ENTER();
  513     ntfsv_reader_init_req_t *reader_initialize_param =
  514         &(evt->info.msg.info.api_info.param.reader_init);
  515 
  516     // This may be a queued request, first verify CLM membership status of
  517     // client node.
  518     if (is_stale_client(reader_initialize_param->client_id) == true) {
  519         TRACE_5("Client node is not CLM member.");
  520         new_reader_res_lib(SA_AIS_ERR_UNAVAILABLE, 0, evt->fr_dest,
  521                    &evt->mds_ctxt);
  522         TRACE_LEAVE();
  523         return rc;
  524     }
  525 
  526     TRACE_4("client_id: %u", reader_initialize_param->client_id);
  527     createReaderWithoutFilter(*reader_initialize_param, &evt->mds_ctxt);
  528 
  529     TRACE_LEAVE();
  530     return rc;
  531 }
  532 
  533 /****************************************************************************
  534  * Name          : proc_reader_initialize_msg_2
  535  *
  536  * Description   : This is the function which is called when ntfs receives a
  537  *                 reader_initialize message. The reader_initialize_msg_2
  538  *                 includes filter.
  539  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
  540  *
  541  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  542  *
  543  * Notes         : None.
  544  *****************************************************************************/
  545 
  546 static uint32_t proc_reader_initialize_msg_2(ntfs_cb_t *cb,
  547                          ntfsv_ntfs_evt_t *evt)
  548 {
  549     uint32_t rc = NCSCC_RC_SUCCESS;
  550 
  551     TRACE_ENTER();
  552     ntfsv_reader_init_req_2_t *rp =
  553         &(evt->info.msg.info.api_info.param.reader_init_2);
  554 
  555     TRACE_4("client_id: %u", rp->head.client_id);
  556 
  557     // This may be a queued request, first verify CLM membership status of
  558     // client node.
  559     if (is_stale_client(rp->head.client_id) == true) {
  560         TRACE_5("Client node is not CLM member.");
  561         new_reader_res_lib(SA_AIS_ERR_UNAVAILABLE, 0, evt->fr_dest,
  562                    &evt->mds_ctxt);
  563         TRACE_LEAVE();
  564         return rc;
  565     }
  566 
  567     createReaderWithFilter(*rp, &evt->mds_ctxt);
  568     TRACE_LEAVE();
  569     return rc;
  570 }
  571 
  572 /****************************************************************************
  573  * Name          : proc_reader_finalize_msg
  574  *
  575  * Description   : This is the function which is called when ntfs receives a
  576  *                 reader_finalize message.
  577  *
  578  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
  579  *
  580  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  581  *
  582  * Notes         : None.
  583  *****************************************************************************/
  584 
  585 static uint32_t proc_reader_finalize_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  586 {
  587     uint32_t rc = NCSCC_RC_SUCCESS;
  588 
  589     TRACE_ENTER();
  590     ntfsv_reader_finalize_req_t *reader_finalize_param =
  591         &(evt->info.msg.info.api_info.param.reader_finalize);
  592 
  593     // This may be a queued request, first verify CLM membership status of
  594     // client node.
  595     if (is_stale_client(reader_finalize_param->client_id) == true) {
  596         TRACE_5("Client node is not CLM member.");
  597         delete_reader_res_lib(SA_AIS_ERR_UNAVAILABLE, evt->fr_dest,
  598                       &evt->mds_ctxt);
  599         TRACE_LEAVE();
  600         return rc;
  601     }
  602 
  603     TRACE_4("client_id: %u", reader_finalize_param->client_id);
  604     deleteReader(*reader_finalize_param, &evt->mds_ctxt);
  605 
  606     /*  if (ais_rv == SA_AIS_OK) */
  607     /*  { */
  608     /*     async_rc = ntfs_subscription_initialize_async_update(cb, */
  609     /*                                                  reader_finalize_param);*/
  610     /*     if (async_rc != NCSCC_RC_SUCCESS) */
  611     /*        TRACE("ntfs_send_reader_finalize_async_update failed"); */
  612     /*  } */
  613     TRACE_LEAVE();
  614     return rc;
  615 }
  616 
  617 /****************************************************************************
  618  * Name          : proc_read_next_msg
  619  *
  620  * Description   : This is the function which is called when ntfs receives a
  621  *                 read_next message.
  622  *
  623  * Arguments     : msg  - Message that was posted to the NTFS Mail box.
  624  *
  625  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  626  *
  627  * Notes         : None.
  628  *****************************************************************************/
  629 
  630 static uint32_t proc_read_next_msg(ntfs_cb_t *cb, ntfsv_ntfs_evt_t *evt)
  631 {
  632     uint32_t rc = NCSCC_RC_SUCCESS;
  633 
  634     TRACE_ENTER();
  635     ntfsv_read_next_req_t *read_next_param =
  636         &(evt->info.msg.info.api_info.param.read_next);
  637 
  638     TRACE_4("client_id: %u", read_next_param->client_id);
  639 
  640     // This may be a queued request, first verify CLM membership status of
  641     // client node.
  642     if (is_stale_client(read_next_param->client_id) == true) {
  643         TRACE_5("Client node is not CLM member.");
  644         read_next_res_lib(SA_AIS_ERR_UNAVAILABLE, NULL, evt->fr_dest,
  645                   &evt->mds_ctxt);
  646         TRACE_LEAVE();
  647         return rc;
  648     }
  649 
  650     readNext(*read_next_param, &evt->mds_ctxt);
  651     /*  if (ais_rv == SA_AIS_OK) */
  652     /*  { */
  653     /*     async_rc = ntfs_subscription_initialize_async_update(cb, */
  654     /*                                                  read_next_param);*/
  655     /*     if (async_rc != NCSCC_RC_SUCCESS) */
  656     /*        TRACE("ntfs_send_read_next_async_update failed");          */
  657     /*  } */
  658     TRACE_LEAVE();
  659     return rc;
  660 }
  661 
  662 /****************************************************************************
  663  * Name          : process_api_evt
  664  *
  665  * Description   : This is the function which is called when ntfs receives an
  666  *                 event either because of an API Invocation or other internal
  667  *                 messages from NTFA clients
  668  *
  669  * Arguments     : evt  - Message that was posted to the NTFS Mail box.
  670  *
  671  * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
  672  *
  673  * Notes         : None.
  674  *****************************************************************************/
  675 static uint32_t process_api_evt(ntfsv_ntfs_evt_t *evt)
  676 {
  677     if (evt->evt_type == NTFSV_NTFS_NTFSV_MSG) {
  678         /* ignore one level... */
  679         if ((evt->info.msg.type >= NTFSV_NTFA_API_MSG) &&
  680             (evt->info.msg.type < NTFSV_MSG_MAX)) {
  681             if ((evt->info.msg.info.api_info.type >=
  682                  NTFSV_INITIALIZE_REQ) &&
  683                 (evt->info.msg.info.api_info.type <
  684                  NTFSV_API_MAX)) {
  685                 if (ntfs_ntfa_api_msg_dispatcher
  686                     [evt->info.msg.info.api_info.type](
  687                         ntfs_cb, evt) != NCSCC_RC_SUCCESS) {
  688                     TRACE_2(
  689                         "ntfs_ntfa_api_msg_dispatcher FAILED type: %d",
  690                         (int)evt->info.msg.type);
  691                 }
  692             }
  693         }
  694     }
  695     return NCSCC_RC_SUCCESS;
  696 }
  697 
  698 /****************************************************************************
  699  * Name          : ntfs_process_mbx
  700  *
  701  * Description   : This is the function which process the IPC mail box of
  702  *                 NTFS
  703  *
  704  * Arguments     : mbx  - This is the mail box pointer on which NTFS is
  705  *                        going to block.
  706  *
  707  * Return Values : None.
  708  *
  709  * Notes         : None.
  710  *****************************************************************************/
  711 void ntfs_process_mbx(SYSF_MBX *mbx)
  712 {
  713     ntfsv_ntfs_evt_t *msg;
  714 
  715     msg = (ntfsv_ntfs_evt_t *)m_NCS_IPC_NON_BLK_RECEIVE(mbx, msg);
  716     if (msg != NULL) {
  717         if (ntfs_cb->ha_state == SA_AMF_HA_ACTIVE) {
  718             if ((msg->evt_type >= NTFSV_NTFS_NTFSV_MSG) &&
  719                 (msg->evt_type <= NTFSV_NTFS_EVT_NTFA_DOWN)) {
  720                 ntfs_ntfsv_top_level_evt_dispatch_tbl
  721                     [msg->evt_type](msg);
  722             } else if (msg->evt_type == NTFSV_EVT_QUIESCED_ACK) {
  723                 proc_mds_quiesced_ack_msg(msg);
  724             } else
  725                 TRACE("message type invalid");
  726         } else {
  727             if (msg->evt_type == NTFSV_NTFS_EVT_NTFA_DOWN) {
  728                 ntfs_ntfsv_top_level_evt_dispatch_tbl
  729                     [msg->evt_type](msg);
  730             }
  731             if (msg->evt_type == NTFSV_EVT_RDA) {
  732                 proc_rda_cb_msg(msg);
  733             }
  734         }
  735 
  736         ntfs_evt_destroy(msg);
  737     }
  738 }