Fix incorrect check of bad OI handle in log server event handler
procdure for open an application stream.
---
 src/log/logd/lgs_evt.cc    | 17 +++++++----------
 src/log/logd/lgs_imm.cc    |  2 ++
 src/log/logd/lgs_mbcsv.cc  |  2 +-
 src/log/logd/lgs_stream.cc | 24 +++++++++---------------
 src/log/logd/lgs_stream.h  |  2 +-
 5 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/src/log/logd/lgs_evt.cc b/src/log/logd/lgs_evt.cc
index b8840b436..785e3cf66 100644
--- a/src/log/logd/lgs_evt.cc
+++ b/src/log/logd/lgs_evt.cc
@@ -956,7 +956,7 @@ SaAisErrorT create_new_app_stream(lgsv_stream_open_req_t 
*open_sync_param,
     goto done;
   }
 
-  rc = lgs_create_rt_appstream(*o_stream);
+  rc = lgs_create_appstream_rt_object(*o_stream);
   if (rc != SA_AIS_OK) log_stream_delete(o_stream);
 
 done:
@@ -1070,15 +1070,7 @@ static uint32_t proc_stream_open_msg(lgs_cb_t *cb, 
lgsv_lgs_evt_t *evt) {
       }
     }
   } else {
-    /* Stream does not exist */
-
-    // This check is to avoid the client getting SA_AIS_BAD_OPERATION
-    // as there is no IMM OI implementer set.
-    if (cb->immOiHandle == 0) {
-      TRACE("IMM service unavailable, open stream failed");
-      ais_rv = SA_AIS_ERR_TRY_AGAIN;
-      goto snd_rsp;
-    }
+    /* Stream does not exist. Create a new stream */
 
     /*
      * Check if the stream is in the list of stream objects
@@ -1126,6 +1118,11 @@ static uint32_t proc_stream_open_msg(lgs_cb_t *cb, 
lgsv_lgs_evt_t *evt) {
     if (ais_rv != SA_AIS_OK) {
       TRACE("%s create_new_app_stream Fail \"%s\"", __FUNCTION__,
             saf_error(ais_rv));
+      if (ais_rv == SA_AIS_ERR_BAD_HANDLE) {
+        // This means that the stream RT object could not be created because
+        // of a bad OI handle. Change to TRY AGAIN in the reply to the agent
+        ais_rv = SA_AIS_ERR_TRY_AGAIN;
+      }
       goto snd_rsp;
     }
   }
diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc
index 314568133..08cb6502f 100644
--- a/src/log/logd/lgs_imm.cc
+++ b/src/log/logd/lgs_imm.cc
@@ -3225,6 +3225,7 @@ static void *imm_impl_init_thread(void *_cb) {
   SaAisErrorT rc = SA_AIS_OK;
 
   TRACE_ENTER();
+  LOG_NO("%s: OI Reinit thread start", __FUNCTION__);
 
   /* Initialize handles and become implementer */
   lgs_imm_init_OI_handle(&immOiHandle, &immSelectionObject);
@@ -3261,6 +3262,7 @@ static void *imm_impl_init_thread(void *_cb) {
     free(lgsv_evt);
   }
 
+  LOG_NO("%s: Reinit thread exit", __FUNCTION__);
   TRACE_LEAVE();
   return NULL;
 }
diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc
index 175858b6f..47668d8d8 100644
--- a/src/log/logd/lgs_mbcsv.cc
+++ b/src/log/logd/lgs_mbcsv.cc
@@ -2092,7 +2092,7 @@ uint32_t ckpt_proc_open_stream(lgs_cb_t *cb, void *data) {
       goto done;
     }
 
-    rc = lgs_create_rt_appstream(stream);
+    rc = lgs_create_appstream_rt_object(stream);
     if (rc != SA_AIS_OK) {
       log_stream_delete(&stream);
       goto done;
diff --git a/src/log/logd/lgs_stream.cc b/src/log/logd/lgs_stream.cc
index 65689d658..8ee3a9c9f 100644
--- a/src/log/logd/lgs_stream.cc
+++ b/src/log/logd/lgs_stream.cc
@@ -520,7 +520,7 @@ int lgs_populate_log_stream(
  * @param stream runtimem app stream
  * @return SaAisErrorT
  */
-SaAisErrorT lgs_create_rt_appstream(log_stream_t *const stream) {
+SaAisErrorT lgs_create_appstream_rt_object(log_stream_t *const stream) {
   SaAisErrorT rc = SA_AIS_OK;
   TRACE_ENTER2("%s, l: %zu", stream->name.c_str(), stream->name.size());
 
@@ -622,20 +622,14 @@ SaAisErrorT lgs_create_rt_appstream(log_stream_t *const 
stream) {
         &attr_saLogStreamCreationTimestamp,
         NULL};
 
-    {
-      /**
-       * Have to have retry for Rt creation.
-       * Rt update could consider removing retry to avoid blocking
-       */
-      rc = immutil_saImmOiRtObjectCreate_2(
-          lgs_cb->immOiHandle, const_cast<SaImmClassNameT>("SaLogStream"),
-          parentName, attrValues);
-      free(dndup);
-
-      if (rc != SA_AIS_OK) {
-        LOG_WA("saImmOiRtObjectCreate_2 returned %u for %s, parent %s", rc,
-               stream->name.c_str(), parent_name);
-      }
+    rc = immutil_saImmOiRtObjectCreate_2(
+        lgs_cb->immOiHandle, const_cast<SaImmClassNameT>("SaLogStream"),
+        parentName, attrValues);
+    free(dndup);
+
+    if (rc != SA_AIS_OK) {
+      LOG_WA("saImmOiRtObjectCreate_2 returned %u for %s, parent %s", rc,
+             stream->name.c_str(), parent_name);
     }
   }
 
diff --git a/src/log/logd/lgs_stream.h b/src/log/logd/lgs_stream.h
index efc39d44f..ad8c7412f 100644
--- a/src/log/logd/lgs_stream.h
+++ b/src/log/logd/lgs_stream.h
@@ -109,7 +109,7 @@ extern int lgs_populate_log_stream(
     SaBoolT twelveHourModeFlag, uint32_t logRecordId,
     log_stream_t *const o_stream);
 
-extern SaAisErrorT lgs_create_rt_appstream(log_stream_t *const rt);
+extern SaAisErrorT lgs_create_appstream_rt_object(log_stream_t *const rt);
 extern log_stream_t *log_stream_new(const std::string &name, int stream_id);
 
 extern void log_stream_open_fileinit(log_stream_t *stream);
-- 
2.16.2


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to