[devel] [PATCH 1/1] mds: improve thread safety in mdstest - part 2 [#2746]

2018-03-26 Thread Hoa Le
- Use __thread if _Thread_local is not supported in GCC version lower than 4.9
---
 src/mds/apitest/mdstipc.h  | 6 ++
 src/mds/apitest/mdstipc_api.c  | 2 +-
 src/mds/apitest/mdstipc_conf.c | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h
index 01b58c4..f67890a 100644
--- a/src/mds/apitest/mdstipc.h
+++ b/src/mds/apitest/mdstipc.h
@@ -21,6 +21,12 @@
 #include "base/ncssysf_tsk.h"
 #include "base/ncssysf_def.h"
 
+#if !defined(_Thread_local)
+#define MDS_THREAD_LOCAL __thread
+#else
+#define MDS_THREAD_LOCAL _Thread_local
+#endif
+
 typedef struct tet_task {
   NCS_OS_CB entry;
   void *arg;
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
index 669c770..2ff8238 100644
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -33,7 +33,7 @@ static MDS_CLIENT_MSG_FORMAT_VER gl_set_msg_fmt_ver;
 
 MDS_SVC_ID svc_ids[3] = {2006, 2007, 2008};
 
-_Thread_local NCSMDS_INFO svc_to_mds_info;
+MDS_THREAD_LOCAL NCSMDS_INFO svc_to_mds_info;
 pthread_mutex_t safe_printf_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t gl_mutex = PTHREAD_MUTEX_INITIALIZER;
 
diff --git a/src/mds/apitest/mdstipc_conf.c b/src/mds/apitest/mdstipc_conf.c
index c2d7d01..d6ee48e 100644
--- a/src/mds/apitest/mdstipc_conf.c
+++ b/src/mds/apitest/mdstipc_conf.c
@@ -25,7 +25,7 @@ extern int fill_syncparameters(int);
 extern uint32_t mds_vdest_tbl_get_role(MDS_VDEST_ID vdest_id, V_DEST_RL *role);
 extern pthread_mutex_t gl_mds_library_mutex;
 
-extern _Thread_local NCSMDS_INFO svc_to_mds_info;
+extern MDS_THREAD_LOCAL NCSMDS_INFO svc_to_mds_info;
 extern pthread_mutex_t safe_printf_mutex;
 extern pthread_mutex_t gl_mutex;
 
-- 
2.7.4


--
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] Performance and memory footprint for OpenSAF services

2018-03-26 Thread Feng Xie
Hi,

   We are evaluating OpenSAF as an open-source middleware solution. Our 
target environment is a single-node embedded system for now and may be extended 
to a cluster later. Performance and memory footprint of OpenSAF services, 
especially messages, notification and event distribution, are important for us. 
Can somebody shed light on high-level understanding of the communication 
mechanism in these services? More specifically,

  1.  Are OpenSAF daemons (such as osafmsgd and osafmsgnd) involved in every 
message passing from a sender to receivers? Or the daemons only act as "name 
servers" when setting up the connections between senders and receivers.
  2.  It seems that OpenSAF allows both sender and receiver to be in the same 
process while using these services. If so, is the communication still carried 
by TCP/TIPC? Are there any ways to bypass TCP or TIPC, eg., using shared 
memory, or passing pointers, to improve the performance for communications 
within the same process?
  3.  Once I start OpenSAF, there are 22 daemons running. Which of them are 
mandatory and which are optional? How can I disable these optional 
components/daemons to reduce the memory footprint?
  4.  Are there any benchmark data on any reference/real systems? Is the 
overhead of OpenSAF services a real/valid concern for a single-node environment?
Thanks a lot!
Feng

--
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 0/1] Review Request for plmd: handle admin-operation-pending for EE unlock [#2819]

2018-03-26 Thread Alex Jones
Summary: plmd: handle admin-operation-pending for EE unlock [#2819]
Review request for Ticket(s): 2819
Peer Reviewer(s): Mathi, Ravi
Pull request to:
Affected branch(es): develop
Development branch: ticket-2819
Base revision: 9c846d28a5dac616b2619d1fe274105d463d0d20
Personal repository: git://git.code.sf.net/u/trguitar/review


Impacted area   Impact y/n

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


Comments (indicate scope for each "y" above):
-

revision ae59ca0e4d33b97d3fbc28d531452e391afe488a
Author: Alex Jones 
Date:   Mon, 26 Mar 2018 11:10:51 -0400

plmd: handle admin-operation-pending for EE unlock [#2819]

If EE unlock fails, it is never retried when management is regained. The EE
just sits in LOCKED admin state.

If EE unlock fails, the code continues as if it did succeed, setting readiness
state to in-service, etc.

If EE unlock fails, just return ERR_DEPLOYMENT immediately, and don't set
anything else.



Complete diffstat:
--
 src/plm/plmd/plms_adm_fsm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


Testing Commands:
-
1) lock, lock-in, unlock-in, unlock of an EE in a loop waiting for the SUs to
   come online before starting again


Testing, Expected Results:
--
1) if unlock returns ERR_DEPLOYMENT, the EE should unlock when plmd receives
   the connection from plmcd


Conditions of Submission:
-
Apr 1 or ack from developer


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] plmd: handle admin-operation-pending for EE unlock [#2819]

2018-03-26 Thread Alex Jones
If EE unlock fails, it is never retried when management is regained. The EE
just sits in LOCKED admin state.

If EE unlock fails, the code continues as if it did succeed, setting readiness
state to in-service, etc.

If EE unlock fails, just return ERR_DEPLOYMENT immediately, and don't set
anything else.
---
 src/plm/plmd/plms_adm_fsm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/plm/plmd/plms_adm_fsm.c b/src/plm/plmd/plms_adm_fsm.c
index 370c30f36..fdcd6ea05 100644
--- a/src/plm/plmd/plms_adm_fsm.c
+++ b/src/plm/plmd/plms_adm_fsm.c
@@ -4437,10 +4437,9 @@ static SaUint32T plms_ent_unlock(PLMS_ENTITY *ent, 
PLMS_TRACK_INFO *trk_info,
/* Unlock the EE.*/
unlck_err = plms_ee_unlock(ent, true, 1 /*mngt_cbk*/);
if (NCSCC_RC_SUCCESS != unlck_err) {
-   /* TODO: Should I return from here, sending failure to
-   IMM and calling management lost callback.*/
LOG_ER("EE unlock operation failed. Ent: %s",
   ent->dn_name_str);
+   goto send_rsp;
}
}
 
@@ -4548,6 +4547,8 @@ static SaUint32T plms_ent_unlock(PLMS_ENTITY *ent, 
PLMS_TRACK_INFO *trk_info,
 
plms_ent_exp_rdness_status_clear(ent);
plms_aff_ent_exp_rdness_status_clear(trk_info->aff_ent_list);
+
+send_rsp:
/* Respnd to IMM.*/
if (NCSCC_RC_SUCCESS == unlck_err) {
ret_err = saImmOiAdminOperationResult(cb->oi_hdl, adm_op.inv_id,
-- 
2.13.6


--
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] msg: updated the assert condition , to avoid core [#2802]

2018-03-26 Thread Alex Jones
   Hi Srinivas,

   Two comments:
1. Put the new include file before the above "msg/..." files, so it is
   in alphabetical order
2. change the test, so there is only one aisrc_validate call in it.
   Otherwise, 2 PASSED show up for the test.

   Alex

   On 03/26/2018 07:23 AM, srinivas wrote:
 __

   NOTICE: This email was received from an EXTERNAL sender
 __

   ---
   src/msg/apitest/test_MetaDataSize.cc | 6 +-
   1 file changed, 5 insertions(+), 1 deletion(-)
   diff --git a/src/msg/apitest/test_MetaDataSize.cc
   b/src/msg/apitest/test_MetaDataSize.cc
   index f99b02b..6d7375a 100644
   --- a/src/msg/apitest/test_MetaDataSize.cc
   +++ b/src/msg/apitest/test_MetaDataSize.cc
   @@ -10,6 +10,7 @@
   #include "msg/apitest/tet_mqsv.h"
   #include 
   #include 
   +#include "msg/agent/mqa.h"
   static SaVersionT msg3_1 = {'B', 3, 0};
   @@ -67,7 +68,10 @@ static void metaDataSize_05(void) {
   rc = saMsgMetadataSizeGet(msgHandle, );
   aisrc_validate(rc, SA_AIS_OK);
   - assert(metaDataSize == 344);
   + if (metaDataSize != sizeof(MQSV_MESSAGE) +
   + sizeof(NCS_OS_MQ_MSG_LL_HDR))
   + rc = SA_AIS_ERR_MESSAGE_ERROR;
   + aisrc_validate(rc, SA_AIS_OK);
   rc = saMsgFinalize(msgHandle);
   assert(rc == SA_AIS_OK);
   --
   2.7.4


signature.asc
Description: OpenPGP digital signature
--
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] msg: updated the assert condition , to avoid core [#2802]

2018-03-26 Thread srinivas
---
 src/msg/apitest/test_MetaDataSize.cc | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/msg/apitest/test_MetaDataSize.cc 
b/src/msg/apitest/test_MetaDataSize.cc
index f99b02b..6d7375a 100644
--- a/src/msg/apitest/test_MetaDataSize.cc
+++ b/src/msg/apitest/test_MetaDataSize.cc
@@ -10,6 +10,7 @@
 #include "msg/apitest/tet_mqsv.h"
 #include 
 #include 
+#include "msg/agent/mqa.h"
 
 static SaVersionT msg3_1 = {'B', 3, 0};
 
@@ -67,7 +68,10 @@ static void metaDataSize_05(void) {
   rc = saMsgMetadataSizeGet(msgHandle, );
   aisrc_validate(rc, SA_AIS_OK);
 
-  assert(metaDataSize == 344);
+  if (metaDataSize != sizeof(MQSV_MESSAGE) +
+ sizeof(NCS_OS_MQ_MSG_LL_HDR))
+  rc = SA_AIS_ERR_MESSAGE_ERROR;
+  aisrc_validate(rc, SA_AIS_OK);
 
   rc = saMsgFinalize(msgHandle);
   assert(rc == SA_AIS_OK);
-- 
2.7.4


--
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 0/1] Review Request for msg: updated the assert condition , to avoid core [#2802]

2018-03-26 Thread srinivas
Summary: msg: updated the assert condition ,to avoid core [#2802]
Review request for Ticket(s): 2802
Peer Reviewer(s): Alex 
Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***
Affected branch(es): develop
Development branch: ticket-2802
Base revision: dac6b5bf582e581252f21d32b470f91d5629b867
Personal repository: git://git.code.sf.net/u/sri-mangipudy/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   y
 Other   n


Comments (indicate scope for each "y" above):
-
updated the assert condition ,to avoid core

revision b42725023edaace6acb823e9fcf1c9cea055067f
Author: srinivas 
Date:   Mon, 26 Mar 2018 16:34:28 +0530

msg: updated the assert condition ,to avoid core [#2802]



Complete diffstat:
--
 src/msg/apitest/test_MetaDataSize.cc | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)


Testing Commands:
-
msgtest 28

Testing, Expected Results:
--
no core dump.

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 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] base: Add functions for parsing a string as an integer [#2814]

2018-03-26 Thread Hans Nordebäck

ack, review only. Minor comment below.

/Thanks HansN


On 03/22/2018 03:13 PM, Anders Widell wrote:

The new functions StrToInt64 and StrToUint64 parse a string as a signed and
unsigned 64-bit integer, respectively. Prefixes 0 for octal and 0x for
hexadecimal are supported, as well as suffixes k, M and G for kilobytes,
megabytes and gigabytes, respectively.
---
  src/base/Makefile.am|   3 +
  src/base/string_parse.cc|  79 ++
  src/base/string_parse.h |  47 +
  src/base/tests/string_parse_test.cc | 129 
  4 files changed, 258 insertions(+)
  create mode 100644 src/base/string_parse.cc
  create mode 100644 src/base/string_parse.h
  create mode 100644 src/base/tests/string_parse_test.cc

diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index 540c6dfe7..bb13d6c43 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -65,6 +65,7 @@ lib_libopensaf_core_la_SOURCES += \
src/base/process.cc \
src/base/saf_edu.c \
src/base/saf_error.c \
+   src/base/string_parse.cc \
src/base/sysf_def.c \
src/base/sysf_exc_scr.c \
src/base/sysf_ipc.c \
@@ -140,6 +141,7 @@ noinst_HEADERS += \
src/base/saf_error.h \
src/base/saf_mem.h \
src/base/sprr_dl_api.h \
+   src/base/string_parse.h \
src/base/sysf_exc_scr.h \
src/base/sysf_ipc.h \
src/base/tests/mock_clock_gettime.h \
@@ -206,6 +208,7 @@ bin_libbase_test_SOURCES = \
src/base/tests/mock_logtrace.cc \
src/base/tests/mock_osaf_abort.cc \
src/base/tests/mock_osafassert.cc \
+   src/base/tests/string_parse_test.cc \
src/base/tests/time_add_test.cc \
src/base/tests/time_compare_test.cc \
src/base/tests/time_convert_test.cc \
diff --git a/src/base/string_parse.cc b/src/base/string_parse.cc
new file mode 100644
index 0..915f0e95a
--- /dev/null
+++ b/src/base/string_parse.cc
@@ -0,0 +1,79 @@
+/*  -*- OpenSAF  -*-
+ *
+ * Copyright Ericsson AB 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
+ * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+ * under the GNU Lesser General Public License Version 2.1, February 1999.
+ * The complete license can be accessed from the following location:
+ * http://opensource.org/licenses/lgpl-license.php
+ * See the Copying file included with the OpenSAF distribution for full
+ * licensing terms.
+ *
+ */
+
+#include "base/string_parse.h"
+
+#include 
+#include 
+#include 
+
+namespace {
+
+int64_t ParseSuffix(char** endptr) {
+  switch (**endptr) {
+case 'k':
+  ++(*endptr);
+  return 1024;
+case 'M':
+  ++(*endptr);
+  return 1024 * 1024;
+case 'G':
+  ++(*endptr);
+  return 1024 * 1024 * 1024;
+default:
+  return 1;
+  }
+}
+
+}  // namespace
+
+namespace base {
+
+int64_t StrToInt64(const char* str, bool* success) {
+  str = RemoveLeadingWhitespace(str);
+  errno = 0;
+  char* endptr;
+  int64_t val = strtoll(str, , 0);
+  int64_t multiplier = ParseSuffix();
+  endptr = RemoveLeadingWhitespace(endptr);
+  *success = *str != '\0' && errno == 0 && *endptr == '\0' &&
+ (val >= 0 ? val <= (INT64_MAX / multiplier)
+   : val >= (INT64_MIN / multiplier));
+  return val * multiplier;
+}
+
+uint64_t StrToUint64(const char* str, bool* success) {
+  str = RemoveLeadingWhitespace(str);
+  errno = 0;
+  char* endptr;
+  uint64_t val = strtoull(str, , 0);
+  uint64_t multiplier = ParseSuffix();
+  endptr = RemoveLeadingWhitespace(endptr);
+  *success = *str != '\0' && *str != '-' && errno == 0 && *endptr == '\0' &&
+ val <= (~static_cast(0) / multiplier);
+  return val * multiplier;
+}
+
+const char* RemoveLeadingWhitespace(const char* str) {
+  while (*str == ' ' || *str == '\t' || *str == '\r' || *str == '\n') ++str;
+  return str;
+}
+
+char* RemoveLeadingWhitespace(char* str) {
+  while (*str == ' ' || *str == '\t' || *str == '\r' || *str == '\n') ++str;
+  return str;
+}
+

[HansN] you can change name of thiese functions and use isspace:
const char* TrimLeadingWhitespace(const char* str) {
  while (isspace(*str)) ++str;
  return str;
}

char* TrimLeadingWhitespace(char* str) {
  while (isspace(*str)) ++str;
  return str;
}

+}  // namespace base
diff --git a/src/base/string_parse.h b/src/base/string_parse.h
new file mode 100644
index 0..17569241c
--- /dev/null
+++ b/src/base/string_parse.h
@@ -0,0 +1,47 @@
+/*  -*- OpenSAF  -*-
+ *
+ * Copyright Ericsson AB 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
+ * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+ * 

Re: [devel] [PATCH 1/1] dtm: Fix the osaflog --flush command, and revert osaflog protocol [#2812]

2018-03-26 Thread Ravi Sekhar Reddy Konda
Hi Anders,

Ack, code review only

Regards,
Ravi

-Original Message-
From: Anders Widell [mailto:anders.wid...@ericsson.com] 
Sent: Monday, March 19, 2018 8:38 PM
To: Ravi Sekhar Reddy Konda 
Cc: opensaf-devel@lists.sourceforge.net; Anders Widell 

Subject: [PATCH 1/1] dtm: Fix the osaflog --flush command, and revert osaflog 
protocol [#2812]

Fix the remaining review comment for ticket [#2731]: revert back to a 
text-based protocol between osaflog command and osaftransportd. Also fix the 
osaflog --flush command, that stopped working after ticket [#2731].
---
 src/dtm/common/osaflog_protocol.h |  7 -
 src/dtm/tools/osaflog.cc  | 55 ++--
 src/dtm/transport/log_server.cc   | 59 ---
 src/dtm/transport/log_server.h|  3 +-
 4 files changed, 47 insertions(+), 77 deletions(-)

diff --git a/src/dtm/common/osaflog_protocol.h 
b/src/dtm/common/osaflog_protocol.h
index db914e00a..61e9f6f39 100644
--- a/src/dtm/common/osaflog_protocol.h
+++ b/src/dtm/common/osaflog_protocol.h
@@ -24,13 +24,6 @@
 
 namespace Osaflog {
 
-enum Command { kFlush, kMaxbackups, kMaxfilesize, kFailure }; -struct Message {
-char marker[4];
-Command  command; // Command Enum
-size_t   value;   // Value based on the command
-};
-
 static constexpr const char* kServerSocketPath =
 PKGLOCALSTATEDIR "/osaf_log.sock";
 
diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc index 
cf1e6b43c..1de0a85d6 100644
--- a/src/dtm/tools/osaflog.cc
+++ b/src/dtm/tools/osaflog.cc
@@ -158,9 +158,9 @@ void PrintUsage(const char* program_name) {
   program_name);
 }
 
-
-bool SendCommand(Osaflog::Message message,
- Osaflog::Command command) {
+bool SendCommand(const std::string& command) {
+  std::string request{std::string{"?"} + command};
+  std::string expected_reply{std::string{"!"} + command};
   auto sock = std::unique_ptr(CreateSocket());
 
   if (!sock) {
@@ -172,13 +172,12 @@ bool SendCommand(Osaflog::Message message,
   socklen_t addrlen = base::UnixSocket::SetAddress(Osaflog::kServerSocketPath,
_addr);
 
-  ssize_t result = sock->SendTo(, sizeof(message),
+  ssize_t result = sock->SendTo(request.data(), request.size(),
 _addr, addrlen);
   if (result < 0) {
 perror("Failed to send message to osaftransportd");
 return false;
-  } else if (static_cast(result) !=
- (sizeof(Osaflog::Message))) {
+  } else if (static_cast(result) != request.size()) {
 fprintf(stderr, "Failed to send message to osaftransportd\n");
 return false;
   }
@@ -214,50 +213,26 @@ bool SendCommand(Osaflog::Message message,
   if (result < 0) {
 perror("Failed to receive reply from osaftransportd");
 return false;
-  } else if (static_cast(result) !=
-   (sizeof(Osaflog::Message) )) {
-Osaflog::Message result_message;
-memset(_message, 0, sizeof(result_message));
-memcpy(_message, buf, result);
-if (result_message.command != command) {
-   fprintf(stderr, "Received unexpected reply from osaftransportd\n");
-   return false;
-}
+  } else if (static_cast(result) != expected_reply.size() ||
+ memcmp(buf, expected_reply.data(), result) != 0) {
+fprintf(stderr, "ERROR: osaftransportf replied '%s'\n",
+std::string{buf, static_cast(result)}.c_str());
+return false;
   }
   return true;
 }
 
 bool MaxTraceFileSize(size_t max_file_size) {
-  Osaflog::Message message;
-
-  memset(, 0, sizeof(message));
-  message.marker[0] = '?';
-  message.command = Osaflog::kMaxfilesize;
-  message.value = max_file_size;
-
-  return SendCommand(message, Osaflog::kMaxfilesize);
+  return SendCommand(std::string{"max-file-size "} +
+ std::to_string(max_file_size));
 }
 
-bool NoOfBackupFiles(size_t number_of_files) {
-  Osaflog::Message message;
-
-  memset(, 0, sizeof(message));
-  message.marker[0] = '?';
-  message.command = Osaflog::kMaxbackups;
-  message.value = number_of_files;
-
-  return SendCommand(message, Osaflog::kMaxbackups);
+bool NoOfBackupFiles(size_t max_backups) {
+  return SendCommand(std::string{"max-backups "} + 
+std::to_string(max_backups));
 }
 
 bool Flush() {
-  Osaflog::Message message;
-
-  memset(, 0, sizeof(message));
-  message.marker[0] = '?';
-  message.command = Osaflog::kFlush;
-  message.value = 0;
-
-  return SendCommand(message, Osaflog::kFlush);
+  return SendCommand(std::string{"flush"});
 }
 
 base::UnixServerSocket* CreateSocket() { diff --git 
a/src/dtm/transport/log_server.cc b/src/dtm/transport/log_server.cc index 
44fbe140a..76519cf35 100644
--- a/src/dtm/transport/log_server.cc
+++ b/src/dtm/transport/log_server.cc
@@ -16,16 +16,16 @@
  *
  */
 
+#include "dtm/transport/log_server.h"
 #include