[devel] [PATCH 1 of 1] imm: Fix external linkage in OI library [#2167]
osaf/libs/agents/saf/imma/imma_oi_api.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Fix external linkage in OI library. diff --git a/osaf/libs/agents/saf/imma/imma_oi_api.c b/osaf/libs/agents/saf/imma/imma_oi_api.c --- a/osaf/libs/agents/saf/imma/imma_oi_api.c +++ b/osaf/libs/agents/saf/imma/imma_oi_api.c @@ -3561,7 +3561,7 @@ extern SaAisErrorT immsv_om_admo_handle_ const SaImmAdminOwnerNameT adminOwnerName, SaImmAdminOwnerHandleT *adminOwnerHandle) __attribute__((weak)); -extern SaAisErrorT immsv_om_handle_finalize( +extern void immsv_om_handle_finalize( SaImmHandleT privateOmHandle) __attribute__((weak)); static SaAisErrorT -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 0 of 1] Review Request for imm: Fix external linkage in OI library [#2167]
Summary: imm: Fix external linkage in OI library [#2167] Review request for Trac Ticket(s): 2167 Peer Reviewer(s): Zoran, Neel Pull request to: Affected branch(es): 5.0, 5.1, 5.2 Development branch: 5.2 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): - changeset 73e7264e41a3384b920d4bbb7dd9fcd3384ef6d1 Author: Hung NguyenDate: Fri, 04 Nov 2016 11:40:41 +0700 imm: Fix external linkage in OI library [#2167] Fix external linkage in OI library. Complete diffstat: -- osaf/libs/agents/saf/imma/imma_oi_api.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Testing Commands: - Testing, Expected Results: -- Conditions of Submission: - Ack from reviewers. 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 ~/.hgrc file (i.e. username, 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. -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 3] mds: Convert the mds_log.c file to C++ [#2015]
Ack tested. -AVM On 11/3/2016 1:58 PM, Anders Widell wrote: > Hi! > > Yes agreed, using this mechanism also for trace is a logical next > step. It should be fairly easy to implement once this MDS logging > mechanism is fully in place. > > regards, > > Anders Widell > > On 11/03/2016 06:14 AM, A V Mahesh wrote: >> Hi Anders Widell, >> >> >>Using a standardized format means that OpenSAF can more easily be >> used together with third-party log servers and log processing tools. >> >> I know the complexity of implementing , but i putting my proposal : >> >> Even our TRACE`s are not formatted according to the protocol >> described in rfc5424, but they have TRACE level (T5, T8, T2 ) >> >> and any way we are using separate process `osaftransportd` for MDS >> loging, so why don't we use TRACE`s even for MDS logging and let >> us have common logic >> at TRACE library which formatted according to the protocol described >> in rfc5424 based on exported variable like `export >> LOG_FARMAT_RFC5424=true` >> >> -AVM >> >> >> On 11/2/2016 4:59 PM, Anders Widell wrote: >>> See replies inline, marked AndersW>. >>> >>> regards, >>> >>> Anders Widell >>> >>> >>> On 11/02/2016 11:16 AM, A V Mahesh wrote: Hi Anders Widell, Thanks the attached patches works. Following are my initial comments: 1) Based on the current format , user will not be able to distinguished the category of CRITICAL , ERR , NOTIFY , INFO , DBG >>> AndersW> You can distinguish them, but the priority level is >>> presented in a numerical format which arguably is not so >>> human-readable. The reason is that the messages are formatted >>> according to the protocol described in rfc5424. Using a standardized >>> format means that OpenSAF can more easily be used together with >>> third-party log servers and log processing tools. I supposed I could >>> translate the log priority level into a human-readable string before >>> writing the log messages to disk. But this would mean that the >>> format on disk will no longer comply with the rfc, and it would also >>> cost some performance. In most cases the MDS log messages will be >>> rotated away without anyone ever reading them - so instead I would >>> propose to create an offline log parser that can translate the log >>> priority level. This tool could later be extended with filtering >>> capabilities etc. What do you think? <135>1 2016-11-02T15:37:52.179638+05:30 SC-1 osafimmloadd 30875 41517 - << mcm_msg_encode_full_or_flat_and_send <134>1 2016-11-02T15:37:52.179663+05:30 SC-1 osafimmloadd 30875 41518 - MDTM: User Sending Data lenght=384 From svc_id = IMMA_OM(26) to svc_id = IMMND(25) <135>1 2016-11-02T15:37:52.179691+05:30 SC-1 osafimmloadd 30875 41519 - MDTM:Sending message with Service Seqno=695, TO Dest_Tipc_id=<0x01001001:821559312> <134>1 2016-11-02T15:37:52.179716+05:30 SC-1 osafimmloadd 30875 41520 - MDTM: TIPC Sending Len=423 <134>1 2016-11-02T15:37:52.179753+05:30 SC-1 osafimmnd 30642 117944 - MDTM: Data received: Processing data <135>1 2016-11-02T15:37:52.179768+05:30 SC-1 osafimmnd 30642 117945 - MDTM: size: 423 anc is NULL <135>1 2016-11-02T15:37:52.179777+05:30 SC-1 osafimmnd 30642 117946 - >> mds_svc_tbl_get_svc_h We use to have it *DBG/**INFO/***ERR/*NOTIFY ***prefix, let us restore it , other wise it become complex to debug , when `MDS_LOG_LEVEL=5` Nov 15 3:10:10.381033 osafimmnd[3912] *DBG *|MDTM: Recd Unfragmented message with SVC Seq num =810, from src Adest = <72075197334002405> Nov 15 3:10:10.381051 osafimmnd[3912] *INFO *|MDTM: User Recd msg len=56595 Oct 6 11:57:20.040978 osafamfnd[4492] *ERR *|MCM_API : vdest_chg_role : VDEST id = 0 Doesn't exist Oct 6 11:57:20.041824 osafamfnd[4492] *NOTIFY *|MDTM: install_tipc : svc_id = IMMA_OM(26), vdest=65535 2) The new format should be explained in some README `<135>1 2016-11-02T15:37:52.179638+05:30 SC-1 osafimmloadd 30875 41517` >>> AndersW> The format is explained in rfc5424. I can insert a >>> reference to the RFC in some README file. -AVM On 11/2/2016 2:44 PM, Anders Widell wrote: > Hi! > > I tried applying the patches on the latest from
[devel] [PATCH 1 of 5] base: Remove dynamic memory allocation from the Buffer class [#2127]
osaf/libs/core/cplusplus/base/buffer.h | 26 +- osaf/libs/core/cplusplus/base/log_message.cc| 106 - osaf/libs/core/cplusplus/base/log_message.h | 126 +++- osaf/libs/core/cplusplus/base/tests/log_message_test.cc | 14 +- osaf/libs/core/mds/mds_log.cc |4 +- 5 files changed, 141 insertions(+), 135 deletions(-) Make the use of temporary Buffer instances on the stack more efficient, by storing the buffer data in a character array inside the class instead of allocating it dynamically. diff --git a/osaf/libs/core/cplusplus/base/buffer.h b/osaf/libs/core/cplusplus/base/buffer.h --- a/osaf/libs/core/cplusplus/base/buffer.h +++ b/osaf/libs/core/cplusplus/base/buffer.h @@ -25,19 +25,14 @@ namespace base { -// An output buffer that can be used to build e.g. a message to be sent over a -// network. +// An output buffer with enough space to store @a Capacity bytes of data. It can +// be used to build e.g. a message to be sent over a network. +template class Buffer { public: - // Allocate a buffer with enough space to store @a capacity bytes of data. - explicit Buffer(size_t capacity) : - buffer_{new char[capacity]}, - capacity_{capacity}, + Buffer() : size_{0} { } - ~Buffer() { -delete [] buffer_; - } // Reset the write position to the start of the buffer. void clear() { size_ = 0; } // Returns true if the buffer is empty. @@ -45,16 +40,18 @@ class Buffer { // Returns a pointer to the start of the buffer. const char* data() const { return buffer_; } // Returns a pointer to the end of the buffer where new data can be appended. - char* end() const { return buffer_ + size_; } + char* end() { return buffer_ + size_; } + // Returns a read-only pointer to the end of the buffer. + const char* end() const { return buffer_ + size_; } // Returns the number of bytes that have been written to the buffer. size_t size() const { return size_; } // Set new size of the buffer (e.g. after manually adding data at the end). void set_size(size_t s) { size_ = s; } // Returns the maximum number of bytes that can be stored in this buffer. - size_t capacity() const { return capacity_; } + static size_t capacity() { return Capacity; } // Append a single character to the end of the buffer. void AppendChar(char c) { -if (size_ != capacity_) buffer_[size_++] = c; +if (size_ != Capacity) buffer_[size_++] = c; } // This function is similar to AppendNumber(), except that leading zeros will // be printed - i.e. this method implements a fixed field width. @@ -77,7 +74,7 @@ class Buffer { } // Append a string of @a size characters to the end of the buffer. void AppendString(const char* str, size_t size) { -size_t bytes_to_copy = capacity_ - size_; +size_t bytes_to_copy = Capacity - size_; if (size < bytes_to_copy) bytes_to_copy = size; memcpy(buffer_ + size_, str, bytes_to_copy); size_ += bytes_to_copy; @@ -88,9 +85,8 @@ class Buffer { } private: - char* buffer_; - size_t capacity_; size_t size_; + char buffer_[Capacity]; DELETE_COPY_AND_MOVE_OPERATORS(Buffer); }; diff --git a/osaf/libs/core/cplusplus/base/log_message.cc b/osaf/libs/core/cplusplus/base/log_message.cc --- a/osaf/libs/core/cplusplus/base/log_message.cc +++ b/osaf/libs/core/cplusplus/base/log_message.cc @@ -16,115 +16,9 @@ */ #include "osaf/libs/core/cplusplus/base/log_message.h" -#include -#include -#include "osaf/libs/core/common/include/osaf_time.h" -#include "osaf/libs/core/cplusplus/base/buffer.h" -#include "osaf/libs/core/cplusplus/base/time.h" namespace base { const struct timespec LogMessage::kNullTime{0, -1}; -void LogMessage::Write(Facility facility, Severity severity, - const struct timespec& time_stamp, - const HostName& host_name, - const AppName& app_name, - const ProcId& proc_id, - const MsgId& msg_id, - const StructuredElements& structured_elements, - const std::string& message, - Buffer* buffer) { - uint32_t priority = static_cast(facility) * uint32_t{8} - + static_cast(severity); - buffer->AppendChar('<'); - buffer->AppendNumber(priority, 100); - buffer->AppendString(">1 ", 3); - WriteTime(time_stamp, buffer); - buffer->AppendChar(' '); - buffer->AppendString(host_name.data(), host_name.size()); - buffer->AppendChar(' '); - buffer->AppendString(app_name.data(), app_name.size()); - buffer->AppendChar(' '); - buffer->AppendString(proc_id.data(), proc_id.size()); - buffer->AppendChar(' '); - buffer->AppendString(msg_id.data(), msg_id.size()); - buffer->AppendChar(' '); - if (structured_elements.empty()) { -buffer->AppendChar('-'); - } else { -for (const auto& elem : structured_elements)
[devel] [PATCH 4 of 5] mds: Make the MdsLog implementation lock-free [#2127]
osaf/libs/core/mds/include/mds_log.h | 10 osaf/libs/core/mds/mds_log.cc| 37 +++ 2 files changed, 13 insertions(+), 34 deletions(-) Remove the mutex from the MdsLog class, by allocating a temporary Buffer instance on the stack and relying on the newly implemented thread-safety in the UnixSocket class. diff --git a/osaf/libs/core/mds/include/mds_log.h b/osaf/libs/core/mds/include/mds_log.h --- a/osaf/libs/core/mds/include/mds_log.h +++ b/osaf/libs/core/mds/include/mds_log.h @@ -54,15 +54,15 @@ enum { uint32_t mds_log_init(const char *log_file_name); void log_mds_dbg(const char *fmt, ...) -__attribute__ ((format(printf, 1, 2))); +__attribute__((format(printf, 1, 2))); void log_mds_info(const char *fmt, ...) -__attribute__ ((format(printf, 1, 2))); +__attribute__((format(printf, 1, 2))); void log_mds_notify(const char *fmt, ...) -__attribute__ ((format(printf, 1, 2))); +__attribute__((format(printf, 1, 2))); void log_mds_err(const char *fmt, ...) -__attribute__ ((format(printf, 1, 2))); +__attribute__((format(printf, 1, 2))); void log_mds_critical(const char *fmt, ...) -__attribute__ ((format(printf, 1, 2))); +__attribute__((format(printf, 1, 2))); #ifdef __cplusplus } diff --git a/osaf/libs/core/mds/mds_log.cc b/osaf/libs/core/mds/mds_log.cc --- a/osaf/libs/core/mds/mds_log.cc +++ b/osaf/libs/core/mds/mds_log.cc @@ -24,10 +24,10 @@ #include "osaf/libs/core/mds/include/mds_log.h" #include -#include #include #include #include +#include #include #include #include @@ -51,15 +51,12 @@ class MdsLog { private: MdsLog(const char* host_name, const char* app_name, uint32_t proc_id, const char* socket_name); - ~MdsLog(); void LogInternal(base::LogMessage::Severity severity, const char *str); static MdsLog* instance_; - pthread_mutex_t mutex_; - base::LogMessage::HostName host_name_; - base::LogMessage::AppName app_name_; - base::LogMessage::ProcId proc_id_; - uint64_t msg_id_; - base::Buffer<512> buffer_; + const base::LogMessage::HostName host_name_; + const base::LogMessage::AppName app_name_; + const base::LogMessage::ProcId proc_id_; + std::atomic msg_id_; base::UnixClientSocket log_socket_; DELETE_COPY_AND_MOVE_OPERATORS(MdsLog); @@ -70,27 +67,11 @@ MdsLog* MdsLog::instance_ = nullptr; MdsLog::MdsLog(const char* host_name, const char* app_name, uint32_t proc_id, const char* socket_name) : -mutex_{}, host_name_{base::LogMessage::HostName{host_name}}, app_name_{base::LogMessage::AppName{app_name}}, proc_id_{base::LogMessage::ProcId{std::to_string(proc_id)}}, msg_id_{0}, -buffer_{}, log_socket_{socket_name} { - pthread_mutexattr_t attr; - int result = pthread_mutexattr_init(); - if (result != 0) osaf_abort(result); - result = pthread_mutexattr_setprotocol(, PTHREAD_PRIO_INHERIT); - if (result != 0) osaf_abort(result); - result = pthread_mutex_init(_, ); - if (result != 0) osaf_abort(result); - result = pthread_mutexattr_destroy(); - if (result != 0) osaf_abort(result); -} - -MdsLog::~MdsLog() { - int result = pthread_mutex_destroy(_); - if (result != 0) osaf_abort(result); } /* @@ -145,9 +126,8 @@ void MdsLog::Log(base::LogMessage::Sever } void MdsLog::LogInternal(base::LogMessage::Severity severity, const char *str) { - osaf_mutex_lock_ordie(_); uint64_t id = msg_id_++; - buffer_.clear(); + base::Buffer<256> buffer; base::LogMessage::Write(base::LogMessage::Facility::kLocal0, severity, base::ReadRealtimeClock(), @@ -157,9 +137,8 @@ void MdsLog::LogInternal(base::LogMessag base::LogMessage::MsgId{std::to_string(id)}, {}, str, - _); - log_socket_.Send(buffer_.data(), buffer_.size()); - osaf_mutex_unlock_ordie(_); + ); + log_socket_.Send(buffer.data(), buffer.size()); } /*** -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 2 of 5] base: Add a Buffer::Write() method taking a format string and a va_list parameter [#2127]
osaf/libs/core/cplusplus/base/log_message.h | 56 + 1 files changed, 56 insertions(+), 0 deletions(-) Make it possible to send a format string and a va_list to Buffer::Write, so that it can be used more efficiently in a printf-style function. diff --git a/osaf/libs/core/cplusplus/base/log_message.h b/osaf/libs/core/cplusplus/base/log_message.h --- a/osaf/libs/core/cplusplus/base/log_message.h +++ b/osaf/libs/core/cplusplus/base/log_message.h @@ -19,8 +19,10 @@ #define OSAF_LIBS_CORE_CPLUSPLUS_BASE_LOG_MESSAGE_H_ #include +#include #include #include +#include #include #include #include @@ -188,6 +190,17 @@ class LogMessage { const std::string& message, Buffer* buffer); template + static void Write(Facility facility, Severity severity, +const struct timespec& time_stamp, +const HostName& host_name, +const AppName& app_name, +const ProcId& proc_id, +const MsgId& msg_id, +const StructuredElements& structured_elements, +const char* format, +va_list ap, +Buffer* buffer); + template static void WriteTime(const struct timespec& ts, Buffer* buffer); }; @@ -228,6 +241,49 @@ void LogMessage::Write(Facility facility } template +void LogMessage::Write(Facility facility, Severity severity, + const struct timespec& time_stamp, + const HostName& host_name, + const AppName& app_name, + const ProcId& proc_id, + const MsgId& msg_id, + const StructuredElements& structured_elements, + const char* format, + va_list ap, + Buffer* buffer) { + uint32_t priority = static_cast(facility) * uint32_t{8} + + static_cast(severity); + buffer->AppendChar('<'); + buffer->AppendNumber(priority, 100); + buffer->AppendString(">1 ", 3); + WriteTime(time_stamp, buffer); + buffer->AppendChar(' '); + buffer->AppendString(host_name.data(), host_name.size()); + buffer->AppendChar(' '); + buffer->AppendString(app_name.data(), app_name.size()); + buffer->AppendChar(' '); + buffer->AppendString(proc_id.data(), proc_id.size()); + buffer->AppendChar(' '); + buffer->AppendString(msg_id.data(), msg_id.size()); + buffer->AppendChar(' '); + if (structured_elements.empty()) { +buffer->AppendChar('-'); + } else { +for (const auto& elem : structured_elements) elem.Write(buffer); + } + if (format[0] != '\0') { +buffer->AppendChar(' '); +char* buf = buffer->end(); +size_t size = buffer->capacity() - buffer->size(); +int n = vsnprintf(buf, size, format, ap); +if (n >= 0) { + if (static_cast(n) < size) size = n; + buffer->set_size(buffer->size() + size); +} + } +} + +template void LogMessage::WriteTime(const struct timespec& ts, Buffer* buffer) { struct tm local_time; -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 3 of 5] base: Make the UnixSocket class thread-safe [#2127]
osaf/libs/core/cplusplus/base/unix_client_socket.cc | 28 --- osaf/libs/core/cplusplus/base/unix_client_socket.h | 2 +- osaf/libs/core/cplusplus/base/unix_server_socket.cc | 19 +-- osaf/libs/core/cplusplus/base/unix_server_socket.h | 4 +- osaf/libs/core/cplusplus/base/unix_socket.cc| 49 ++--- osaf/libs/core/cplusplus/base/unix_socket.h | 22 ++--- 6 files changed, 74 insertions(+), 50 deletions(-) Make the UnixSocket class thread-safe by protecting Open() and Close() with a mutex. diff --git a/osaf/libs/core/cplusplus/base/unix_client_socket.cc b/osaf/libs/core/cplusplus/base/unix_client_socket.cc --- a/osaf/libs/core/cplusplus/base/unix_client_socket.cc +++ b/osaf/libs/core/cplusplus/base/unix_client_socket.cc @@ -29,24 +29,18 @@ UnixClientSocket::UnixClientSocket(const UnixClientSocket::~UnixClientSocket() { } -void UnixClientSocket::Open() { - if (fd() < 0) { -UnixSocket::Open(); -if (fd() >= 0) { - int result; - int e; - do { -result = connect(fd(), addr(), addrlen()); -e = errno; -if (result != 0 && (e == EALREADY || e == EINPROGRESS)) { - struct timespec delay{0, 1000}; - clock_nanosleep(CLOCK_MONOTONIC, 0, , nullptr); -} - } while (result != 0 && (e == EINTR || e == EALREADY - || e == EINPROGRESS)); - if (result != 0) Close(); +bool UnixClientSocket::OpenHook(int sock) { + int result; + int e; + do { +result = connect(sock, addr(), addrlen()); +e = errno; +if (result != 0 && (e == EALREADY || e == EINPROGRESS)) { + struct timespec delay{0, 1000}; + clock_nanosleep(CLOCK_MONOTONIC, 0, , nullptr); } - } + } while (result != 0 && (e == EINTR || e == EALREADY || e == EINPROGRESS)); + return result == 0; } } // namespace base diff --git a/osaf/libs/core/cplusplus/base/unix_client_socket.h b/osaf/libs/core/cplusplus/base/unix_client_socket.h --- a/osaf/libs/core/cplusplus/base/unix_client_socket.h +++ b/osaf/libs/core/cplusplus/base/unix_client_socket.h @@ -33,7 +33,7 @@ class UnixClientSocket : public UnixSock // from the file system. virtual ~UnixClientSocket(); protected: - virtual void Open(); + virtual bool OpenHook(int sock); }; } // namespace base diff --git a/osaf/libs/core/cplusplus/base/unix_server_socket.cc b/osaf/libs/core/cplusplus/base/unix_server_socket.cc --- a/osaf/libs/core/cplusplus/base/unix_server_socket.cc +++ b/osaf/libs/core/cplusplus/base/unix_server_socket.cc @@ -29,23 +29,12 @@ UnixServerSocket::UnixServerSocket(const UnixServerSocket::~UnixServerSocket() { } -void UnixServerSocket::Open() { - if (fd() < 0) { -UnixSocket::Open(); -if (fd() >= 0) { - int result = bind(fd(), addr(), addrlen()); - if (result != 0) Close(); -} - } +bool UnixServerSocket::OpenHook(int sock) { + return bind(sock, addr(), addrlen()) == 0; } -void UnixServerSocket::Close() { - if (fd() >= 0) { -int e = errno; -UnixSocket::Close(); -unlink(path()); -errno = e; - } +void UnixServerSocket::CloseHook() { + unlink(path()); } } // namespace base diff --git a/osaf/libs/core/cplusplus/base/unix_server_socket.h b/osaf/libs/core/cplusplus/base/unix_server_socket.h --- a/osaf/libs/core/cplusplus/base/unix_server_socket.h +++ b/osaf/libs/core/cplusplus/base/unix_server_socket.h @@ -33,8 +33,8 @@ class UnixServerSocket : public UnixSock // file system. virtual ~UnixServerSocket(); protected: - virtual void Open(); - virtual void Close(); + virtual bool OpenHook(int sock); + virtual void CloseHook(); }; } // namespace base diff --git a/osaf/libs/core/cplusplus/base/unix_socket.cc b/osaf/libs/core/cplusplus/base/unix_socket.cc --- a/osaf/libs/core/cplusplus/base/unix_socket.cc +++ b/osaf/libs/core/cplusplus/base/unix_socket.cc @@ -19,40 +19,75 @@ #include #include #include +#include "osaf/libs/core/common/include/osaf_utility.h" namespace base { UnixSocket::UnixSocket(const std::string& path) : fd_{-1}, -addr_{AF_UNIX, {}} { +addr_{AF_UNIX, {}}, +mutex_{} { if (path.size() < sizeof(addr_.sun_path)) { memcpy(addr_.sun_path, path.c_str(), path.size() + 1); } else { addr_.sun_path[0] = '\0'; } + pthread_mutexattr_t attr; + int result = pthread_mutexattr_init(); + if (result != 0) osaf_abort(result); + result = pthread_mutexattr_setprotocol(, PTHREAD_PRIO_INHERIT); + if (result != 0) osaf_abort(result); + result = pthread_mutex_init(_, ); + if (result != 0) osaf_abort(result); + result = pthread_mutexattr_destroy(); + if (result != 0) osaf_abort(result); } -void UnixSocket::Open() { - if (fd_ < 0) { +int UnixSocket::Open() { + osaf_mutex_lock_ordie(_); + int sock = fd_; + if (sock < 0) { if (addr_.sun_path[0] != '\0') { - fd_ = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); + sock = socket(AF_UNIX, SOCK_DGRAM |
[devel] [PATCH 5 of 5] mds: Use the va_list version of the Buffer::Write() method [#2127]
osaf/libs/core/mds/mds_log.cc | 42 -- 1 files changed, 16 insertions(+), 26 deletions(-) Use the va_list version of Buffer::Write() to avoid the need for formatting the message into a temporary buffer. diff --git a/osaf/libs/core/mds/mds_log.cc b/osaf/libs/core/mds/mds_log.cc --- a/osaf/libs/core/mds/mds_log.cc +++ b/osaf/libs/core/mds/mds_log.cc @@ -46,12 +46,14 @@ class MdsLog { public: static bool Init(); - static void Log(base::LogMessage::Severity severity, const char *str); + static void Log(base::LogMessage::Severity severity, const char *fmt, + va_list ap); private: MdsLog(const char* host_name, const char* app_name, uint32_t proc_id, const char* socket_name); - void LogInternal(base::LogMessage::Severity severity, const char *str); + void LogInternal(base::LogMessage::Severity severity, const char *fmt, + va_list ap); static MdsLog* instance_; const base::LogMessage::HostName host_name_; const base::LogMessage::AppName app_name_; @@ -121,11 +123,13 @@ bool MdsLog::Init() { return instance_ != nullptr; } -void MdsLog::Log(base::LogMessage::Severity severity, const char *str) { - if (instance_ != nullptr) instance_->LogInternal(severity, str); +void MdsLog::Log(base::LogMessage::Severity severity, const char *fmt, + va_list ap) { + if (instance_ != nullptr) instance_->LogInternal(severity, fmt, ap); } -void MdsLog::LogInternal(base::LogMessage::Severity severity, const char *str) { +void MdsLog::LogInternal(base::LogMessage::Severity severity, const char *fmt, + va_list ap) { uint64_t id = msg_id_++; base::Buffer<256> buffer; base::LogMessage::Write(base::LogMessage::Facility::kLocal0, @@ -136,7 +140,8 @@ void MdsLog::LogInternal(base::LogMessag proc_id_, base::LogMessage::MsgId{std::to_string(id)}, {}, - str, + fmt, + ap, ); log_socket_.Send(buffer.data(), buffer.size()); } @@ -167,13 +172,10 @@ uint32_t mds_log_init(const char*) { ***/ void log_mds_critical(const char *fmt, ...) { if (gl_mds_log_level < NCSMDS_LC_CRITICAL) return; - char str[256]; va_list ap; - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); + MdsLog::Log(base::LogMessage::Severity::kCrit, fmt, ap); va_end(ap); - MdsLog::Log(base::LogMessage::Severity::kCrit, str); } /*** @@ -186,13 +188,10 @@ void log_mds_critical(const char *fmt, . ***/ void log_mds_err(const char *fmt, ...) { if (gl_mds_log_level < NCSMDS_LC_ERR) return; - char str[256]; va_list ap; - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); + MdsLog::Log(base::LogMessage::Severity::kErr, fmt, ap); va_end(ap); - MdsLog::Log(base::LogMessage::Severity::kErr, str); } /*** @@ -205,13 +204,10 @@ void log_mds_err(const char *fmt, ...) { ***/ void log_mds_notify(const char *fmt, ...) { if (gl_mds_log_level < NCSMDS_LC_NOTIFY) return; - char str[256]; va_list ap; - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); + MdsLog::Log(base::LogMessage::Severity::kNotice, fmt, ap); va_end(ap); - MdsLog::Log(base::LogMessage::Severity::kNotice, str); } /*** @@ -224,13 +220,10 @@ void log_mds_notify(const char *fmt, ... ***/ void log_mds_info(const char *fmt, ...) { if (gl_mds_log_level < NCSMDS_LC_INFO) return; - char str[256]; va_list ap; - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); + MdsLog::Log(base::LogMessage::Severity::kInfo, fmt, ap); va_end(ap); - MdsLog::Log(base::LogMessage::Severity::kInfo, str); } /*** @@ -244,11 +237,8 @@ void log_mds_info(const char *fmt, ...) ***/ void log_mds_dbg(const char *fmt, ...) { if (gl_mds_log_level < NCSMDS_LC_DBG) return; - char str[256]; va_list ap; - va_start(ap, fmt); - vsnprintf(str, sizeof(str), fmt, ap); + MdsLog::Log(base::LogMessage::Severity::kDebug, fmt, ap); va_end(ap); - MdsLog::Log(base::LogMessage::Severity::kDebug, str); } -- Developer Access Program for
[devel] [PATCH 0 of 5] Review Request for mds: Make the MdsLog implementation lock-free [#2127]
Summary: mds: Make the MdsLog implementation lock-free [#2127] Review request for Trac Ticket(s): 2127 Peer Reviewer(s): Mahesh, Ramesh Pull request to: Affected branch(es): default(5.2) Development branch: default Impacted area Impact y/n Docsn Build systemn 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): - changeset 3ca410774e02b702bde5f1b0adf828874ad489c1 Author: Anders WidellDate: Thu, 03 Nov 2016 17:07:30 +0100 base: Remove dynamic memory allocation from the Buffer class [#2127] Make the use of temporary Buffer instances on the stack more efficient, by storing the buffer data in a character array inside the class instead of allocating it dynamically. changeset d8f626a20254d5d21bdc2fe1c86e920e88d7d4ba Author: Anders Widell Date: Thu, 03 Nov 2016 17:07:39 +0100 base: Add a Buffer::Write() method taking a format string and a va_list parameter [#2127] Make it possible to send a format string and a va_list to Buffer::Write, so that it can be used more efficiently in a printf-style function. changeset 9c8c71b4d740b511234625a6aff4f28bd8bb6120 Author: Anders Widell Date: Thu, 03 Nov 2016 17:07:47 +0100 base: Make the UnixSocket class thread-safe [#2127] Make the UnixSocket class thread-safe by protecting Open() and Close() with a mutex. changeset 72add090922c93c082e3f40543291bdb9b39c8f1 Author: Anders Widell Date: Thu, 03 Nov 2016 17:08:03 +0100 mds: Make the MdsLog implementation lock-free [#2127] Remove the mutex from the MdsLog class, by allocating a temporary Buffer instance on the stack and relying on the newly implemented thread-safety in the UnixSocket class. changeset 426b4b404464d8ad966dd0cca2695e49465637ec Author: Anders Widell Date: Thu, 03 Nov 2016 17:08:11 +0100 mds: Use the va_list version of the Buffer::Write() method [#2127] Use the va_list version of Buffer::Write() to avoid the need for formatting the message into a temporary buffer. Complete diffstat: -- osaf/libs/core/cplusplus/base/buffer.h | 26 --- osaf/libs/core/cplusplus/base/log_message.cc| 106 -- osaf/libs/core/cplusplus/base/log_message.h | 182 +--- osaf/libs/core/cplusplus/base/tests/log_message_test.cc | 14 +- osaf/libs/core/cplusplus/base/unix_client_socket.cc | 28 - osaf/libs/core/cplusplus/base/unix_client_socket.h |2 +- osaf/libs/core/cplusplus/base/unix_server_socket.cc | 19 +++--- osaf/libs/core/cplusplus/base/unix_server_socket.h |4 +- osaf/libs/core/cplusplus/base/unix_socket.cc| 49 - osaf/libs/core/cplusplus/base/unix_socket.h | 22 ++-- osaf/libs/core/mds/include/mds_log.h| 10 +++--- osaf/libs/core/mds/mds_log.cc | 79 ++-- 12 files changed, 298 insertions(+), 243 deletions(-) Testing Commands: - Run regression tests, especially related to MDS logging. Testing, Expected Results: -- Regression tests should pass. Conditions of Submission: - Ack from reviewer(s) 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
[devel] [PATCH 5 of 5] imm: Fix linkage errors [#2142]
osaf/libs/agents/saf/imma/imma_init.cc | 1 - osaf/libs/agents/saf/imma/imma_om_api.cc | 1 - osaf/libs/core/mds/include/mds_dl_api.h | 9 + osaf/libs/saf/libSaImm/Makefile.am | 4 ++-- osaf/libs/saf/libSaImm/libSaImmOm.map| 14 -- 5 files changed, 19 insertions(+), 10 deletions(-) Fix linkage errors. diff --git a/osaf/libs/agents/saf/imma/imma_init.cc b/osaf/libs/agents/saf/imma/imma_init.cc --- a/osaf/libs/agents/saf/imma/imma_init.cc +++ b/osaf/libs/agents/saf/imma/imma_init.cc @@ -23,7 +23,6 @@ **/ -#define _GNU_SOURCE #include #include "imma.h" diff --git a/osaf/libs/agents/saf/imma/imma_om_api.cc b/osaf/libs/agents/saf/imma/imma_om_api.cc --- a/osaf/libs/agents/saf/imma/imma_om_api.cc +++ b/osaf/libs/agents/saf/imma/imma_om_api.cc @@ -36,7 +36,6 @@ TRACE_4 library errors ERR_LIBRARY - aproximates ERROR */ -#define _GNU_SOURCE #include #include diff --git a/osaf/libs/core/mds/include/mds_dl_api.h b/osaf/libs/core/mds/include/mds_dl_api.h --- a/osaf/libs/core/mds/include/mds_dl_api.h +++ b/osaf/libs/core/mds/include/mds_dl_api.h @@ -30,6 +30,11 @@ #include "ncs_lib.h" +#ifdef __cplusplus +extern "C" +{ +#endif + uint32_t mds_lib_req(NCS_LIB_REQ_INFO *req); int mds_auth_server_connect(const char *name, MDS_DEST mds_dest, int svc_id, int64_t timeout); @@ -37,4 +42,8 @@ int mds_auth_server_disconnect(const cha int svc_id, int64_t timeout); int mds_auth_server_create(const char *name); +#ifdef __cplusplus +} #endif + +#endif diff --git a/osaf/libs/saf/libSaImm/Makefile.am b/osaf/libs/saf/libSaImm/Makefile.am --- a/osaf/libs/saf/libSaImm/Makefile.am +++ b/osaf/libs/saf/libSaImm/Makefile.am @@ -35,7 +35,7 @@ libSaImmOi_la_CPPFLAGS = \ if HAVE_LD_VERSION_SCRIPT libSaImmOi_la_LDFLAGS = \ -Wl,-version-script=$(top_srcdir)/osaf/libs/saf/libSaImm/libSaImmOi.map \ - -version-number $(OILIB_VERSION) + -version-number $(OILIB_VERSION) -lstdc++ else libSaImmOi_la_LDFLAGS = \ -version-number $(OILIB_VERSION) @@ -56,7 +56,7 @@ libSaImmOm_la_CPPFLAGS = \ if HAVE_LD_VERSION_SCRIPT libSaImmOm_la_LDFLAGS = \ -Wl,-version-script=$(top_srcdir)/osaf/libs/saf/libSaImm/libSaImmOm.map \ - -version-number $(OMLIB_VERSION) + -version-number $(OMLIB_VERSION) -lstdc++ else libSaImmOm_la_LDFLAGS = \ -version-number $(OMLIB_VERSION) diff --git a/osaf/libs/saf/libSaImm/libSaImmOm.map b/osaf/libs/saf/libSaImm/libSaImmOm.map --- a/osaf/libs/saf/libSaImm/libSaImmOm.map +++ b/osaf/libs/saf/libSaImm/libSaImmOm.map @@ -10,12 +10,14 @@ OPENSAF_IMM_A.02.01 { saImmOm*; immsv_finalize_sync;# FIXME immsv* should be in libimmsv_common.so immsv_sync; - immsv_om_augment_ccb_initialize; - immsv_om_augment_ccb_get_result; - immsv_om_augment_ccb_get_admo_name; - immsv_om_handle_initialize; - immsv_om_admo_handle_initialize; - immsv_om_handle_finalize; + extern "C++" { + "immsv_om_handle_initialize(unsigned long long*, SaVersionT*)"; + "immsv_om_handle_finalize(unsigned long long)"; + "immsv_om_admo_handle_initialize(unsigned long long, char*, unsigned long long*)"; + "immsv_om_augment_ccb_initialize(unsigned long long, unsigned int, unsigned int, unsigned long long*, unsigned long long*)"; + "immsv_om_augment_ccb_get_admo_name(unsigned long long, SaNameT*, SaNameT*)"; + "immsv_om_augment_ccb_get_result(unsigned long long, unsigned int)" + }; local: *; }; -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 2 of 5] imm: Fix "crosses initialization" errors [#2142]
osaf/libs/agents/saf/imma/imma_db.cc | 3 +-- osaf/libs/agents/saf/imma/imma_oi_api.cc | 7 +++ osaf/libs/agents/saf/imma/imma_om_api.cc | 24 +--- osaf/libs/agents/saf/imma/imma_proc.cc | 6 -- 4 files changed, 21 insertions(+), 19 deletions(-) Fix "crosses initialization" errors. diff --git a/osaf/libs/agents/saf/imma/imma_db.cc b/osaf/libs/agents/saf/imma/imma_db.cc --- a/osaf/libs/agents/saf/imma/imma_db.cc +++ b/osaf/libs/agents/saf/imma/imma_db.cc @@ -1346,10 +1346,9 @@ SaStringT* imma_getErrorStrings(IMMSV_SA { unsigned int listSize = 0; SaStringT* errStringArr=NULL; + IMMSV_ATTR_NAME_LIST* errStrs = errRsp->errStrings; if(errRsp->errStrings == NULL) {goto done;} - IMMSV_ATTR_NAME_LIST* errStrs = errRsp->errStrings; - while(errStrs) { ++listSize; errStrs = errStrs->next; diff --git a/osaf/libs/agents/saf/imma/imma_oi_api.cc b/osaf/libs/agents/saf/imma/imma_oi_api.cc --- a/osaf/libs/agents/saf/imma/imma_oi_api.cc +++ b/osaf/libs/agents/saf/imma/imma_oi_api.cc @@ -895,6 +895,9 @@ static SaAisErrorT admin_op_result_commo uint32_t proc_rc = NCSCC_RC_SUCCESS; bool locked = true; bool errStringPar = false; + /* Note NOT unsigned since negative means async invoc. */ + SaInt32T inv = m_IMMSV_UNPACK_HANDLE_LOW(invocation); + SaInt32T owner = m_IMMSV_UNPACK_HANDLE_HIGH(invocation); TRACE_ENTER(); if (cb->sv_id == 0) { @@ -972,10 +975,6 @@ static SaAisErrorT admin_op_result_commo } - /* Note NOT unsigned since negative means async invoc. */ - SaInt32T inv = m_IMMSV_UNPACK_HANDLE_LOW(invocation); - SaInt32T owner = m_IMMSV_UNPACK_HANDLE_HIGH(invocation); - /* populate the structure */ memset(_evt, 0, sizeof(IMMSV_EVT)); adminOpRslt_evt.type = IMMSV_EVT_TYPE_IMMND; diff --git a/osaf/libs/agents/saf/imma/imma_om_api.cc b/osaf/libs/agents/saf/imma/imma_om_api.cc --- a/osaf/libs/agents/saf/imma/imma_om_api.cc +++ b/osaf/libs/agents/saf/imma/imma_om_api.cc @@ -1605,6 +1605,7 @@ static SaAisErrorT ccb_object_create_com SaImmHandleT immHandle=0LL; SaUint32T adminOwnerId = 0; SaStringT *newErrorStrings = NULL; + size_t parentNameLength = 0; TRACE_ENTER(); if (cb->sv_id == 0) { @@ -1840,7 +1841,6 @@ static SaAisErrorT ccb_object_create_com } strncpy(evt.info.immnd.info.objCreate.className.buf, className, evt.info.immnd.info.objCreate.className.size); - size_t parentNameLength = 0; if(parentName) { if(!osaf_is_extended_name_valid(parentName)) { rc = SA_AIS_ERR_INVALID_PARAM; @@ -3827,10 +3827,9 @@ static SaAisErrorT admin_op_invoke_commo evt.info.immnd.info.admOpReq.objectName.buf = (char *)objectName; osafassert(evt.info.immnd.info.admOpReq.params == NULL); - const SaImmAdminOperationParamsT_2 *param = NULL; int i; for (i = 0; params[i]; ++i) { - param = params[i]; + const SaImmAdminOperationParamsT_2 *param = params[i]; /*alloc-2 */ IMMSV_ADMIN_OPERATION_PARAM *p = malloc(sizeof(IMMSV_ADMIN_OPERATION_PARAM)); memset(p, 0, sizeof(IMMSV_ADMIN_OPERATION_PARAM)); @@ -4599,6 +4598,10 @@ SaAisErrorT saImmOmClassCreate_2(SaImmHa IMMSV_ATTR_DEF_LIST *sysattr = NULL; const SaImmAttrDefinitionT_2 *attr; int i; + int persistent = 0; + int attrClNameExist = 0; + int attrAdmNameExist = 0; + int attrImplNameExist = 0; TRACE_ENTER(); if (cb->sv_id == 0) { @@ -4751,11 +4754,7 @@ SaAisErrorT saImmOmClassCreate_2(SaImmHa evt.info.immnd.info.classDescr.classCategory = classCategory; TRACE("name: %s category:%u", className, classCategory); - int persistent = 0; attr = attrDefinitions[0]; - int attrClNameExist = 0; - int attrAdmNameExist = 0; - int attrImplNameExist = 0; for (i = 0; attr != 0; attr = attrDefinitions[++i]) { /* Ignore system attribute definitions that are loaded since they are indistinguishable from being set @@ -5759,6 +5758,8 @@ static SaAisErrorT accessor_get_common(S IMMSV_EVT evt; IMMSV_EVT *out_evt = NULL; SaTimeT timeout; + IMMSV_OM_SEARCH_INIT *req = NULL; + SaImmHandleT immHandle; TRACE_ENTER(); @@ -5810,7 +5811,7 @@ static SaAisErrorT accessor_get_common(S goto release_lock; } - SaImmHandleT immHandle = search_node->mImmHandle; + immHandle = search_node->mImmHandle; imma_client_node_get(>client_tree, , _node); if (!(cl_node && cl_node->isOm)) { @@ -5869,7 +5870,7 @@ static SaAisErrorT accessor_get_common(S memset(, 0, sizeof(IMMSV_EVT)); evt.type = IMMSV_EVT_TYPE_IMMND;
[devel] [PATCH 4 of 5] imm: Fix "comparison between signed and unsigned integer" errors [#2142]
osaf/libs/agents/saf/imma/imma_cb.h | 2 +- osaf/libs/agents/saf/imma/imma_db.cc | 2 +- osaf/libs/agents/saf/imma/imma_oi_api.cc | 2 +- osaf/libs/agents/saf/imma/imma_proc.cc | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) Fix "comparison between signed and unsigned integer" errors. diff --git a/osaf/libs/agents/saf/imma/imma_cb.h b/osaf/libs/agents/saf/imma/imma_cb.h --- a/osaf/libs/agents/saf/imma/imma_cb.h +++ b/osaf/libs/agents/saf/imma/imma_cb.h @@ -123,7 +123,7 @@ typedef struct imma_search_node { } IMMA_SEARCH_NODE; typedef struct imma_continuation_record { - SaUint32T invocation; + SaInt32T invocation; SaInvocationT userInvoc; SaImmHandleT immHandle; struct imma_continuation_record *next; diff --git a/osaf/libs/agents/saf/imma/imma_db.cc b/osaf/libs/agents/saf/imma/imma_db.cc --- a/osaf/libs/agents/saf/imma/imma_db.cc +++ b/osaf/libs/agents/saf/imma/imma_db.cc @@ -1380,7 +1380,7 @@ void imma_freeSearchAttrs(SaImmAttrValue SaImmAttrValuesT_2 *att = NULL; int ix; for (ix = 0; attr[ix]; ++ix) { - int ix2; + SaUint32T ix2; att = attr[ix]; free(att->attrName);/*free-3 */ diff --git a/osaf/libs/agents/saf/imma/imma_oi_api.cc b/osaf/libs/agents/saf/imma/imma_oi_api.cc --- a/osaf/libs/agents/saf/imma/imma_oi_api.cc +++ b/osaf/libs/agents/saf/imma/imma_oi_api.cc @@ -2920,7 +2920,7 @@ static SaAisErrorT rt_object_create_comm TRACE("RtObjectCreate ignoring attribute %s with no values", attr->attrName); continue; } else if(attr->attrValueType == SA_IMM_ATTR_SANAMET) { - int n; + SaUint32T n; for(n=0; nattrValuesNumber; n++) { if(!osaf_is_extended_name_valid((SaNameT*) attr->attrValues[n])) { rc = SA_AIS_ERR_INVALID_PARAM; diff --git a/osaf/libs/agents/saf/imma/imma_proc.cc b/osaf/libs/agents/saf/imma/imma_proc.cc --- a/osaf/libs/agents/saf/imma/imma_proc.cc +++ b/osaf/libs/agents/saf/imma/imma_proc.cc @@ -2461,7 +2461,7 @@ static bool imma_process_callback_info(I free(attr[i]->attrName); /*free-3 */ attr[i]->attrName = 0; if (attr[i]->attrValuesNumber) { - int j; + SaUint32T j; for (j = 0; j < attr[i]->attrValuesNumber; ++j) { imma_freeAttrValue3(attr[i]->attrValues[j], attr[i]->attrValueType);/*free-5 */ attr[i]->attrValues[j] = 0; @@ -2854,7 +2854,7 @@ static bool imma_process_callback_info(I free(attr[i]->modAttr.attrName);/*free-3 */ attr[i]->modAttr.attrName = 0; if (attr[i]->modAttr.attrValuesNumber) { - int j; + SaUint32T j; for (j = 0; j < attr[i]->modAttr.attrValuesNumber; ++j) { imma_freeAttrValue3(attr[i]->modAttr.attrValues[j], attr[i]->modAttr.attrValueType);/*free-5 */ -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 0 of 5] Review Request for imm: Compile the IMM library using the C++ compiler [#2142]
Summary: imm: Compile the IMM library using the C++ compiler [#2142] Review request for Trac Ticket(s): 2142 Peer Reviewer(s): Zoran, Neel Pull request to: Affected branch(es): 5.2 Development branch: 5.2 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): - changeset 2a00f46102c46d227d6050fe8991d88eb86b903f Author: Hung NguyenDate: Wed, 02 Nov 2016 11:23:40 +0700 imm: Compile the IMM library using the C++ compiler [#2142] Compile the IMM library using the C++ compiler. changeset 48f7f2ba7b9d4d091d0e230fc1d55e724e8fc628 Author: Hung Nguyen Date: Wed, 02 Nov 2016 11:23:40 +0700 imm: Fix "crosses initialization" errors [#2142] Fix "crosses initialization" errors. changeset 4539872836e8771009194bb02881e21d9ad68135 Author: Hung Nguyen Date: Wed, 02 Nov 2016 11:23:40 +0700 imm: Fix "invalid conversion" errors. [#2142] Fix "invalid conversion" errors. changeset 4feae1a1f865c5e1ca1db15d49dc0c53a5e60588 Author: Hung Nguyen Date: Wed, 02 Nov 2016 11:23:40 +0700 imm: Fix "comparison between signed and unsigned integer" errors [#2142] Fix "comparison between signed and unsigned integer" errors. changeset 32c3655fbd2baa8b9e87dbba6c6834135d573d97 Author: Hung Nguyen Date: Wed, 02 Nov 2016 11:23:40 +0700 imm: Fix linkage errors [#2142] Fix linkage errors. Complete diffstat: -- osaf/libs/agents/saf/imma/Makefile.am | 24 - osaf/libs/agents/saf/imma/imma_cb.h |2 +- osaf/libs/agents/saf/imma/imma_db.c | 12 -- osaf/libs/agents/saf/imma/imma_init.c |5 +--- osaf/libs/agents/saf/imma/imma_mds.c|4 +- osaf/libs/agents/saf/imma/imma_oi_api.c | 43 +++--- osaf/libs/agents/saf/imma/imma_om_api.c | 169 osaf/libs/agents/saf/imma/imma_proc.c | 106 --- osaf/libs/agents/saf/imma/imma_proc.h |8 +++--- osaf/libs/core/mds/include/mds_dl_api.h |9 osaf/libs/saf/libSaImm/Makefile.am |4 +- osaf/libs/saf/libSaImm/libSaImmOm.map | 14 +++- 12 files changed, 206 insertions(+), 194 deletions(-) Testing Commands: - Testing, Expected Results: -- Conditions of Submission: - Ack from reviewers. 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
[devel] [PATCH 1 of 5] imm: Compile the IMM library using the C++ compiler [#2142]
osaf/libs/agents/saf/imma/Makefile.am | 24 ++-- osaf/libs/agents/saf/imma/imma_db.c | 0 osaf/libs/agents/saf/imma/imma_init.c | 0 osaf/libs/agents/saf/imma/imma_mds.c| 0 osaf/libs/agents/saf/imma/imma_oi_api.c | 0 osaf/libs/agents/saf/imma/imma_om_api.c | 0 osaf/libs/agents/saf/imma/imma_proc.c | 0 7 files changed, 14 insertions(+), 10 deletions(-) Compile the IMM library using the C++ compiler. diff --git a/osaf/libs/agents/saf/imma/Makefile.am b/osaf/libs/agents/saf/imma/Makefile.am --- a/osaf/libs/agents/saf/imma/Makefile.am +++ b/osaf/libs/agents/saf/imma/Makefile.am @@ -27,6 +27,8 @@ noinst_HEADERS = \ noinst_LTLIBRARIES = libimmaOm.la libimmaOi.la +libimmaOm_la_CXXFLAGS = $(AM_CXXFLAGS) + libimmaOm_la_CPPFLAGS = \ -DIMMA_OM -DSA_EXTENDED_NAME_SOURCE \ $(AM_CPPFLAGS) \ @@ -35,11 +37,13 @@ libimmaOm_la_CPPFLAGS = \ libimmaOm_la_LDFLAGS = -static libimmaOm_la_SOURCES = \ - imma_om_api.c \ - imma_db.c \ - imma_init.c \ - imma_mds.c \ - imma_proc.c + imma_om_api.cc \ + imma_db.cc \ + imma_init.cc \ + imma_mds.cc \ + imma_proc.cc + +libimmaOi_la_CXXFLAGS = $(AM_CXXFLAGS) libimmaOi_la_CPPFLAGS = \ -DIMMA_OI -DSA_EXTENDED_NAME_SOURCE \ @@ -49,8 +53,8 @@ libimmaOi_la_CPPFLAGS = \ libimmaOi_la_LDFLAGS = -static libimmaOi_la_SOURCES = \ - imma_oi_api.c \ - imma_db.c \ - imma_init.c \ - imma_mds.c \ - imma_proc.c + imma_oi_api.cc \ + imma_db.cc \ + imma_init.cc \ + imma_mds.cc \ + imma_proc.cc diff --git a/osaf/libs/agents/saf/imma/imma_db.c b/osaf/libs/agents/saf/imma/imma_db.cc rename from osaf/libs/agents/saf/imma/imma_db.c rename to osaf/libs/agents/saf/imma/imma_db.cc diff --git a/osaf/libs/agents/saf/imma/imma_init.c b/osaf/libs/agents/saf/imma/imma_init.cc rename from osaf/libs/agents/saf/imma/imma_init.c rename to osaf/libs/agents/saf/imma/imma_init.cc diff --git a/osaf/libs/agents/saf/imma/imma_mds.c b/osaf/libs/agents/saf/imma/imma_mds.cc rename from osaf/libs/agents/saf/imma/imma_mds.c rename to osaf/libs/agents/saf/imma/imma_mds.cc diff --git a/osaf/libs/agents/saf/imma/imma_oi_api.c b/osaf/libs/agents/saf/imma/imma_oi_api.cc rename from osaf/libs/agents/saf/imma/imma_oi_api.c rename to osaf/libs/agents/saf/imma/imma_oi_api.cc diff --git a/osaf/libs/agents/saf/imma/imma_om_api.c b/osaf/libs/agents/saf/imma/imma_om_api.cc rename from osaf/libs/agents/saf/imma/imma_om_api.c rename to osaf/libs/agents/saf/imma/imma_om_api.cc diff --git a/osaf/libs/agents/saf/imma/imma_proc.c b/osaf/libs/agents/saf/imma/imma_proc.cc rename from osaf/libs/agents/saf/imma/imma_proc.c rename to osaf/libs/agents/saf/imma/imma_proc.cc -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1 of 1] amfd: add support of saAmfSUAssignedSIs [#905]
osaf/services/saf/amf/amfd/imm.cc| 63 osaf/services/saf/amf/amfd/include/imm.h | 7 +++ osaf/services/saf/amf/amfd/su.cc | 31 --- 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/osaf/services/saf/amf/amfd/imm.cc b/osaf/services/saf/amf/amfd/imm.cc --- a/osaf/services/saf/amf/amfd/imm.cc +++ b/osaf/services/saf/amf/amfd/imm.cc @@ -1635,6 +1635,69 @@ SaAisErrorT avd_saImmOiRtObjectUpdate_sy } /** + * IM object update, BLOCKING. It updates multivalue attributes. + * @param dn + * @param attributeName + * @param attrValueType + * @param attrValues + * @param assigned_si + */ +SaAisErrorT avd_saImmOiRtObjectUpdate_multival_sync(const std::string& dn, SaImmAttrNameT attributeName, + SaImmValueTypeT attrValueType, SaImmAttrValueT *attrValues, uint32_t assigned_si, + SaImmAttrModificationTypeT modifyType) +{ + SaAisErrorT rc; + SaImmAttrModificationT_2 attrMod; + const SaImmAttrModificationT_2 *attrMods[] = {, nullptr}; + + TRACE_ENTER2("'%s' %s", dn.c_str(), attributeName); + + attrMod.modType = modifyType; + attrMod.modAttr.attrName = attributeName; + attrMod.modAttr.attrValuesNumber = assigned_si; + attrMod.modAttr.attrValueType = attrValueType; + attrMod.modAttr.attrValues = attrValues; + + rc = saImmOiRtObjectUpdate_o3(avd_cb->immOiHandle, dn.c_str(), attrMods); + if (rc != SA_AIS_OK) { + LOG_WA("saImmOiRtObjectUpdate of '%s' %s failed with %u", + dn.c_str(), attributeName, rc); + } + return rc; +} + + +/** + * IM object update, BLOCKING. It replaces the attr values to null. + * @param dn + * @param attributeName + * @param attrValueType + * @param value + */ +SaAisErrorT avd_saImmOiRtObjectUpdate_replace_sync(const std::string& dn, SaImmAttrNameT attributeName, + SaImmValueTypeT attrValueType, void *value, + SaImmAttrModificationTypeT modifyType) +{ + SaAisErrorT rc; + SaImmAttrModificationT_2 attrMod; + const SaImmAttrModificationT_2 *attrMods[] = {, nullptr}; + + TRACE_ENTER2("'%s' %s", dn.c_str(), attributeName); + + attrMod.modType = SA_IMM_ATTR_VALUES_REPLACE; + attrMod.modAttr.attrName = attributeName; + attrMod.modAttr.attrValuesNumber = 0; + attrMod.modAttr.attrValueType = attrValueType; + + rc = saImmOiRtObjectUpdate_o3(avd_cb->immOiHandle, dn.c_str(), attrMods); + if (rc != SA_AIS_OK) { + LOG_WA("saImmOiRtObjectUpdate of '%s' %s failed with %u", + dn.c_str(), attributeName, rc); + } + return rc; +} + +/** * @brief As of now standby AMFD will maintain immjobs for object of few classes. * This function checks if immjobs for this object can be maintained at standby. * diff --git a/osaf/services/saf/amf/amfd/include/imm.h b/osaf/services/saf/amf/amfd/include/imm.h --- a/osaf/services/saf/amf/amfd/include/imm.h +++ b/osaf/services/saf/amf/amfd/include/imm.h @@ -153,6 +153,13 @@ extern unsigned int avd_imm_config_get(v extern SaAisErrorT avd_saImmOiRtObjectUpdate_sync(const std::string& dn, SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, void *value, SaImmAttrModificationTypeT modifyType = SA_IMM_ATTR_VALUES_REPLACE); +extern SaAisErrorT avd_saImmOiRtObjectUpdate_multival_sync(const std::string& dn, + SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, SaImmAttrValueT *value, + uint32_t assigned_si, + SaImmAttrModificationTypeT modifyType = SA_IMM_ATTR_VALUES_REPLACE); +extern SaAisErrorT avd_saImmOiRtObjectUpdate_replace_sync(const std::string& dn, + SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, void *value, + SaImmAttrModificationTypeT modifyType = SA_IMM_ATTR_VALUES_REPLACE); extern void avd_saImmOiRtObjectUpdate(const std::string& dn, const std::string& attributeName, SaImmValueTypeT attrValueType, void* value); extern void avd_saImmOiRtObjectCreate(const std::string& lassName, diff --git a/osaf/services/saf/amf/amfd/su.cc b/osaf/services/saf/amf/amfd/su.cc --- a/osaf/services/saf/amf/amfd/su.cc +++ b/osaf/services/saf/amf/amfd/su.cc @@ -1390,12 +1390,31 @@ static SaAisErrorT su_rt_attr_cb(SaImmOi while ((attributeName = attributeNames[i++]) != nullptr) { if (!strcmp("saAmfSUAssignedSIs", attributeName)) { -#if 0 - /* TODO */ - SaUint32T saAmfSUAssignedSIs = su->saAmfSUNumCurrActiveSIs + su->saAmfSUNumCurrStandbySIs; - avd_saImmOiRtObjectUpdate_sync(immOiHandle, objectName, - attributeName, SA_IMM_ATTR_SAUINT32T, ); -#endif + if (su->list_of_susi != nullptr) { +
[devel] [PATCH 0 of 1] Review Request for amfd: add support of saAmfSUAssignedSIs [#905]
Summary: amfd: add support of saAmfSUAssignedSIs [#905] Review request for Trac Ticket(s): #905 Peer Reviewer(s): Amf Dev Pull request to: <> Affected branch(es): Default Development branch: Default 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): - <> changeset 3bcdf574f912fc71c6f6f27c4e3ee3bccd80af80 Author: Nagendra KumarDate: Thu, 03 Nov 2016 14:57:52 +0530 amfd: add support of saAmfSUAssignedSIs [#905] Complete diffstat: -- osaf/services/saf/amf/amfd/imm.cc| 63 +++ osaf/services/saf/amf/amfd/include/imm.h | 7 +++ osaf/services/saf/amf/amfd/su.cc | 31 +-- 3 files changed, 95 insertions(+), 6 deletions(-) Testing Commands: - 1. SU1 is Act and SU2 is Standby having 4 SIs each. immlist safSu=SU1,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs=safSi=AmfDemo1,safApp=AmfDemo1:safSi=AmfDemo2,safApp=AmfDemo1:safSi=AmfDemo3,safApp=AmfDemo1:safSi=AmfDemo4,safApp=AmfDemo1 immlist safSu=SU2,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs=safSi=AmfDemo1,safApp=AmfDemo1:safSi=AmfDemo2,safApp=AmfDemo1:safSi=AmfDemo3,safApp=AmfDemo1:safSi=AmfDemo4,safApp=AmfDemo1 2. Lock SU1. There is no susi on SU1. immlist safSu=SU1,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs= immlist safSu=SU2,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs=safSi=AmfDemo1,safApp=AmfDemo1:safSi=AmfDemo2,safApp=AmfDemo1:safSi=AmfDemo3,safApp=AmfDemo1:safSi=AmfDemo4,safApp=AmfDemo1 3. Unlock SU1 and lock SI2. There is no SI2 assignments below. immlist safSu=SU1,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs=safSi=AmfDemo1,safApp=AmfDemo1:safSi=AmfDemo3,safApp=AmfDemo1:safSi=AmfDemo4,safApp=AmfDemo1 immlist safSu=SU2,safSg=AmfDemo_2N,safApp=AmfDemo1 -a saAmfSUAssignedSIs saAmfSUAssignedSIs=safSi=AmfDemo1,safApp=AmfDemo1:safSi=AmfDemo3,safApp=AmfDemo1:safSi=AmfDemo4,safApp=AmfDemo1 Testing, Expected Results: -- As shown above. Conditions of Submission: - Ack from Amf Dev 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 ~/.hgrc file (i.e. username, email etc) ___ Your computer have a badly configured date and
Re: [devel] [PATCH 2 of 3] base: Unit tests for FileNotify V4 [#2091]
Ack. Thanks, Ramesh. On 10/27/2016 8:55 PM, Hans Nordeback wrote: > osaf/libs/core/cplusplus/base/tests/Makefile.am | 7 +- > osaf/libs/core/cplusplus/base/tests/file_notify_test.cc | 83 > + > 2 files changed, 88 insertions(+), 2 deletions(-) > > > diff --git a/osaf/libs/core/cplusplus/base/tests/Makefile.am > b/osaf/libs/core/cplusplus/base/tests/Makefile.am > --- a/osaf/libs/core/cplusplus/base/tests/Makefile.am > +++ b/osaf/libs/core/cplusplus/base/tests/Makefile.am > @@ -33,7 +33,8 @@ libbase_test_LDFLAGS = \ > -pthread -lrt \ > $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-getenv.o \ > $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-log_message.o \ > - $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-process.o > + $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-process.o \ > + $(top_builddir)/osaf/libs/core/cplusplus/base/libbase_la-file_notify.o > > libbase_test_SOURCES = \ > getenv_test.cc \ > @@ -44,8 +45,10 @@ libbase_test_SOURCES = \ > time_add_test.cc \ > time_compare_test.cc \ > time_convert_test.cc \ > + file_notify_test.cc \ > time_subtract_test.cc > > libbase_test_LDADD = \ > $(GTEST_DIR)/lib/libgtest.la \ > - $(GTEST_DIR)/lib/libgtest_main.la > + $(GTEST_DIR)/lib/libgtest_main.la \ > + $(top_builddir)/osaf/libs/core/libopensaf_core.la > diff --git a/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc > b/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc > new file mode 100644 > --- /dev/null > +++ b/osaf/libs/core/cplusplus/base/tests/file_notify_test.cc > @@ -0,0 +1,83 @@ > +/* -*- OpenSAF -*- > + * > + * (C) Copyright 2016 The OpenSAF Foundation > + * > + * 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. > + * > + * Author(s): Ericsson AB > + * > + */ > + > +#include "base/file_notify.h" > +#include "gtest/gtest.h" > + > +class FileNotifyTest : public ::testing::Test { > + protected: > + FileNotifyTest() { > +// Setup work can be done here for each test. > + } > + > + virtual ~FileNotifyTest() { > +// Cleanup work that doesn't throw exceptions here. > + } > + > + // If the constructor and destructor are not enough for setting up > + // and cleaning up each test, you can define the following methods: > + > + // cppcheck-suppress unusedFunction > + virtual void SetUp() { > +// Code here will be called immediately after the constructor (right > +// before each test). > + } > + > + // cppcheck-suppress unusedFunction > + virtual void TearDown() { > +// Code here will be called immediately after each test (right > +// before the destructor). > + } > + > + // Objects declared here can be used by all tests in the test case. > + base::FileNotify::FileNotifyErrors > rc{base::FileNotify::FileNotifyErrors::kOK}; > +}; > + > +// > +TEST_F(FileNotifyTest, TestNonExistingPathCreation) { > + base::FileNotify file_notify; > + std::string non_existing_file = "/a/b/c"; > + > + rc = file_notify.WaitForFileCreation(non_existing_file, 10); > + ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kError); > +} > + > +// > +TEST_F(FileNotifyTest, TestExistingFileCreation) { > + base::FileNotify file_notify; > + std::string existing_file = __FILE__; > + > + rc = file_notify.WaitForFileCreation(existing_file, 10); > + ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kOK); > +} > + > +// > +TEST_F(FileNotifyTest, TestNonExistingPathDeletion) { > + base::FileNotify file_notify; > + std::string non_existing_path = "/a/b/c"; > + > + rc = file_notify.WaitForFileDeletion(non_existing_path, 10); > + ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kOK); > +} > + > +TEST_F(FileNotifyTest, TestExistingFileDeletion) { > + base::FileNotify file_notify; > + std::string existing_file = __FILE__; > + > + rc = file_notify.WaitForFileDeletion(existing_file, 10); > + ASSERT_EQ(rc, base::FileNotify::FileNotifyErrors::kTimeOut); > +} -- Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 3] base: Use inotify to improve response time for transport monitor process V4 [#2091]
Ack with very minor comments inline. Regards, Ramesh. On 10/27/2016 8:55 PM, Hans Nordeback wrote: > osaf/libs/core/cplusplus/base/Makefile.am|2 + > osaf/libs/core/cplusplus/base/file_notify.cc | 190 > +++ > osaf/libs/core/cplusplus/base/file_notify.h | 102 ++ > 3 files changed, 294 insertions(+), 0 deletions(-) > > > diff --git a/osaf/libs/core/cplusplus/base/Makefile.am > b/osaf/libs/core/cplusplus/base/Makefile.am > --- a/osaf/libs/core/cplusplus/base/Makefile.am > +++ b/osaf/libs/core/cplusplus/base/Makefile.am > @@ -24,6 +24,7 @@ SUBDIRS = tests > > noinst_HEADERS = \ > buffer.h \ > + file_notify.h \ > getenv.h \ > log_message.h \ > macros.h \ > @@ -43,6 +44,7 @@ libbase_la_CPPFLAGS = \ > libbase_la_LDFLAGS = -static > > libbase_la_SOURCES = \ > + file_notify.cc \ > getenv.cc \ > log_message.cc \ > process.cc \ > diff --git a/osaf/libs/core/cplusplus/base/file_notify.cc > b/osaf/libs/core/cplusplus/base/file_notify.cc > new file mode 100644 > --- /dev/null > +++ b/osaf/libs/core/cplusplus/base/file_notify.cc > @@ -0,0 +1,190 @@ > +/* -*- OpenSAF -*- > + * > + * (C) Copyright 2016 The OpenSAF Foundation > + * > + * 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. > + * > + * Author(s): Ericsson AB > + * > + */ > + > +#include "base/file_notify.h" > +#include > +#include > +#include > +#include > +#include "time.h" > +#include "osaf_poll.h" > +#include "logtrace.h" > + > +namespace base { > + > +FileNotify::FileNotify() { > + if ((inotify_fd_ = inotify_init()) == -1) { > +LOG_NO("inotify_init failed: %s", strerror(errno)); > + } > +} > + > +FileNotify::~FileNotify() { > + close(inotify_fd_); > +} > + > +void FileNotify::SplitFileName(const std::string _name) { > + char *tmp1 = strdup(file_name.c_str()); > + char *tmp2 = strdup(file_name.c_str()); > + file_path_ = dirname(tmp1); > + file_name_ = basename(tmp2); > + free(tmp1); > + free(tmp2); > +} > + > +FileNotify::FileNotifyErrors > +FileNotify::WaitForFileCreation(const std::string _name, > +const std::vector& user_fds, int > timeout) { > + FileNotify::FileNotifyErrors rc {FileNotifyErrors::kOK}; > + SplitFileName(file_name); > + > + if ((inotify_wd_ = > + inotify_add_watch(inotify_fd_, file_path_.c_str(), IN_CREATE)) == -1) > { > +LOG_NO("inotify_add_watch failed: %s", strerror(errno)); > +return FileNotifyErrors::kError; > + } > + > + if (FileExists(file_name)) { > +TRACE("File already created: %s", file_name.c_str()); > +inotify_rm_watch(inotify_fd_, inotify_wd_); > +return FileNotifyErrors::kOK; > + } [Ramesh]: How about checking FileExists() first i.e., before adding to watch. > + > + rc = ProcessEvents(user_fds, timeout); > + inotify_rm_watch(inotify_fd_, inotify_wd_); > + return rc; > +} > + > +FileNotify::FileNotifyErrors > +FileNotify::WaitForFileDeletion(const std::string _name, > +const std::vector& user_fds, > +int timeout) { > + FileNotify::FileNotifyErrors rc {FileNotifyErrors::kOK}; > + > + if ((inotify_wd_ = inotify_add_watch(inotify_fd_, file_name.c_str(), > + IN_DELETE_SELF)) == -1) { > +if (errno == ENOENT) { > + TRACE("File already deleted: %s", file_name.c_str()); > + return FileNotifyErrors::kOK; > +} else { > + LOG_NO("inotify_add_watch failed: %s", strerror(errno)); > + return FileNotifyErrors::kError; > +} > + } > + > + rc = ProcessEvents(user_fds, timeout); > + inotify_rm_watch(inotify_fd_, inotify_wd_); > + return rc; > +} > + > +FileNotify::FileNotifyErrors > +FileNotify::ProcessEvents(const std::vector& user_fds, int timeout) { > + enum { > +FD_INOTIFY = 0, > + }; > + > + timespec start_time {0}; > + timespec time_left_ts {0}; > + timespec timeout_ts {0}; > + > + int num_of_fds = user_fds.size() + 1; > + pollfd* fds = new pollfd[num_of_fds]; > + > + fds[FD_INOTIFY].fd = inotify_fd_; > + fds[FD_INOTIFY].events = POLLIN; > + for (int i = 1; i < num_of_fds; ++i) { > +fds[i].fd = user_fds[i - 1]; > +fds[i].events = POLLIN; > + } > + > + timeout_ts = base::MillisToTimespec(timeout); > + start_time = base::ReadMonotonicClock(); > + > + while (true) { > +TRACE("remaining timeout: %d", timeout); > +unsigned rc = osaf_poll(fds, num_of_fds, timeout); > + > +if (rc > 0) { > +
Re: [devel] [PATCH 1 of 3] mds: Convert the mds_log.c file to C++ [#2015]
Hi! Yes agreed, using this mechanism also for trace is a logical next step. It should be fairly easy to implement once this MDS logging mechanism is fully in place. regards, Anders Widell On 11/03/2016 06:14 AM, A V Mahesh wrote: > Hi Anders Widell, > > >>Using a standardized format means that OpenSAF can more easily be > used together with third-party log servers and log processing tools. > > I know the complexity of implementing , but i putting my proposal : > > Even our TRACE`s are not formatted according to the protocol > described in rfc5424, but they have TRACE level (T5, T8, T2 ) > > and any way we are using separate process `osaftransportd` for MDS > loging, so why don't we use TRACE`s even for MDS logging and let > us have common logic > at TRACE library which formatted according to the protocol described > in rfc5424 based on exported variable like `export > LOG_FARMAT_RFC5424=true` > > -AVM > > > On 11/2/2016 4:59 PM, Anders Widell wrote: >> See replies inline, marked AndersW>. >> >> regards, >> >> Anders Widell >> >> >> On 11/02/2016 11:16 AM, A V Mahesh wrote: >>> Hi Anders Widell, >>> >>> Thanks the attached patches works. Following are my initial comments: >>> >>> 1) Based on the current format , user will not be able to >>> distinguished the category of CRITICAL , ERR , NOTIFY , INFO , DBG >> AndersW> You can distinguish them, but the priority level is >> presented in a numerical format which arguably is not so >> human-readable. The reason is that the messages are formatted >> according to the protocol described in rfc5424. Using a standardized >> format means that OpenSAF can more easily be used together with >> third-party log servers and log processing tools. I supposed I could >> translate the log priority level into a human-readable string before >> writing the log messages to disk. But this would mean that the format >> on disk will no longer comply with the rfc, and it would also cost >> some performance. In most cases the MDS log messages will be rotated >> away without anyone ever reading them - so instead I would propose to >> create an offline log parser that can translate the log priority >> level. This tool could later be extended with filtering capabilities >> etc. What do you think? >>> >>> >>> >>> >>> >>> <135>1 2016-11-02T15:37:52.179638+05:30 SC-1 osafimmloadd 30875 >>> 41517 - << mcm_msg_encode_full_or_flat_and_send >>> <134>1 2016-11-02T15:37:52.179663+05:30 SC-1 osafimmloadd 30875 >>> 41518 - MDTM: User Sending Data lenght=384 From svc_id = IMMA_OM(26) >>> to svc_id = IMMND(25) >>> <135>1 2016-11-02T15:37:52.179691+05:30 SC-1 osafimmloadd 30875 >>> 41519 - MDTM:Sending message with Service Seqno=695, TO >>> Dest_Tipc_id=<0x01001001:821559312> >>> <134>1 2016-11-02T15:37:52.179716+05:30 SC-1 osafimmloadd 30875 >>> 41520 - MDTM: TIPC Sending Len=423 >>> <134>1 2016-11-02T15:37:52.179753+05:30 SC-1 osafimmnd 30642 117944 >>> - MDTM: Data received: Processing data >>> <135>1 2016-11-02T15:37:52.179768+05:30 SC-1 osafimmnd 30642 117945 >>> - MDTM: size: 423 anc is NULL >>> <135>1 2016-11-02T15:37:52.179777+05:30 SC-1 osafimmnd 30642 117946 >>> - >> mds_svc_tbl_get_svc_h >>> >>> >>> >>> >>> >>> We use to have it *DBG/**INFO/***ERR/*NOTIFY ***prefix, let us >>> restore it , other wise it become complex to debug , when >>> `MDS_LOG_LEVEL=5` >>> >>> >>> >>> >>> >>> Nov 15 3:10:10.381033 osafimmnd[3912] *DBG *|MDTM: Recd >>> Unfragmented message with SVC Seq num =810, from src Adest = >>> <72075197334002405> >>> Nov 15 3:10:10.381051 osafimmnd[3912] *INFO *|MDTM: User Recd msg >>> len=56595 >>> >>> Oct 6 11:57:20.040978 osafamfnd[4492] *ERR *|MCM_API : >>> vdest_chg_role : VDEST id = 0 Doesn't exist >>> Oct 6 11:57:20.041824 osafamfnd[4492] *NOTIFY *|MDTM: install_tipc >>> : svc_id = IMMA_OM(26), vdest=65535 >>> >>> >>> >>> >>> >>> 2) The new format should be explained in some README `<135>1 >>> 2016-11-02T15:37:52.179638+05:30 SC-1 osafimmloadd 30875 41517` >> AndersW> The format is explained in rfc5424. I can insert a reference >> to the RFC in some README file. >>> >>> >>> -AVM >>> >>> >>> On 11/2/2016 2:44 PM, Anders Widell wrote: Hi! I tried applying the patches on the latest from opensaf-staging, and building with GCC 4.8.4. I works for me, so it could be that the patches have been corrupted by the mail system. Please find the patches attached in a tar file.