osaf/libs/core/include/nid_api.h | 3 +-
osaf/libs/core/leap/nid_api.c | 64 ++++-----------------------------------
2 files changed, 8 insertions(+), 59 deletions(-)
Add a protection mechanism so that a service can only respond to NID once, even
if it calls nid_notify() multiple times.
diff --git a/osaf/libs/core/include/nid_api.h b/osaf/libs/core/include/nid_api.h
--- a/osaf/libs/core/include/nid_api.h
+++ b/osaf/libs/core/include/nid_api.h
@@ -64,8 +64,7 @@ typedef struct nid_fifo_msg {
/**********************************************************************
* Exported finctions by NID_API *
**********************************************************************/
-uint32_t nid_notify(char *, uint32_t, uint32_t *);
-uint32_t nis_notify(char *, uint32_t *);
+uint32_t nid_notify(const char*, uint32_t, uint32_t*);
uint32_t nid_create_ipc(char *);
uint32_t nid_open_ipc(int32_t *fd, char *);
void nid_close_ipc(void);
diff --git a/osaf/libs/core/leap/nid_api.c b/osaf/libs/core/leap/nid_api.c
--- a/osaf/libs/core/leap/nid_api.c
+++ b/osaf/libs/core/leap/nid_api.c
@@ -29,6 +29,9 @@
*****************************************************************************/
#include <nid_api.h>
+#include <stdbool.h>
+
+static bool is_nid_notified = false;
/****************************************************************************
* Name : nid_notify *
@@ -43,7 +46,7 @@
* *
* Notes : None. *
***************************************************************************/
-uint32_t nid_notify(char *service, uint32_t status, uint32_t *error)
+uint32_t nid_notify(const char* service, uint32_t status, uint32_t* error)
{
uint32_t scode;
char msg[250];
@@ -51,6 +54,8 @@ uint32_t nid_notify(char *service, uint3
uint32_t retry = 3;
char strbuff[256];
+ if (is_nid_notified) return NCSCC_RC_SUCCESS;
+
scode = status;
if ((scode < 0)) {
@@ -90,62 +95,7 @@ uint32_t nid_notify(char *service, uint3
return NCSCC_RC_FAILURE;
}
+ is_nid_notified = true;
nid_close_ipc();
return NCSCC_RC_SUCCESS;
}
-
-/****************************************************************************
- * Name : nis_notify *
- * *
- * Description : Opens the FIFO to bladeinitd and write the service and *
- * status code to FIFO. *
- * *
- * Arguments : status - input parameter providing status *
- * error - output parameter to return error code if any *
- * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.. *
- * *
- * Notes : None. *
- ***************************************************************************/
-uint32_t nis_notify(char *status, uint32_t *error)
-{
- int32_t fd = -1;
- uint32_t retry = 3;
- char strbuff[256];
-
- if (status == NULL) {
- if (error != NULL)
- *error = NID_INV_PARAM;
- return NCSCC_RC_FAILURE;
- }
-
- while (retry) {
- if (nid_open_ipc(&fd, strbuff) != NCSCC_RC_SUCCESS) {
- retry--;
- } else
- break;
- }
-
- if ((fd < 0) && (retry == 0)) {
- if (error != NULL)
- *error = NID_OFIFO_ERR;
- return NCSCC_RC_FAILURE;
- }
-
- /* Send the message */
- retry = 3;
- while (retry) {
- if (write(fd, status, strlen(status)) == strlen(status))
- break;
- else
- retry--;
- }
-
- if (retry == 0) {
- if (error != NULL)
- *error = NID_WFIFO_ERR;
- return NCSCC_RC_FAILURE;
- }
-
- nid_close_ipc();
- return NCSCC_RC_SUCCESS;
-}
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel