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 | 16 ++++++++++------
src/ntf/ntfd/NtfAdmin.h | 2 +-
src/ntf/ntfd/NtfClient.cc | 26 +++++++++++++-------------
src/ntf/ntfd/NtfClient.h | 7 ++++---
src/ntf/ntfd/ntfs_com.h | 2 +-
src/ntf/ntfd/ntfs_mds.c | 7 +++----
6 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/src/ntf/ntfd/NtfAdmin.cc b/src/ntf/ntfd/NtfAdmin.cc
index 1ec79c5ec..944ba17a8 100644
--- a/src/ntf/ntfd/NtfAdmin.cc
+++ b/src/ntf/ntfd/NtfAdmin.cc
@@ -536,14 +536,17 @@ void NtfAdmin::ClientsDownRemoved(MDS_DEST mds_dest) {
}
/**
- * Set flag for the clients that belong to the ntfa down. This is set on mds
- * thread and the clients are removed in ntfd thread.
+ * Search all clients in client-map and set flag down for them that belong
+ * to the ntfa down. This is set on mds thread and the clients are removed
+ * in ntfd thread.
* Help to prevent the disorder of coming between NTFSV_NTFS_EVT_NTFA_DOWN
event
- * and checkpoint of NTFSV_NTFS_NTFSV_MSG requests. (Ticket #2705)
+ * and checkpoint of NTFSV_NTFS_NTFSV_MSG requests in standby(Ticket #2705).
+ * And also help to realize all clients have already downed then don't send the
+ * response to these clients.
*
* @param mds_dest
*/
-void NtfAdmin::SetClientsDownFlag(MDS_DEST mds_dest) {
+void NtfAdmin::SearchAndSetClientsDownFlag(MDS_DEST mds_dest) {
TRACE_ENTER();
osaf_mutex_lock_ordie(&client_down_mutex);
for (const auto &it : clientMap) {
@@ -1060,6 +1063,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);
@@ -1173,9 +1177,9 @@ void ClientsDownRemoved(MDS_DEST mds_dest) {
NtfAdmin::theNtfAdmin->ClientsDownRemoved(mds_dest);
}
-void SetClientsDownFlag(MDS_DEST mds_dest) {
+void SearchAndSetClientsDownFlag(MDS_DEST mds_dest) {
osafassert(NtfAdmin::theNtfAdmin != NULL);
- NtfAdmin::theNtfAdmin->SetClientsDownFlag(mds_dest);
+ NtfAdmin::theNtfAdmin->SearchAndSetClientsDownFlag(mds_dest);
}
void subscriptionRemoved(unsigned int clientId,
diff --git a/src/ntf/ntfd/NtfAdmin.h b/src/ntf/ntfd/NtfAdmin.h
index 6e7be8748..002cb4fd0 100644
--- a/src/ntf/ntfd/NtfAdmin.h
+++ b/src/ntf/ntfd/NtfAdmin.h
@@ -66,7 +66,7 @@ class NtfAdmin {
void clientRemoved(unsigned int clientId);
void clientRemoveMDS(MDS_DEST mds_dest);
void ClientsDownRemoved(MDS_DEST mds_dest);
- void SetClientsDownFlag(MDS_DEST mds_dest);
+ void SearchAndSetClientsDownFlag(MDS_DEST mds_dest);
void subscriptionRemoved(unsigned int clientId,
SaNtfSubscriptionIdT subscriptionId,
MDS_SYNC_SND_CTXT *mdsCtxt);
diff --git a/src/ntf/ntfd/NtfClient.cc b/src/ntf/ntfd/NtfClient.cc
index 6393a3617..994d7b4bd 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,
@@ -496,9 +502,3 @@ void NtfClient::set_client_version(SaVersionT* ver) {
safVersion_ = *ver; }
* @return ptr to SaVersionT.
*/
SaVersionT* NtfClient::getSafVersion() { return &safVersion_; }
-
-
-void NtfClient::SetClientDownFlag() { client_down_flag_ = true; }
-
-
-bool NtfClient::GetClientDownFlag() { return client_down_flag_;}
diff --git a/src/ntf/ntfd/NtfClient.h b/src/ntf/ntfd/NtfClient.h
index 87921246f..cffd51816 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"
@@ -68,8 +69,8 @@ class NtfClient {
bool IsA11Client() const;
void set_client_version(SaVersionT *ver);
SaVersionT *getSafVersion();
- void SetClientDownFlag();
- bool GetClientDownFlag();
+ void SetClientDownFlag() { client_down_flag_ = true; }
+ bool GetClientDownFlag() { return client_down_flag_;}
private:
void newReaderResponse(SaAisErrorT *error, unsigned int readerId,
@@ -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_com.h b/src/ntf/ntfd/ntfs_com.h
index 96f111a6f..b9e37da09 100644
--- a/src/ntf/ntfd/ntfs_com.h
+++ b/src/ntf/ntfd/ntfs_com.h
@@ -78,7 +78,7 @@ void notificationLoggedConfirmed(SaNtfIdentifierT
notificationId);
void clientRemoved(unsigned int clientId);
void clientRemoveMDS(MDS_DEST mds_dest);
void ClientsDownRemoved(MDS_DEST mds_dest);
-void SetClientsDownFlag(MDS_DEST mds_dest);
+void SearchAndSetClientsDownFlag(MDS_DEST mds_dest);
void subscriptionRemoved(unsigned int clientId,
SaNtfSubscriptionIdT subscriptionId,
MDS_SYNC_SND_CTXT *mdsCtxt);
diff --git a/src/ntf/ntfd/ntfs_mds.c b/src/ntf/ntfd/ntfs_mds.c
index a4b4a5f09..5f40c6e42 100644
--- a/src/ntf/ntfd/ntfs_mds.c
+++ b/src/ntf/ntfd/ntfs_mds.c
@@ -947,10 +947,9 @@ 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 has already downed in active.
+ SearchAndSetClientsDownFlag(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
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel