[devel] [PATCH 1/1] log: Fix cyclic crash when starting standby and OI is not active [#2711]

2018-03-09 Thread Lennart Lund
Fix cyclic reboot caused by reading an IMM RT object when the OI is down
---
 src/log/apitest/logtest.c  |  2 --
 src/log/logd/lgs_config.cc |  2 +-
 src/log/logd/lgs_evt.cc| 13 +--
 src/log/logd/lgs_fmt.h |  8 ++-
 src/log/logd/lgs_imm.cc| 13 ++-
 src/log/logd/lgs_mbcsv.cc  | 56 +-
 src/log/logd/lgs_mbcsv.h   |  7 +-
 src/log/logd/lgs_recov.cc  |  6 +++--
 src/log/logd/lgs_stream.cc | 28 +--
 src/log/logd/lgs_stream.h  |  2 +-
 src/osaf/immutil/immutil.h |  4 +++-
 11 files changed, 87 insertions(+), 54 deletions(-)

diff --git a/src/log/apitest/logtest.c b/src/log/apitest/logtest.c
index afa1fcf57..f8fe135cb 100644
--- a/src/log/apitest/logtest.c
+++ b/src/log/apitest/logtest.c
@@ -33,8 +33,6 @@
 #include "base/osaf_extended_name.h"
 #include 
 
-#define LLDTEST
-
 SaNameT systemStreamName;
 SaNameT alarmStreamName;
 SaNameT globalConfig;
diff --git a/src/log/logd/lgs_config.cc b/src/log/logd/lgs_config.cc
index a70a2f6c6..4190e3048 100644
--- a/src/log/logd/lgs_config.cc
+++ b/src/log/logd/lgs_config.cc
@@ -586,7 +586,7 @@ int lgs_cfg_verify_log_file_format(const char 
*log_file_format) {
   SaBoolT dummy;
 
   if (!lgs_is_valid_format_expression((const SaStringT)log_file_format,
-  STREAM_TYPE_APPLICATION, )) {
+  STREAM_TYPE_APPLICATION_RT, )) {
 LOG_NO("logStreamFileFormat has invalid value = %s", log_file_format);
 rc = -1;
   }
diff --git a/src/log/logd/lgs_evt.cc b/src/log/logd/lgs_evt.cc
index b8840b436..4b735875d 100644
--- a/src/log/logd/lgs_evt.cc
+++ b/src/log/logd/lgs_evt.cc
@@ -877,7 +877,7 @@ SaAisErrorT create_new_app_stream(lgsv_stream_open_req_t 
*open_sync_param,
 
   /* Check the format string */
   if (!lgs_is_valid_format_expression(open_sync_param->logFileFmt,
-  STREAM_TYPE_APPLICATION,
+  STREAM_TYPE_APPLICATION_RT,
   )) {
 TRACE("format expression failure");
 rc = SA_AIS_ERR_INVALID_PARAM;
@@ -947,16 +947,15 @@ SaAisErrorT create_new_app_stream(lgsv_stream_open_req_t 
*open_sync_param,
   open_sync_param->logFileName, open_sync_param->logFilePathName,
   open_sync_param->maxLogFileSize, open_sync_param->maxLogRecordSize,
   open_sync_param->logFileFullAction, open_sync_param->maxFilesRotated,
-  open_sync_param->logFileFmt, STREAM_TYPE_APPLICATION, twelveHourModeFlag,
-  0,
-  *o_stream);  // output
+  open_sync_param->logFileFmt, STREAM_TYPE_APPLICATION_RT,
+  twelveHourModeFlag, 0, *o_stream);  // output
   if (err == -1) {
 log_stream_delete(o_stream);
 rc = SA_AIS_ERR_NO_MEMORY;
 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:
@@ -1055,7 +1054,7 @@ static uint32_t proc_stream_open_msg(lgs_cb_t *cb, 
lgsv_lgs_evt_t *evt) {
   logStream = log_stream_get_by_name(name);
   if (logStream != nullptr) {
 TRACE("existing stream - id %u", logStream->streamId);
-if (logStream->streamType == STREAM_TYPE_APPLICATION) {
+if (logStream->streamType == STREAM_TYPE_APPLICATION_RT) {
   /* Verify the creation attributes for an existing appl. stream */
   if (open_sync_param->lstr_open_flags & SA_LOG_STREAM_CREATE) {
 ais_rv = file_attribute_cmp(open_sync_param, logStream);
@@ -1218,7 +1217,7 @@ static uint32_t proc_stream_close_msg(lgs_cb_t *cb, 
lgsv_lgs_evt_t *evt) {
 
   // This check is to avoid the client getting SA_AIS_BAD_OPERATION
   // as there is no IMM OI implementer set.
-  if ((stream->streamType == STREAM_TYPE_APPLICATION) &&
+  if ((stream->streamType == STREAM_TYPE_APPLICATION_RT) &&
   (cb->immOiHandle == 0)) {
 TRACE("IMM service unavailable, close stream failed");
 ais_rc = SA_AIS_ERR_TRY_AGAIN;
diff --git a/src/log/logd/lgs_fmt.h b/src/log/logd/lgs_fmt.h
index f493e2c48..3075c442b 100644
--- a/src/log/logd/lgs_fmt.h
+++ b/src/log/logd/lgs_fmt.h
@@ -172,7 +172,13 @@ typedef enum {
   STREAM_TYPE_ALARM = 0,
   STREAM_TYPE_NOTIFICATION = 1,
   STREAM_TYPE_SYSTEM = 2,
-  STREAM_TYPE_APPLICATION = 3
+  // Note: STREAM_TYPE_APPLICATION is only used to handle backwards
+  //   compatibility if a log service version before the ...APPLICATION_RT
+  //   and CFG was added is running as active and a log server of this
+  //   version is started/running as standby
+  STREAM_TYPE_APPLICATION = 3,
+  STREAM_TYPE_APPLICATION_RT = 4,
+  STREAM_TYPE_APPLICATION_CFG = 5
 } logStreamTypeT;
 
 extern SaBoolT lgs_is_valid_format_expression(const SaStringT, logStreamTypeT,
diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc
index 314568133..60870fa17 100644
--- a/src/log/logd/lgs_imm.cc
+++ b/src/log/logd/lgs_imm.cc
@@ -399,7 +399,7 @@ static void adminOperationCallback(
 

[devel] [PATCH 0/1] Review Request for log: Fix cyclic crash when starting standby and OI is not active [#2711]

2018-03-09 Thread Lennart Lund
Summary: log: Fix cyclic crash when starting standby and OI is not active 
[#2711]
Review request for Ticket(s): 2711
Peer Reviewer(s): canh.v.tru...@dektech.com.au, vu.m.ngu...@dektech.com.au
Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***
Affected branch(es): develop
Development branch: ticket-2711
Base revision: 30b70f4a56ab0225d3ade3cc8dda3fe403b5492c
Personal repository: git://git.code.sf.net/u/elunlen/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
Added fix to make full compatibility between this and older version
regarding message based checkpointing

revision 0297bb21730490bbfa003eec2adf3b9de112f2cf
Author: Lennart Lund 
Date:   Fri, 9 Mar 2018 15:39:37 +0100

log: Fix cyclic crash when starting standby and OI is not active [#2711]

Fix cyclic reboot caused by reading an IMM RT object when the OI is down



Complete diffstat:
--
 src/log/apitest/logtest.c  |  2 --
 src/log/logd/lgs_config.cc |  2 +-
 src/log/logd/lgs_evt.cc| 13 +--
 src/log/logd/lgs_fmt.h |  8 ++-
 src/log/logd/lgs_imm.cc| 13 ++-
 src/log/logd/lgs_mbcsv.cc  | 56 +-
 src/log/logd/lgs_mbcsv.h   |  7 +-
 src/log/logd/lgs_recov.cc  |  6 +++--
 src/log/logd/lgs_stream.cc | 28 +--
 src/log/logd/lgs_stream.h  |  2 +-
 src/osaf/immutil/immutil.h |  4 +++-
 11 files changed, 87 insertions(+), 54 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
*** HOW MANY DAYS BEFORE PUSHING, CONSENSUS ETC ***


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  n  n
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging 

[devel] [PATCH 0/1] Review Request for tools: Fix trace2dot, it stopped working after ticket #2165 [#2668]

2018-03-09 Thread Hans Nordeback
Summary: tools: Fix trace2dot, it stopped working after ticket #2165 [#2668]
Review request for Ticket(s): 2668
Peer Reviewer(s): AndersW
Pull request to: 
Affected branch(es): develop
Development branch: ticket-2668
Base revision: 30b70f4a56ab0225d3ade3cc8dda3fe403b5492c
Personal repository: git://git.code.sf.net/u/hansnordeback/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
*** EXPLAIN/COMMENT THE PATCH SERIES HERE ***

revision 0e9a107623599596462855ae5ddff45a83427039
Author: Hans Nordeback 
Date:   Fri, 9 Mar 2018 14:05:52 +0100

tools: Fix trace2dot, it stopped working after ticket #2165 [#2668]



Complete diffstat:
--
 tools/devel/dot/trace2dot | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
*** HOW MANY DAYS BEFORE PUSHING, CONSENSUS ETC ***


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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


[devel] [PATCH 1/1] tools: Fix trace2dot, it stopped working after ticket #2165 [#2668]

2018-03-09 Thread Hans Nordeback
---
 tools/devel/dot/trace2dot | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/devel/dot/trace2dot b/tools/devel/dot/trace2dot
index 160617c7a..1977276ea 100755
--- a/tools/devel/dot/trace2dot
+++ b/tools/devel/dot/trace2dot
@@ -2,7 +2,7 @@
 #
 #
 # (C) Copyright 2015 The OpenSAF Foundation
-# (C) Copyright Ericsson AB 2015, 2016, 2017. All rights reserved.
+# (C) Copyright Ericsson AB 2015, 2016, 2017, 2018. All rights reserved.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -59,13 +59,13 @@ def check_infile(trace_file):
 trace_leave = set()
 for line in infile:
 items = line.split()
-if items.__len__() > 6:
-if items[5] == '>>':
-name = items[6].rstrip(':')
+if len(items) > 10:
+if items[9] == '>>':
+name = items[10].rstrip(':')
 trace_enter.add(name)
 
-if items[5] == '<<':
-name = items[6].rstrip(':')
+if items[9] == '<<':
+name = items[10].rstrip(':')
 trace_leave.add(name)
 
 for name in trace_enter:
@@ -86,9 +86,9 @@ def process_infile(infile, from_function, outfile):
 
 for line in infile:
 items = line.split()
-if items.__len__() > 6:
-if items[5] == '>>':
-func_enter = items[6].rstrip(':')
+if len(items) > 10:
+if items[9] == '>>':
+func_enter = items[10].rstrip(':')
 if from_function and not from_func_found:
 if from_function != func_enter:
 continue
@@ -108,8 +108,8 @@ def process_infile(infile, from_function, outfile):
 ' [ordering=out, color=red, shape=box, label="' +
 func_enter + '"];\n')
 
-if items[5] == '<<':
-func_leave = items[6].rstrip(':')
+if items[9] == '<<':
+func_leave = items[10].rstrip(':')
 if from_function:
 if from_function == func_leave:
 break
-- 
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


Re: [devel] [PATCH 1/1] amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2018-03-09 Thread Hans Nordebäck

ack, review only. Some comments below marked with [HansN].

/Thanks HansN


On 03/06/2018 07:39 AM, Nguyen Luu wrote:

Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.
---
  src/amf/agent/amf_agent.cc | 51 --
  1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index f0ed7a8..a162af1 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2,6 +2,7 @@
   *
   * (C) Copyright 2008 The OpenSAF Foundation
   * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,6 +14,7 @@
   * licensing terms.
   *
   * Author(s): Emerson Network Power
+ *Ericsson
   *
   */
  
@@ -272,7 +274,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, SaDispatchFlagsT flags) {

  rc = SA_AIS_ERR_LIBRARY;
  goto done;
}
-  /* acquire cb read lock */
+  /* acquire cb write lock */
m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
/* retrieve hdl rec */
if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
@@ -293,7 +295,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {
pend_fin = cb->pend_fin;
  
  done:

-  /* release cb read lock and return handles */
+  /* release cb write lock and return handles */
if (cb) {
  m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
  ncshm_give_hdl(gl_ava_hdl);
@@ -356,7 +358,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
  uninstall_osafAmfSCStatusChangeCallback();
}
  
-  /* acquire cb read lock */

+  /* acquire cb write lock */
m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
  
/* retrieve hdl rec */

@@ -394,7 +396,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
  cb->pend_fin++;
  
  done:

-  /* release cb read lock and return handles */
+  /* release cb read write and return handles */
if (cb) {
  m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
  ncshm_give_hdl(gl_ava_hdl);
@@ -457,8 +459,7 @@ SaAisErrorT AmfAgent::ComponentRegister(SaAmfHandleT hdl,
  goto done;
}
/* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
[HansN] the agent is c++, so use if (!(cb = static_cast*>(ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl {

  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
@@ -627,8 +628,7 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
  goto done;
}
/* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
[HansN] if (!(cb = static_cast*>(ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl {

  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
@@ -636,6 +636,13 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
  
/* acquire cb read lock */

m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (ava_B4_ver_used(cb)) {
  TRACE_2("Invalid AMF version, B 4.1");
@@ -1373,14 +1380,20 @@ SaAisErrorT AmfAgent::CSIQuiescingComplete(SaAmfHandleT 
hdl, SaInvocationT inv,
  goto done;
}
/* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
}
/* acquire cb read lock */
m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
/* retrieve hdl rec */
if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
  rc = SA_AIS_ERR_BAD_HANDLE;
@@ -1591,7 +1604,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTrack(
  goto done;
}
/* acquire cb read lock */
-  m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
+  

[devel] [PATCH 1/2] dtm: configure trace file size and no of backups in transportd.conf [#2731]

2018-03-09 Thread syam-talluri
---
 opensaf.spec.in|  2 +
 src/dtm/Makefile.am|  3 +
 src/dtm/transport/log_server.cc| 95 --
 src/dtm/transport/log_server.h | 10 +++-
 src/dtm/transport/log_writer.cc|  6 +-
 src/dtm/transport/log_writer.h |  4 +-
 src/dtm/transport/main.cc  |  4 ++
 src/dtm/transport/osaf-transport.in|  1 +
 src/dtm/transport/tests/log_writer_test.cc |  2 +-
 src/dtm/transport/transportd.conf  | 13 
 10 files changed, 129 insertions(+), 11 deletions(-)
 create mode 100644 src/dtm/transport/transportd.conf

diff --git a/opensaf.spec.in b/opensaf.spec.in
index 187e20e..ac92174 100644
--- a/opensaf.spec.in
+++ b/opensaf.spec.in
@@ -1400,6 +1400,7 @@ fi
 %config(noreplace) %{_pkgsysconfdir}/nodeinit.conf.controller
 %config(noreplace) %{_pkgsysconfdir}/nodeinit.conf.payload
 %config(noreplace) %{_pkgsysconfdir}/dtmd.conf
+%config(noreplace) %{_pkgsysconfdir}/transportd.conf
 %{_pkglibdir}/osafrded
 %{_pkgclcclidir}/osaf-rded
 %{_pkglibdir}/osaffmd
@@ -1426,6 +1427,7 @@ fi
 %dir %{_pkgsysconfdir}
 %config(noreplace) %{_pkgsysconfdir}/nodeinit.conf.payload
 %config(noreplace) %{_pkgsysconfdir}/dtmd.conf
+%config(noreplace) %{_pkgsysconfdir}/transportd.conf
 %{_pkglibdir}/osafdtmd
 %{_pkglibdir}/osaftransportd
 %{_pkgclcclidir}/osaf-dtm
diff --git a/src/dtm/Makefile.am b/src/dtm/Makefile.am
index f3ba720..822249c 100644
--- a/src/dtm/Makefile.am
+++ b/src/dtm/Makefile.am
@@ -57,6 +57,9 @@ nodist_pkgclccli_SCRIPTS += \
 dist_pkgsysconf_DATA += \
src/dtm/dtmnd/dtmd.conf
 
+dist_pkgsysconf_DATA += \
+   src/dtm/transport/transportd.conf
+
 bin_osaftransportd_CXXFLAGS = $(AM_CXXFLAGS)
 
 bin_osaftransportd_CPPFLAGS = \
diff --git a/src/dtm/transport/log_server.cc b/src/dtm/transport/log_server.cc
index 2d6c961..780feb1 100644
--- a/src/dtm/transport/log_server.cc
+++ b/src/dtm/transport/log_server.cc
@@ -18,21 +18,28 @@
 
 #include "dtm/transport/log_server.h"
 #include 
+#include 
+#include 
 #include "base/osaf_poll.h"
 #include "base/time.h"
 #include "dtm/common/osaflog_protocol.h"
 #include "osaf/configmake.h"
 
+#define TRANSPORTD_CONFIG_FILE PKGSYSCONFDIR "/transportd.conf"
+
+size_t LogServer::no_of_backups = 9;
+size_t LogServer::kmax_file_size = 5000 * 1024;
+
 const Osaflog::ClientAddressConstantPrefix LogServer::address_header_{};
 
 LogServer::LogServer(int term_fd)
 : term_fd_{term_fd},
   log_socket_{Osaflog::kServerSocketPath, base::UnixSocket::kNonblocking},
   log_streams_{},
-  current_stream_{new LogStream{"mds.log", 1}},
+  current_stream_{new LogStream{"mds.log", 1, LogServer::kmax_file_size}},
   no_of_log_streams_{1} {
   log_streams_["mds.log"] = current_stream_;
-}
+  }
 
 LogServer::~LogServer() {
   for (const auto& s : log_streams_) delete s.second;
@@ -40,6 +47,12 @@ LogServer::~LogServer() {
 
 void LogServer::Run() {
   struct pollfd pfd[2] = {{term_fd_, POLLIN, 0}, {log_socket_.fd(), POLLIN, 
0}};
+
+  /* Initialize a signal handler for loading new configuration from 
transportd.conf */
+  if ((signal(SIGUSR2, usr2_sig_handler)) == SIG_ERR) {
+  syslog(LOG_ERR,"signal USR2 registration failed: %s", strerror(errno));
+  }
+
   do {
 for (int i = 0; i < 256; ++i) {
   char* buffer = current_stream_->current_buffer_position();
@@ -88,6 +101,12 @@ void LogServer::Run() {
   } while ((pfd[0].revents & POLLIN) == 0);
 }
 
+void LogServer::usr2_sig_handler(int sig) {
+   syslog(LOG_ERR, "Recived the SIGUSR2 Signal");
+   ReadConfig(TRANSPORTD_CONFIG_FILE);
+   signal(SIGUSR2, usr2_sig_handler);
+}
+
 LogServer::LogStream* LogServer::GetStream(const char* msg_id,
size_t msg_id_size) {
   if (msg_id_size == current_stream_->log_name_size() &&
@@ -99,7 +118,8 @@ LogServer::LogStream* LogServer::GetStream(const char* 
msg_id,
   if (iter != log_streams_.end()) return iter->second;
   if (no_of_log_streams_ >= kMaxNoOfStreams) return nullptr;
   if (!ValidateLogName(msg_id, msg_id_size)) return nullptr;
-  LogStream* stream = new LogStream{log_name, 9};
+
+  LogStream* stream = new LogStream{log_name, LogServer::no_of_backups, 
LogServer::kmax_file_size};
   auto result = log_streams_.insert(
   std::map::value_type{log_name, stream});
   if (!result.second) osaf_abort(msg_id_size);
@@ -107,6 +127,71 @@ LogServer::LogStream* LogServer::GetStream(const char* 
msg_id,
   return stream;
 }
 
+bool LogServer::ReadConfig(const char *transport_config_file) {
+  FILE *transport_conf_file;
+  char line[256];
+  size_t maxFileSize=0;
+  size_t noOfBackupFiles=0;
+  int i, n, comment_line, tag_len = 0;
+
+  /* Open transportd.conf config file. */
+  transport_conf_file = fopen(transport_config_file, "r");
+  if (transport_conf_file == nullptr) {
+
+syslog(LOG_ERR,"Not able to read transportd.conf: %s", strerror(errno));
+return 

[devel] [PATCH 0/2] Review Request for dtm: Added following options --max-backups and --max-file-size to osaflog tool and in transportd [#2731]

2018-03-09 Thread syam-talluri
Summary: dtm: configure trace file size and no of backups in transportd.conf 
[#2731]
Review request for Ticket(s): 2731
Peer Reviewer(s): anders.wid...@ericsson.com
Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***
Affected branch(es): develop
Development branch: ticket-2731
Base revision: 30b70f4a56ab0225d3ade3cc8dda3fe403b5492c
Personal repository: git://git.code.sf.net/u/syam-talluri/review


Impacted area   Impact y/n

 Docsn
 Build systemy
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  y
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
Fixed the cpplint warnings, review comments incorporated

revision 6992d2a095f653efdec428447bfa7841d01c5e53
Author: syam-talluri 
Date:   Fri, 9 Mar 2018 14:58:43 +0530

dtm: Added following options  --max-backups and --max-file-size to osaflog tool 
and in transportd [#2731]



revision 4d73f74f421743ef56ccce8c51c44996d3df6669
Author: syam-talluri 
Date:   Fri, 9 Mar 2018 14:58:43 +0530

dtm: configure trace file size and no of backups in transportd.conf [#2731]



Added Files:

 src/dtm/transport/transportd.conf


Complete diffstat:
--
 opensaf.spec.in|   2 +
 src/dtm/Makefile.am|   3 +
 src/dtm/common/osaflog_protocol.h  |  13 +++
 src/dtm/tools/osaflog.cc   | 168 -
 src/dtm/transport/log_server.cc| 111 ---
 src/dtm/transport/log_server.h |  16 ++-
 src/dtm/transport/log_writer.cc|   9 +-
 src/dtm/transport/log_writer.h |   5 +-
 src/dtm/transport/main.cc  |   4 +
 src/dtm/transport/osaf-transport.in|   1 +
 src/dtm/transport/tests/log_writer_test.cc |   2 +-
 src/dtm/transport/transportd.conf  |  13 +++
 12 files changed, 298 insertions(+), 49 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
Ack from the Reviewer


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results

[devel] [PATCH 2/2] dtm: Added following options --max-backups and --max-file-size to osaflog tool and in transportd [#2731]

2018-03-09 Thread syam-talluri
---
 src/dtm/common/osaflog_protocol.h |  13 +++
 src/dtm/tools/osaflog.cc  | 168 --
 src/dtm/transport/log_server.cc   |  74 -
 src/dtm/transport/log_server.h|  14 ++--
 src/dtm/transport/log_writer.cc   |   5 +-
 src/dtm/transport/log_writer.h|   3 +-
 src/dtm/transport/main.cc |   6 +-
 src/dtm/transport/transportd.conf |   8 +-
 8 files changed, 211 insertions(+), 80 deletions(-)

diff --git a/src/dtm/common/osaflog_protocol.h 
b/src/dtm/common/osaflog_protocol.h
index 61e9f6f..54551ee 100644
--- a/src/dtm/common/osaflog_protocol.h
+++ b/src/dtm/common/osaflog_protocol.h
@@ -24,6 +24,19 @@
 
 namespace Osaflog {
 
+enum cmd { FLUSH, MAXBACKUPS, MAXFILESIZE};
+enum cmdreply { RFLUSH = 101, RMAXBACKUPS, RMAXFILESIZE, FAILURE};
+struct cmd_osaflog {
+char marker[4];
+enum cmd  m_cmd;// Command Enum
+size_t  m_value;   // Value based on the command
+};
+
+
+struct cmd_osaflog_resp {
+enum cmdreply  m_cmdreply;// Command Enum
+};
+
 static constexpr const char* kServerSocketPath =
 PKGLOCALSTATEDIR "/osaf_log.sock";
 
diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc
index 3ce66f4..e0d135b 100644
--- a/src/dtm/tools/osaflog.cc
+++ b/src/dtm/tools/osaflog.cc
@@ -14,6 +14,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,6 +40,8 @@ namespace {
 
 void PrintUsage(const char* program_name);
 bool Flush();
+bool MaxTraceFileSize(size_t maxfilesize);
+bool NoOfBackupFiles(size_t nooffiles);
 base::UnixServerSocket* CreateSocket();
 uint64_t Random64Bits(uint64_t seed);
 bool PrettyPrint(const std::string& log_stream);
@@ -53,20 +56,82 @@ char buf[65 * 1024];
 }  // namespace
 
 int main(int argc, char** argv) {
-  bool flush_option = false;
-  if (argc >= 2 && strcmp(argv[1], "--flush") == 0) {
-flush_option = true;
---argc;
-++argv;
-  }
-  if ((argc != 2) && (argc != 1 || flush_option == false)) {
+  struct option long_options[] = {{"max-file-size", required_argument, 0, 'm'},
+  {"max-backups", required_argument, 0, 'b'},
+  {"flush", no_argument, 0, 'f'},
+  {"print", required_argument, 0, 'p'},
+  {0, 0, 0, 0}};
+
+  size_t maxfilesize = 0;
+  size_t maxbackups = 0;
+  char *pplog = NULL;
+  int opt = 0;
+
+  int long_index = 0;
+  bool flush_result =  true;
+  bool print_result =  true;
+  bool maxfilesize_result = true;
+  bool noof_backup_result = true;
+  bool flush_set = false;
+  bool prettyprint_set = false;
+  bool maxfilesize_set = false;
+  bool maxbackups_set = false;
+
+  if (argc == 1) {
 PrintUsage(argv[0]);
 exit(EXIT_FAILURE);
   }
-  bool flush_result = Flush();
-  bool print_result = true;
-  if (argc == 2) print_result = PrettyPrint(argv[1]);
-  exit((flush_result && print_result) ? EXIT_SUCCESS : EXIT_FAILURE);
+
+  while ((opt = getopt_long(argc, argv, "m:b:p:f",
+   long_options, _index)) != -1) {
+switch (opt) {
+ case 'p':
+   pplog = optarg;
+   prettyprint_set = true;
+   flush_set = true;
+ break;
+ case 'f':
+   flush_set = true;
+ break;
+ case 'm':
+   maxfilesize_set = true;
+   maxfilesize = atoi(optarg);
+ break;
+ case 'b':
+   maxbackups_set = true;
+   maxbackups = atoi(optarg);
+ break;
+ default: PrintUsage(argv[0]);
+ exit(EXIT_FAILURE);
+}
+}
+
+  if (argc - optind == 1) {
+  flush_result = Flush();
+  flush_set = false;
+  print_result = PrettyPrint(argv[optind]);
+  prettyprint_set = false;
+   } else if (argc - optind > 1) {
+  PrintUsage(argv[0]);
+  exit(EXIT_FAILURE);
+   }
+
+  if (flush_set == true) {
+ flush_result = Flush();
+  }
+  if (prettyprint_set == true) {
+  print_result = PrettyPrint(pplog);
+  }
+  if (maxbackups_set == true) {
+ noof_backup_result = NoOfBackupFiles(maxbackups);
+  }
+  if (maxfilesize_set == true) {
+ maxfilesize_result = MaxTraceFileSize(maxfilesize);
+  }
+  if (flush_result && print_result && maxfilesize_result &&
+noof_backup_result)
+ exit(EXIT_SUCCESS);
+  exit(EXIT_FAILURE);
 }
 
 namespace {
@@ -75,18 +140,27 @@ void PrintUsage(const char* program_name) {
   fprintf(stderr,
   "Usage: %s [OPTION] [LOGSTREAM]\n"
   "\n"
-  "Pretty-print the messages stored on disk for the specified\n"
+  "print the messages stored on disk for the specified\n"
   "LOGSTREAM. When a LOGSTREAM argument is specified, the option\n"
   "--flush is