When the sending notification request come to NTFD , they are put in the mbx
to wait for being processed. if client of these request is down (MDS_DEST of 
this client
is disconnected), MDS thread receive the event down and also put to mbx. The 
priority
of event down and send request are the same. So NTF will process the send 
request
before the event down.

The patch fix to NTFD will not send the response of request if the MDS_DEST of 
client has
already disconnected.
---
 src/ntf/ntfd/NtfAdmin.cc  |  1 +
 src/ntf/ntfd/NtfClient.cc | 20 +++++++++++++-------
 src/ntf/ntfd/NtfClient.h  |  3 ++-
 src/ntf/ntfd/ntfs_mds.c   |  8 ++++----
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/ntf/ntfd/NtfAdmin.cc b/src/ntf/ntfd/NtfAdmin.cc
index 2cb99457c..d0bb50733 100644
--- a/src/ntf/ntfd/NtfAdmin.cc
+++ b/src/ntf/ntfd/NtfAdmin.cc
@@ -1048,6 +1048,7 @@ uint32_t NtfAdmin::send_cluster_membership_msg_to_clients(
   ClientMap::iterator pos;
   for (pos = clientMap.begin(); pos != clientMap.end(); pos++) {
     NtfClient *client = pos->second;
+    if (client->GetClientDownFlag() == true) continue;
     client_id = client->getClientId();
     mds_dest = client->getMdsDest();
     NODE_ID tmp_node_id = m_NTFS_GET_NODE_ID_FROM_ADEST(mds_dest);
diff --git a/src/ntf/ntfd/NtfClient.cc b/src/ntf/ntfd/NtfClient.cc
index 6393a3617..57e591f04 100644
--- a/src/ntf/ntfd/NtfClient.cc
+++ b/src/ntf/ntfd/NtfClient.cc
@@ -180,7 +180,7 @@ void NtfClient::notificationReceived(unsigned int clientId,
       notification->storeMatchingSubscription(
           clientId_, subscription->getSubscriptionId());
       // if active, send out the notification
-      if (activeController()) {
+      if (activeController() && client_down_flag_ == false) {
         subscription->sendNotification(notification, this);
       }
     } else {
@@ -279,7 +279,7 @@ void NtfClient::sendNotConfirmedNotification(
     NtfSmartPtr notification, SaNtfSubscriptionIdT subscriptionId) {
   TRACE_ENTER();
   // if active, send out the notification
-  if (activeController()) {
+  if (activeController() && client_down_flag_ == false) {
     SubscriptionMap::iterator pos;
     pos = subscriptionMap.find(subscriptionId);
     if (pos != subscriptionMap.end()) {
@@ -305,7 +305,8 @@ void NtfClient::confirmNtfSubscribe(SaNtfSubscriptionIdT 
subscriptionId,
       "NtfClient::confirmNtfSubscribe subscribe_res_lib called, "
       "client %u, subscription %u",
       clientId_, subscriptionId);
-  subscribe_res_lib(SA_AIS_OK, subscriptionId, mdsDest_, mds_ctxt);
+  if (client_down_flag_ == false)
+    subscribe_res_lib(SA_AIS_OK, subscriptionId, mdsDest_, mds_ctxt);
 }
 
 /**
@@ -321,7 +322,8 @@ void NtfClient::confirmNtfUnsubscribe(SaNtfSubscriptionIdT 
subscriptionId,
       "NtfClient::confirmNtfUnsubscribe unsubscribe_res_lib called,"
       " client %u, subscription %u",
       clientId_, subscriptionId);
-  unsubscribe_res_lib(SA_AIS_OK, subscriptionId, mdsDest_, mdsCtxt);
+  if (client_down_flag_ == false)
+    unsubscribe_res_lib(SA_AIS_OK, subscriptionId, mdsDest_, mdsCtxt);
 }
 
 /**
@@ -335,17 +337,20 @@ void 
NtfClient::confirmNtfUnsubscribe(SaNtfSubscriptionIdT subscriptionId,
 void NtfClient::confirmNtfNotification(SaNtfIdentifierT notificationId,
                                        MDS_SYNC_SND_CTXT* mdsCtxt,
                                        MDS_DEST mdsDest) {
-  notfication_result_lib(SA_AIS_OK, notificationId, mdsCtxt, mdsDest);
+  if (client_down_flag_ == false)
+    notfication_result_lib(SA_AIS_OK, notificationId, mdsCtxt, mdsDest);
 }
 
 void NtfClient::newReaderResponse(SaAisErrorT* error, unsigned int readerId,
                                   MDS_SYNC_SND_CTXT* mdsCtxt) {
-  new_reader_res_lib(*error, readerId, mdsDest_, mdsCtxt);
+  if (client_down_flag_ == false)
+    new_reader_res_lib(*error, readerId, mdsDest_, mdsCtxt);
 }
 
 void NtfClient::readNextResponse(SaAisErrorT* error, NtfSmartPtr& notification,
                                  MDS_SYNC_SND_CTXT* mdsCtxt) {
   TRACE_ENTER();
+  if (client_down_flag_ == true) return;
   if (*error == SA_AIS_OK) {
     read_next_res_lib(*error, notification->sendNotInfo_, mdsDest_, mdsCtxt);
   } else {
@@ -356,7 +361,8 @@ void NtfClient::readNextResponse(SaAisErrorT* error, 
NtfSmartPtr& notification,
 
 void NtfClient::deleteReaderResponse(SaAisErrorT* error,
                                      MDS_SYNC_SND_CTXT* mdsCtxt) {
-  delete_reader_res_lib(*error, mdsDest_, mdsCtxt);
+  if (client_down_flag_ == false)
+    delete_reader_res_lib(*error, mdsDest_, mdsCtxt);
 }
 
 NtfReader* NtfClient::createReaderWithoutFilter(ntfsv_reader_init_req_t rp,
diff --git a/src/ntf/ntfd/NtfClient.h b/src/ntf/ntfd/NtfClient.h
index 87921246f..76c708d4a 100644
--- a/src/ntf/ntfd/NtfClient.h
+++ b/src/ntf/ntfd/NtfClient.h
@@ -22,6 +22,7 @@
 #ifndef NTF_NTFD_NTFCLIENT_H_
 #define NTF_NTFD_NTFCLIENT_H_
 
+#include <atomic>
 #include "ntf/ntfd/NtfSubscription.h"
 #include "ntf/ntfd/NtfNotification.h"
 #include "ntf/ntfd/NtfReader.h"
@@ -86,7 +87,7 @@ class NtfClient {
   SaVersionT safVersion_;
 
   // The flag to indicate that the client down and is going to deleted
-  bool client_down_flag_;
+  std::atomic<bool> client_down_flag_;
 
   typedef std::map<SaNtfSubscriptionIdT, NtfSubscription *> SubscriptionMap;
   SubscriptionMap subscriptionMap;
diff --git a/src/ntf/ntfd/ntfs_mds.c b/src/ntf/ntfd/ntfs_mds.c
index a4b4a5f09..8594db674 100644
--- a/src/ntf/ntfd/ntfs_mds.c
+++ b/src/ntf/ntfd/ntfs_mds.c
@@ -947,10 +947,10 @@ static uint32_t mds_svc_event(struct ncsmds_callback_info 
*info)
                        // Set flag for client down at standby node then ntfd
                        // just removes only the downed clients. This is helpful
                        // in some cases ntfd receives this event after
-                       // checkpoint of initializing new client
-                       if (ntfs_cb->ha_state == SA_AMF_HA_STANDBY) {
-                               SetClientsDownFlag(evt->fr_dest);
-                       }
+                       // checkpoint of initializing new client in standby or
+                       // checking if client is downed in active.
+
+                       SetClientsDownFlag(evt->fr_dest);
 
                        /* Push the event and we are done */
                        if (m_NCS_IPC_SEND(&ntfs_cb->mbx, evt,
-- 
2.15.1



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

Reply via email to