Re: [devel] [PATCH 2 of 2] AMFND: Fix SC failover during headless sync before standby AMFD comes up [#2162]
Hi Minh, > I have resent to you the missing patches that I received, as I put myself in > reception list. Anyway, I'm checking this problem. We didn't get that also. I think, you have said it before also in #1725 patch context, at that time also, we had not got. Please correct the problem now so that we need not take the patches from source forge. When needed, it is easier to search in mail box, going to source forge is not an easy way. Please re-float the patches again after correcting the problem and let us know. Thanks -Nagu > -Original Message- > From: minh chau [mailto:minh.c...@dektech.com.au] > Sent: 08 November 2016 13:28 > To: Nagendra Kumar; Praveen Malviya; hans.nordeb...@ericsson.com; > gary@dektech.com.au > Cc: opensaf-devel@lists.sourceforge.net > Subject: Re: [PATCH 2 of 2] AMFND: Fix SC failover during headless sync > before standby AMFD comes up [#2162] > > Hi Nagu, Praveen > > Sorry if any inconvenience. All patches have reached sourceforge and those > can be seen in devel mailing list. > I have resent to you the missing patches that I received, as I put myself in > reception list. Anyway, I'm checking this problem. > > Thanks, > Minh > > On 08/11/16 18:26, Nagendra Kumar wrote: > > Hi Minh, > > This is common problem in your patches that only few are > received. Can you please correct it. > > > > Thanks > > -Nagu > > > >> -Original Message- > >> From: praveen malviya > >> Sent: 08 November 2016 12:50 > >> To: Minh Hon Chau; hans.nordeb...@ericsson.com; Nagendra Kumar; > >> gary@dektech.com.au > >> Cc: opensaf-devel@lists.sourceforge.net > >> Subject: Re: [PATCH 2 of 2] AMFND: Fix SC failover during headless > >> sync before standby AMFD comes up [#2162] > >> > >> Hi Minh, > >> > >> Patch 0 and 1 are not received. Please resend. > >> > >> > >> Thanks, > >> Praveen > >> > >> On 08-Nov-16 8:53 AM, Minh Hon Chau wrote: > >>> osaf/services/saf/amf/amfnd/di.cc | 7 +-- > >>> osaf/services/saf/amf/amfnd/susm.cc | 6 ++ > >>> 2 files changed, 11 insertions(+), 2 deletions(-) > >>> > >>> > >>> This case of SC failover causes new active AMFD getting stuck in > >>> node_up messages > >>> > >>> Say first active controller is SC1, which goes down during headless > >>> sync. Therefore, the amfnd on SC2 receives mds_down of AVD, then > >>> both is_avd_down and amfd_sync_required are set to true. When SC2 > >>> takes over active role, amfnd on SC2 receives mds_up, but only > >>> is_avd_down is > >> set to false and the variable amfd_sync_required remains true. > >>> When amfnd-SC2 finishes initiating middleware SU, it needs to send > >>> su_oper message to AMFD, but it is failed to send out due to > >> amfd_sync_required. > >>> In this scenario of SC failover, amfd_sync_required needs to set to > >>> false when amfnd on SC2 receives su_pres message on middleware SUs. > >>> That means amfnd on active controller does not need to wait for > >>> set_leds message, to be informed that cluster initiation is done, so > >>> that amfnd can sen su_oper messages to AMFD. This logic also aligns > >>> with normal headless scenario, where amfnd on active controller has > >>> amfd_sync_required initially marked as false because no middleware > >>> SUs are initiated. When amfd_sync_required is true that means amfnd > >>> all > >> middleware SUs are initiated and assigned before headless, thus amfnd > >> needs to wait for cluster initiation after headless. > >>> diff --git a/osaf/services/saf/amf/amfnd/di.cc > >>> b/osaf/services/saf/amf/amfnd/di.cc > >>> --- a/osaf/services/saf/amf/amfnd/di.cc > >>> +++ b/osaf/services/saf/amf/amfnd/di.cc > >>> @@ -748,7 +748,8 @@ uint32_t avnd_di_oper_send(AVND_CB *cb, > >>> if (avnd_diq_rec_add(cb, &msg) == nullptr) { > >>> rc = NCSCC_RC_FAILURE; > >>> } > >>> - LOG_NO("avnd_di_oper_send() deferred as AMF director is > >> offline"); > >>> + LOG_NO("avnd_di_oper_send() deferred as AMF director is > >> offline(%d)," > >>> + " or sync is required(%d)", cb->is_avd_down, > >>> +cb->amfd_sync_required); > >>> } else { > >>> // We are in normal cluster, send msg to director > >>> msg.info.avd->msg_info.n2d_opr_state.msg_id = ++(cb- > >>> snd_msg_id); @@ -881,7 +882,9 @@ uint32_t > >>> avnd_di_susi_resp_send(AVND_CB > >>> rc = NCSCC_RC_FAILURE; > >>> } > >>> m_AVND_SU_ALL_SI_RESET(su); > >>> - LOG_NO("avnd_di_susi_resp_send() deferred as AMF > director is > >> offline"); > >>> +LOG_NO("avnd_di_susi_resp_send() deferred as AMF > >>> + director is > >> offline(%d)," > >>> +" or sync is required(%d)", > >>> + cb->is_avd_down, > >>> + cb->amfd_sync_required); > >>> + > >>> } else { > >>> // We are in normal cluster, send msg to director > >>>
[devel] [PATCH 0 of 1] Review Request for amfd: create su if it cannot be found [#2175]
Summary: amfd: create su if it cannot be found [#2175] Review request for Trac Ticket(s): 2175 Peer Reviewer(s): <> Pull request to: <> Affected branch(es): all< 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 4c0dc9549d762214a92eacb620589cf09f240ebf Author: Gary Lee Date: Tue, 08 Nov 2016 19:48:42 +1100 amfd: create su if it can't be found [#2175] during standby cold sync, there may be a chance that SU creation was missed in between config read and being applier, so re-read config again. Complete diffstat: -- osaf/services/saf/amf/amfd/include/su.h | 2 +- osaf/services/saf/amf/amfd/sg.cc| 2 +- osaf/services/saf/amf/amfd/su.cc| 24 +--- 3 files changed, 23 insertions(+), 5 deletions(-) Testing Commands: - <> Testing, Expected Results: -- <> Conditions of Submission: - <> 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 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
[devel] [PATCH 1 of 1] amfd: create su if it can't be found [#2175]
osaf/services/saf/amf/amfd/include/su.h | 2 +- osaf/services/saf/amf/amfd/sg.cc| 2 +- osaf/services/saf/amf/amfd/su.cc| 24 +--- 3 files changed, 23 insertions(+), 5 deletions(-) during standby cold sync, there may be a chance that SU creation was missed in between config read and being applier, so re-read config again. diff --git a/osaf/services/saf/amf/amfd/include/su.h b/osaf/services/saf/amf/amfd/include/su.h --- a/osaf/services/saf/amf/amfd/include/su.h +++ b/osaf/services/saf/amf/amfd/include/su.h @@ -166,7 +166,7 @@ extern AmfDb *su_db * * @return SaAisErrorT */ -extern SaAisErrorT avd_su_config_get(const std::string& sg_name, AVD_SG *sg); +extern SaAisErrorT avd_su_config_get(const std::string& sg_name); /** * Class constructor, must be called before any other function diff --git a/osaf/services/saf/amf/amfd/sg.cc b/osaf/services/saf/amf/amfd/sg.cc --- a/osaf/services/saf/amf/amfd/sg.cc +++ b/osaf/services/saf/amf/amfd/sg.cc @@ -455,7 +455,7 @@ SaAisErrorT avd_sg_config_get(const std: sg_add_to_model(sg); - if (avd_su_config_get(Amf::to_string(&dn), sg) != SA_AIS_OK) { + if (avd_su_config_get(Amf::to_string(&dn)) != SA_AIS_OK) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } 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 @@ -663,7 +663,7 @@ done: TRACE_LEAVE(); } -SaAisErrorT avd_su_config_get(const std::string& sg_name, AVD_SG *sg) +SaAisErrorT avd_su_config_get(const std::string& sg_name) { SaAisErrorT error, rc; SaImmSearchHandleT searchHandle; @@ -1813,10 +1813,28 @@ static void su_ccb_apply_modify_hdlr(str int i = 0; AVD_SU *su; bool value_is_deleted; + const std::string object_name(osaf_extended_name_borrow(&opdata->objectName)); - TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, osaf_extended_name_borrow(&opdata->objectName)); + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, object_name.c_str()); - su = su_db->find(Amf::to_string(&opdata->objectName)); + su = su_db->find(object_name); + if (su == nullptr) { + // during standby cold sync, there may be a chance that + // SU creation was missed in between config read + // and being applier, so re-read config again. + LOG_WA("CCB ID %llu, cannot find '%s'", opdata->ccbId, object_name.c_str()); + + // get the SG + std::string::size_type pos; + pos = object_name.find(','); + osafassert(pos != std::string::npos); + + // re-read config + avd_su_config_get(object_name.substr(pos + 1)); + + su = su_db->find(object_name); + osafassert(su != nullptr); + } while ((attr_mod = opdata->param.modify.attrMods[i++]) != nullptr) { /* Attribute value removed */ -- 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 amfnd: clean proxy if proxy and proxied are not in the same SU [#2169]
Summary: amfnd: clean proxy if proxy and proxied are not in the same SU [#2169] Review request for Trac Ticket(s): #2169 Peer Reviewer(s): Amf Dev Pull request to: <> Affected branch(es): All 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 13585f8f543960aed090d9344e6d640c9872551e Author: Nagendra Kumar Date: Tue, 08 Nov 2016 13:57:12 +0530 amfnd: clean proxy if proxy and proxied are not in the same SU [#2169] Complete diffstat: -- osaf/services/saf/amf/amfnd/clc.cc | 17 - 1 files changed, 16 insertions(+), 1 deletions(-) Testing Commands: - 1. Use proxy demo available in samples/amf/proxy/. 2. Unlock proxy adn proxied using test.sh 3. Run the below commands to kill proxy component twice: pkill -9 proxy pkill -9 proxy 4. Lock SU1: amf-adm lock safSu=1,safSg=2N,safApp=Proxy 5. Unlock SU1: amf-adm unlock safSu=1,safSg=2N,safApp=Proxy Testing, Expected Results: -- After step #3, Su1 is restarted and re-assigned assignments. After step #4, proxy SU assignments are removed and proxied components are moved into Orphan state. After step #5, proxy gets assingments and proxied are moved into Instantiated state. PM_SC-1:/home/nagu/views/staging/samples/amf/proxy # amf-state siass safSISU=safSu=SC-1\,safSg=2N\,safApp=OpenSAF,safSi=SC-2N,safApp=OpenSAF saAmfSISUHAState=ACTIVE(1) saAmfSISUHAReadinessState=READY_FOR_ASSIGNMENT(1) safSISU=safSu=SC-1\,safSg=NoRed\,safApp=OpenSAF,safSi=NoRed1,safApp=OpenSAF saAmfSISUHAState=ACTIVE(1) saAmfSISUHAReadinessState=READY_FOR_ASSIGNMENT(1) safSISU=safSu=1\,safSg=2N\,safApp=Proxy,safSi=1,safApp=Proxy saAmfSISUHAState=ACTIVE(1) saAmfSISUHAReadinessState=READY_FOR_ASSIGNMENT(1) safSISU=safSu=1\,safSg=2N\,safApp=Proxied,safSi=1,safApp=Proxied saAmfSISUHAState=ACTIVE(1) saAmfSISUHAReadinessState=READY_FOR_ASSIGNMENT(1) PM_SC-1:/home/nagu/views/staging/samples/amf/proxy # immlist -a saAmfCompPresenceState safComp=1,safSu=1,safSg=2N,safApp=Proxied saAmfCompPresenceState=3 PM_SC-1:/home/nagu/views/staging/samples/amf/proxy # immlist -a saAmfCompPresenceState safComp=2,safSu=1,safSg=2N,safApp=Proxied saAmfCompPresenceState=3 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.
[devel] [PATCH 1 of 1] amfnd: clean proxy if proxy and proxied are not in the same SU [#2169]
osaf/services/saf/amf/amfnd/clc.cc | 17 - 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/osaf/services/saf/amf/amfnd/clc.cc b/osaf/services/saf/amf/amfnd/clc.cc --- a/osaf/services/saf/amf/amfnd/clc.cc +++ b/osaf/services/saf/amf/amfnd/clc.cc @@ -2024,7 +2024,22 @@ uint32_t avnd_comp_clc_inst_clean_hdler( rc = avnd_comp_cbk_send(cb, comp, AVSV_AMF_PXIED_COMP_CLEAN, 0, 0); } else if (m_AVND_COMP_TYPE_IS_PROXY(comp) && comp->pxied_list.n_nodes) { /* if there are still outstanding proxied components we can't terminate right now */ - return rc; + /* Check if the proxy and proxied components are in the same SUs. */ + TRACE("Proxy has proxied components: %u", comp->pxied_list.n_nodes); + AVND_COMP_PXIED_REC *rec; + rec = (AVND_COMP_PXIED_REC *)m_NCS_DBLIST_FIND_FIRST(&comp->pxied_list); +while (rec) { +if (comp->su == rec->pxied_comp->su) + break; +rec = (AVND_COMP_PXIED_REC *)m_NCS_DBLIST_FIND_NEXT(&rec->comp_dll_node); +} + if (rec == nullptr) { + TRACE("Proxy and proxied are not in the same SU."); + /* This means that proxy and proxied components are not in the same SU. + That means that we can cleanup the component. */ + rc = avnd_comp_clc_cmd_execute(cb, comp, AVND_COMP_CLC_CMD_TYPE_CLEANUP); + } else + return rc; } else { if (m_AVND_SU_IS_RESTART(comp->su) && m_AVND_COMP_IS_RESTART_DIS(comp) && (comp->csi_list.n_nodes > 0) && -- 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 1] mds: Remove use of mutex at TIPC receive (part 1) V2 [#2132]
Hi Mahesh, I checked with the TIPC maintainers, with the following answer: "I checked the code and found that MSG_DONTWAIT flag is supported by both send() and recv() functions since kernel v2.6.16. lxr.free-electrons.com/source/net/tipc/socket.c?v=3.11#L990 The documentation just specifies the send() support. Since the MSG_DONTWAIT flag was introduced in Linux 2.2 all networking protocols in linux do support it. " /Regards HansN On 11/08/2016 08:21 AM, A V Mahesh wrote: > Hi HansN, > > Based on TIPC Programmers_Guide, I can see TIPC supports the > MSG_DONTWAIT flag when sending only, > but this patch is using MSG_DONTWAIT flag while recv, can you please > provide the reference document . > > -AVM > > On 10/27/2016 8:59 PM, Hans Nordeback wrote: >> osaf/libs/core/mds/mds_dt_tipc.c | 374 >> +- >> 1 files changed, 203 insertions(+), 171 deletions(-) >> >> >> This first part changes the socket descriptors to non blocking at >> receive. >> This to read all incoming messages before returning to the next poll >> call. >> >> diff --git a/osaf/libs/core/mds/mds_dt_tipc.c >> b/osaf/libs/core/mds/mds_dt_tipc.c >> --- a/osaf/libs/core/mds/mds_dt_tipc.c >> +++ b/osaf/libs/core/mds/mds_dt_tipc.c >> @@ -565,15 +565,13 @@ static uint32_t mdtm_destroy_rcv_task(vo >> ssize_t recvfrom_connectionless (int sd, void *buf, size_t nbytes, >> int flags, >> struct sockaddr *from, socklen_t *addrlen) >> { >> -struct msghdr msg; >> -struct iovec iov; >> +struct msghdr msg = {0}; >> +struct iovec iov = {0}; >> char anc_buf[CMSG_SPACE(8) + CMSG_SPACE(1024) + CMSG_SPACE(12)]; >> struct cmsghdr *anc; >> int has_addr; >> int anc_data[2]; >> -ssize_t sz; >> - >> has_addr = (from != NULL) && (addrlen != NULL); >> iov.iov_base = buf; >> @@ -586,55 +584,63 @@ ssize_t recvfrom_connectionless (int sd, >> msg.msg_control = anc_buf; >> msg.msg_controllen = sizeof(anc_buf); >> -sz = recvmsg(sd, &msg, flags); >> -if (sz >= 0) { >> -anc = CMSG_FIRSTHDR(&msg); >> -if (anc == NULL) { >> -m_MDS_LOG_DBG("MDTM: size: %d anc is NULL", (int)sz); >> +while (true) { >> +ssize_t sz = recvmsg(sd, &msg, flags); >> +if (sz == -1) { >> +if (errno == EAGAIN || errno == EWOULDBLOCK) { >> +return sz; >> +} else if (errno == EINTR) { >> +continue; >> +} else { >> +/* -1 indicates connection termination >> connectionless this not possible */ >> +abort(); >> +} >> } >> -while (anc != NULL) { >> - >> -/* Receipt of a normal data message never creates the >> TIPC_ERRINFO >> - and TIPC_RETDATA objects, and only creates the >> TIPC_DESTNAME object >> - if the message was sent using a TIPC name or name >> sequence as the >> - destination rather than a TIPC port ID*/ >> -if (anc->cmsg_type == TIPC_ERRINFO) { >> -anc_data[0] = *((unsigned int*)(CMSG_DATA(anc) + 0)); >> -if (anc_data[0] == TIPC_ERR_OVERLOAD) { >> -LOG_CR("MDTM: undelivered message condition >> ancillary data: TIPC_ERR_OVERLOAD"); >> -m_MDS_LOG_CRITICAL("MDTM: undelivered message >> condition ancillary data: TIPC_ERR_OVERLOAD"); >> +if (sz >= 0) { >> +anc = CMSG_FIRSTHDR(&msg); >> +if (anc == NULL) { >> +m_MDS_LOG_DBG("MDTM: size: %d anc is NULL", (int)sz); >> +} >> +while (anc != NULL) { >> + >> +/* Receipt of a normal data message never creates >> the TIPC_ERRINFO >> + and TIPC_RETDATA objects, and only creates the >> TIPC_DESTNAME object >> + if the message was sent using a TIPC name or name >> sequence as the >> + destination rather than a TIPC port ID*/ >> +if (anc->cmsg_type == TIPC_ERRINFO) { >> +anc_data[0] = *((unsigned int*)(CMSG_DATA(anc) + >> 0)); >> +if (anc_data[0] == TIPC_ERR_OVERLOAD) { >> +LOG_CR("MDTM: undelivered message condition >> ancillary data: TIPC_ERR_OVERLOAD"); >> +m_MDS_LOG_CRITICAL("MDTM: undelivered >> message condition ancillary data: TIPC_ERR_OVERLOAD"); >> +} else { >> +/* TIPC_ERRINFO - TIPC error code associated >> with a returned data message or a connection termination message */ >> +m_MDS_LOG_DBG("MDTM: undelivered message >> condition ancillary data: TIPC_ERRINFO err : %d", anc_data[0]); >> +} >> +} else if (anc->cmsg_type == TIPC_RETDATA) { >> +/* If we set TIPC_DEST_DROPPABLE off message >> (configure TIPC to return rejected m
Re: [devel] [PATCH 1 of 1] amfd: increment iterator before it is deleted [#2171]
Ack, code review only. Thanks, Praveen On 07-Nov-16 8:41 AM, Gary Lee wrote: > osaf/services/saf/amf/amfd/main.cc | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > > avd_node_failover() will delete the current node and invalidate the > iterator. We need to increment the iterator first. > > diff --git a/osaf/services/saf/amf/amfd/main.cc > b/osaf/services/saf/amf/amfd/main.cc > --- a/osaf/services/saf/amf/amfd/main.cc > +++ b/osaf/services/saf/amf/amfd/main.cc > @@ -415,8 +415,9 @@ static void handle_event_in_failover_sta >* failover completes >*/ > for (std::map::const_iterator it = > node_id_db->begin(); > - it != node_id_db->end(); it++) { > + it != node_id_db->end();) { > AVD_AVND *node = it->second; > + ++it; > bool fover_done = false; > if (AVD_AVND_STATE_ABSENT == node->node_state) { > /* Check whether this node failover has been > > -- > 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 > -- 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 1] AMFD: Make active/standby amfd becomes early implementer/applier [#2112]
Ack code review only. Thanks, Praveen On 24-Oct-16 10:27 AM, Minh Hon Chau wrote: > osaf/services/saf/amf/amfd/role.cc | 20 ++-- > 1 files changed, 10 insertions(+), 10 deletions(-) > > > After headless, for some reasons the SU read from IMM does not gaurantee > to be the same order as they were added via ccb. That will not maintain > the mapping between node and su, which later would cause a crash of amfnd > > After headless, saAmfSUHostedByNode is read empty so map_su_to_node() > does re-mapping which is a wrong one, and su_add_to_model() also updated > this wrong mapping to IMM. The only right mapping exists in the sync > information where amfd retrieves from avd_susi_recreate(). But this is > also where the problem comes, because payload will reuse the order before > headless and that possibly cause a node mapped to two different SU(s). > > Patch makes active/standby amfd becoming early implementer/applier so > that saAmfSUHostedByNode is read non-empty, and there will not be a re-map > due to blank saAmfSUHostedByNode inside function map_su_to_node(). > > diff --git a/osaf/services/saf/amf/amfd/role.cc > b/osaf/services/saf/amf/amfd/role.cc > --- a/osaf/services/saf/amf/amfd/role.cc > +++ b/osaf/services/saf/amf/amfd/role.cc > @@ -260,6 +260,11 @@ uint32_t avd_active_role_initialization( > > TRACE_ENTER(); > > +if (avd_imm_impl_set() != SA_AIS_OK) { > +LOG_ER("avd_imm_impl_set FAILED"); > +goto done; > +} > + > if (avd_imm_config_get() != NCSCC_RC_SUCCESS) { > LOG_ER("avd_imm_config_get FAILED"); > goto done; > @@ -267,11 +272,6 @@ uint32_t avd_active_role_initialization( > > cb->init_state = AVD_CFG_DONE; > > - if (avd_imm_impl_set() != SA_AIS_OK) { > - LOG_ER("avd_imm_impl_set FAILED"); > - goto done; > - } > - > avd_imm_update_runtime_attrs(); > > status = NCSCC_RC_SUCCESS; > @@ -294,6 +294,11 @@ uint32_t avd_standby_role_initialization > > TRACE_ENTER(); > > +if (avd_imm_applier_set() != SA_AIS_OK) { > +LOG_ER("avd_imm_applier_set FAILED"); > +goto done; > +} > + > if (avd_imm_config_get() != NCSCC_RC_SUCCESS) { > LOG_ER("avd_imm_config_get FAILED"); > goto done; > @@ -301,11 +306,6 @@ uint32_t avd_standby_role_initialization > > cb->init_state = AVD_CFG_DONE; > > - if (avd_imm_applier_set() != SA_AIS_OK) { > - LOG_ER("avd_imm_applier_set FAILED"); > - goto done; > - } > - > status = NCSCC_RC_SUCCESS; > done: > TRACE_LEAVE(); > -- 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 1] amfd: create node if not exist [#2150]
Hi Long, I have gone through the traces from both the AMFDs. I think there is a time difference between the controllers. I just wanted to see whether SC-2 got any CCBs for PL-6 addition. At the same time SC-2 did not get PL-6 information in avd_node_config_get() also. I guess PL-6 was added when SC-2 completed at-least reading node_configuration and has not done applier set. Is this the state of SC-2 when PL-6 was added? Thanks, Praveen On 02-Nov-16 9:28 AM, Long HB Nguyen wrote: > osaf/services/saf/amf/amfd/ckpt_updt.cc | 14 +- > 1 files changed, 9 insertions(+), 5 deletions(-) > > > diff --git a/osaf/services/saf/amf/amfd/ckpt_updt.cc > b/osaf/services/saf/amf/amfd/ckpt_updt.cc > --- a/osaf/services/saf/amf/amfd/ckpt_updt.cc > +++ b/osaf/services/saf/amf/amfd/ckpt_updt.cc > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > static char *action_name[] = { > const_cast("invalid"), > @@ -53,10 +54,14 @@ uint32_t avd_ckpt_node(AVD_CL_CB *cb, AV > > osafassert (action == NCS_MBCSV_ACT_UPDATE); > > - if (nullptr == (node = avd_node_get(ckpt_node->name))) { > - LOG_WA("avd_node_get FAILED for '%s'", ckpt_node->name.c_str()); > - rc = NCSCC_RC_FAILURE; > - goto done; > + node = avd_node_get(ckpt_node->name); > + if (node == nullptr) { > + TRACE("'%s' does not exist, creating it", > ckpt_node->name.c_str()); > + node = avd_node_new(ckpt_node->name); > + node->cluster = avd_cluster; > + node->admin_ng = nullptr; > + rc = node_name_db->insert(node->name, node); > + osafassert(rc == NCSCC_RC_SUCCESS); > } > /* Update all runtime attributes */ > node->saAmfNodeAdminState = ckpt_node->saAmfNodeAdminState; > @@ -72,7 +77,6 @@ uint32_t avd_ckpt_node(AVD_CL_CB *cb, AV > if (nullptr == avd_node_find_nodeid(ckpt_node->node_info.nodeId)) > avd_node_add_nodeid(node); > > -done: > TRACE_LEAVE2("%u", rc); > return rc; > } > -- 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 3] Review Request for mds: Use osaftransportd for writing MDS log messages [#2015] (rebased)
Summary: mds: Use osaftransportd for writing MDS log messages [#2015] rebased Review request for Trac Ticket(s): 2015 Peer Reviewer(s): Mahesh 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 servicesy Core libraries y Samples n Tests n Other n Comments (indicate scope for each "y" above): - rebased: Changes since last review request: re-based patch 3 so that it can be applied after ticket [#2091] was pushed. changeset 6f49da07674f2e9e16c7195b2f22187e831f71eb Author: Anders Widell Date: Tue, 08 Nov 2016 14:57:35 +0100 mds: Convert the mds_log.c file to C++ [#2015] Convert the mds_log.c file to C++ so that it can use C++ classes without the need for any wrappers. changeset 025f1c0b9160908b0460e7f36a270cbcfb40d7a9 Author: Anders Widell Date: Tue, 08 Nov 2016 14:57:40 +0100 mds: Use osaftransportd for writing MDS log messages [#2015] Instead of writing MDS log messages to a file directly from inside the MDS code, send the log messages to the osaftransportd process using a UNIX socket. changeset aca6312a2e8c54805802072d8d6a04c84d54f196 Author: Anders Widell Date: Tue, 08 Nov 2016 14:57:44 +0100 dtm: Implement an MDS log server [#2015] Add a new thread that reads MDS log messages from a UNIX socket and writes them to disk. Rotate the MDS log file when it exceeds the maximum file size limit. Complete diffstat: -- osaf/libs/core/mds/Makefile.am |2 +- osaf/libs/core/mds/include/mds_dt2c.h|3 - osaf/libs/core/mds/include/mds_log.h | 59 +++--- osaf/libs/core/mds/mds_dt_tipc.c |5 +- osaf/libs/core/mds/mds_log.cc| 412 +-- osaf/libs/core/mds/mds_main.c|6 +- osaf/services/infrastructure/dtms/scripts/osaf-transport.in |2 + osaf/services/infrastructure/dtms/transport/Makefile.am |4 + osaf/services/infrastructure/dtms/transport/log_server.cc| 62 +++ osaf/services/infrastructure/dtms/transport/log_server.h | 49 +++ osaf/services/infrastructure/dtms/transport/log_writer.cc| 111 +++ osaf/services/infrastructure/dtms/transport/log_writer.h | 68 + osaf/services/infrastructure/dtms/transport/main.cc | 113 +-- osaf/services/infrastructure/dtms/transport/transport_monitor.cc | 61 +++ osaf/services/infrastructure/dtms/transport/transport_monitor.h | 17 +--- 15 files changed, 665 insertions(+), 309 deletions(-) Testing Commands: - Build and start OpenSAF. Testing, Expected Results: -- OpenSAF MDS logging should work as before. 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 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 w
[devel] [PATCH 3 of 3] dtm: Implement an MDS log server [#2015]
osaf/services/infrastructure/dtms/scripts/osaf-transport.in |2 + osaf/services/infrastructure/dtms/transport/Makefile.am |4 + osaf/services/infrastructure/dtms/transport/log_server.cc| 62 + osaf/services/infrastructure/dtms/transport/log_server.h | 49 osaf/services/infrastructure/dtms/transport/log_writer.cc| 111 + osaf/services/infrastructure/dtms/transport/log_writer.h | 68 ++ osaf/services/infrastructure/dtms/transport/main.cc | 113 - osaf/services/infrastructure/dtms/transport/transport_monitor.cc | 61 + osaf/services/infrastructure/dtms/transport/transport_monitor.h | 17 +- 9 files changed, 406 insertions(+), 81 deletions(-) Add a new thread that reads MDS log messages from a UNIX socket and writes them to disk. Rotate the MDS log file when it exceeds the maximum file size limit. diff --git a/osaf/services/infrastructure/dtms/scripts/osaf-transport.in b/osaf/services/infrastructure/dtms/scripts/osaf-transport.in --- a/osaf/services/infrastructure/dtms/scripts/osaf-transport.in +++ b/osaf/services/infrastructure/dtms/scripts/osaf-transport.in @@ -34,6 +34,7 @@ RETVAL=0 binary=$pkglibdir/$osafprog pidfile=$pkgpiddir/$osafprog.pid lockfile=$lockdir/$initscript +sockfile=$pkglocalstatedir/mds_log.sock start() { [ -p $NIDFIFO ] || return 1 @@ -100,6 +101,7 @@ stop() { killproc -p "$pidfile" "$osafprog" RETVAL=$? if [ "$RETVAL" -eq 0 ] || [ "$RETVAL" -eq 7 ]; then + rm -f "$sockfile" rm -f "$lockfile" RETVAL=0 fi diff --git a/osaf/services/infrastructure/dtms/transport/Makefile.am b/osaf/services/infrastructure/dtms/transport/Makefile.am --- a/osaf/services/infrastructure/dtms/transport/Makefile.am +++ b/osaf/services/infrastructure/dtms/transport/Makefile.am @@ -23,6 +23,8 @@ DEFAULT_INCLUDES = SUBDIRS = tests noinst_HEADERS = \ + log_server.h \ + log_writer.h \ transport_monitor.h osaf_execbindir = $(pkglibdir) @@ -34,6 +36,8 @@ osaftransportd_CPPFLAGS = \ $(AM_CPPFLAGS) osaftransportd_SOURCES = \ + log_server.cc \ + log_writer.cc \ transport_monitor.cc \ main.cc diff --git a/osaf/services/infrastructure/dtms/transport/log_server.cc b/osaf/services/infrastructure/dtms/transport/log_server.cc new file mode 100644 --- /dev/null +++ b/osaf/services/infrastructure/dtms/transport/log_server.cc @@ -0,0 +1,62 @@ +/* -*- 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 "osaf/services/infrastructure/dtms/transport/log_server.h" +#include "./configmake.h" +#include "osaf/libs/core/common/include/osaf_poll.h" +#include "osaf/libs/core/cplusplus/base/getenv.h" +#include "osaf/libs/core/cplusplus/base/time.h" + +LogServer::LogServer(int term_fd) +: term_fd_{term_fd}, + log_socket_{base::GetEnv("pkglocalstatedir", + PKGLOCALSTATEDIR) + "/mds_log.sock"}, + log_writer_{} { +} + +LogServer::~LogServer() { +} + +void LogServer::Run() { + struct pollfd pfd[2] = { +{term_fd_, POLLIN, 0}, +{log_socket_.fd(), POLLIN, 0} + }; + struct timespec last_flush = base::ReadMonotonicClock(); + do { +for (int i = 0; i < 256; ++i) { + char* buffer = log_writer_.current_buffer_position(); + ssize_t result = log_socket_.Recv(buffer, LogWriter::kMaxMessageSize); + if (result < 0) break; + while (result != 0 && buffer[result - 1] == '\n') --result; + if (static_cast(result) != LogWriter::kMaxMessageSize) { +buffer[result++] = '\n'; + } else { +buffer[result - 1] = '\n'; + } + log_writer_.Write(result); +} +struct timespec current = base::ReadMonotonicClock(); +if ((current - last_flush) >= base::kFifteenSeconds) { + log_writer_.Flush(); + last_flush = current; +} +struct timespec timeout = (last_flush + base::kFifteenSeconds) - current; +pfd[1].fd = log_socket_.fd(); +osaf_ppoll(pfd, 2, &timeout, nullptr); + } while ((pfd[0].revents & POLLIN) == 0); +} diff --git a/osaf/services/infrastructure/dtms/transport/log_server.h b/osaf/services/infrastructure/dtms/transport/log_server.h new file mode 100644 --- /dev/null +++ b/osaf/services/infrastructure/dtms/transport/log_server.h @@ -0,0 +1,49 @@ +/* -*- OpenSAF -*- + * + * (C) Copyright 20
[devel] [PATCH 1 of 3] mds: Convert the mds_log.c file to C++ [#2015]
osaf/libs/core/mds/Makefile.am|2 +- osaf/libs/core/mds/include/mds_dt2c.h |3 - osaf/libs/core/mds/include/mds_log.h | 59 +++-- osaf/libs/core/mds/mds_dt_tipc.c |5 +- osaf/libs/core/mds/mds_log.cc | 369 + osaf/libs/core/mds/mds_main.c |6 +- 6 files changed, 229 insertions(+), 215 deletions(-) Convert the mds_log.c file to C++ so that it can use C++ classes without the need for any wrappers. diff --git a/osaf/libs/core/mds/Makefile.am b/osaf/libs/core/mds/Makefile.am --- a/osaf/libs/core/mds/Makefile.am +++ b/osaf/libs/core/mds/Makefile.am @@ -37,7 +37,7 @@ libmds_la_SOURCES = \ mds_papi.c \ mds_c_sndrcv.c \ mds_c_api.c \ - mds_log.c \ + mds_log.cc \ ncs_ada.c \ ncs_mda.c \ ncs_vda.c diff --git a/osaf/libs/core/mds/include/mds_dt2c.h b/osaf/libs/core/mds/include/mds_dt2c.h --- a/osaf/libs/core/mds/include/mds_dt2c.h +++ b/osaf/libs/core/mds/include/mds_dt2c.h @@ -316,9 +316,6 @@ typedef struct mds_mbx_evt_info { /* */ /* */ -/* Initialize Logging */ -extern uint32_t mds_log_init(char *log_file_name, char *line_prefix); - /* extern gl_mds_checksum */ extern uint32_t gl_mds_checksum; 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 @@ -22,39 +22,50 @@ ** */ -#ifndef _MDS_LOG_H -#define _MDS_LOG_H +#ifndef OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_ +#define OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_ -#include -#include "ncs_lib.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /* Logging utility functions - Phani */ -extern uint32_t gl_mds_log_level; +extern int gl_mds_log_level; -#define NCSMDS_LC_CRITICAL 1 -#define NCSMDS_LC_ERR2 -#define NCSMDS_LC_NOTIFY 3 -#define NCSMDS_LC_INFO 4 -#define NCSMDS_LC_DBG5 +enum { + NCSMDS_LC_CRITICAL = 1, + NCSMDS_LC_ERR = 2, + NCSMDS_LC_NOTIFY = 3, + NCSMDS_LC_INFO = 4, + NCSMDS_LC_DBG = 5 +}; -#define m_MDS_LOG_CRITICAL if (gl_mds_log_level < NCSMDS_LC_CRITICAL) {} else log_mds_critical - -#define m_MDS_LOG_ERR if (gl_mds_log_level < NCSMDS_LC_ERR) {} else log_mds_err - -#define m_MDS_LOG_NOTIFY if (gl_mds_log_level < NCSMDS_LC_NOTIFY) {} else log_mds_notify - -#define m_MDS_LOG_INFO if (gl_mds_log_level < NCSMDS_LC_INFO) {} else log_mds_info - -#define m_MDS_LOG_DBG if (gl_mds_log_level < NCSMDS_LC_DBG) {} else log_mds_dbg +#define m_MDS_LOG_CRITICAL log_mds_critical +#define m_MDS_LOG_ERR log_mds_err +#define m_MDS_LOG_NOTIFY log_mds_notify +#define m_MDS_LOG_INFO log_mds_info +#define m_MDS_LOG_DBG log_mds_dbg #define m_MDS_ENTER() m_MDS_LOG_DBG(">> %s", __FUNCTION__) #define m_MDS_LEAVE() m_MDS_LOG_DBG("<< %s", __FUNCTION__) -extern void log_mds_dbg(char *fmt, ...); -extern void log_mds_info(char *fmt, ...); -extern void log_mds_notify(char *fmt, ...); -extern void log_mds_err(char *fmt, ...); -extern void log_mds_critical(char *fmt, ...); +uint32_t mds_log_init(const char *log_file_name); +void log_mds_dbg(const char *fmt, ...) +__attribute__ ((format(printf, 1, 2))); +void log_mds_info(const char *fmt, ...) +__attribute__ ((format(printf, 1, 2))); +void log_mds_notify(const char *fmt, ...) +__attribute__ ((format(printf, 1, 2))); +void log_mds_err(const char *fmt, ...) +__attribute__ ((format(printf, 1, 2))); +void log_mds_critical(const char *fmt, ...) +__attribute__ ((format(printf, 1, 2))); +#ifdef __cplusplus +} #endif + +#endif // OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_ diff --git a/osaf/libs/core/mds/mds_dt_tipc.c b/osaf/libs/core/mds/mds_dt_tipc.c --- a/osaf/libs/core/mds/mds_dt_tipc.c +++ b/osaf/libs/core/mds/mds_dt_tipc.c @@ -31,6 +31,7 @@ #include "ncssysf_tsk.h" #include "ncssysf_mem.h" +#include #include #include #include @@ -1107,12 +1108,12 @@ static uint32_t mdtm_process_discovery_e m_MDS_LOG_INFO("MDTM: Raising the NODE UP event for NODE id = %d", node_id); uint32_t up_node_id; if ((up_node_id = m_MDS_GET_NODE_ID_FROM_ADEST(m_MDS_GET_ADEST)) == node_id) { - m_MDS_LOG_INFO("MDTM:NODE_UP for subtn_ref_val:%lu node_name:%s, node_id:%u addr_family:%d ", + m_MDS_LOG_INFO("MDTM:NODE_UP for subtn_ref_val:%" PRIu64 " node_name:%s, node_id:%u addr_family:%d ", (uint64_t)subtn_ref_val,gl_mds_mcm_cb->node_name, node_id, AF_TIPC); return mds_mcm_node_up(svc_hdl, node_id, NULL, AF_TIPC, gl_mds_mcm_cb->node_name);
[devel] [PATCH 2 of 3] mds: Use osaftransportd for writing MDS log messages [#2015]
osaf/libs/core/mds/mds_log.cc | 223 ++--- 1 files changed, 120 insertions(+), 103 deletions(-) Instead of writing MDS log messages to a file directly from inside the MDS code, send the log messages to the osaftransportd process using a UNIX socket. 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 @@ -23,38 +23,93 @@ */ #include "osaf/libs/core/mds/include/mds_log.h" +#include +#include #include #include #include #include #include #include +#include +#include "./configmake.h" +#include "osaf/libs/core/common/include/osaf_utility.h" +#include "osaf/libs/core/cplusplus/base/buffer.h" +#include "osaf/libs/core/cplusplus/base/log_message.h" +#include "osaf/libs/core/cplusplus/base/macros.h" +#include "osaf/libs/core/cplusplus/base/time.h" +#include "osaf/libs/core/cplusplus/base/unix_client_socket.h" #include "osaf/libs/core/include/mds_papi.h" #include "osaf/libs/core/include/ncsgl_defs.h" #include "osaf/libs/core/mds/include/mds_dt2c.h" -constexpr static const size_t kMaxMdsFileNameLen = 256; +class MdsLog { + public: + static bool Init(); + static void Log(base::LogMessage::Severity severity, const char *str); -static void log_mds(const char *str); + 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 buffer_; + base::UnixClientSocket log_socket_; + + DELETE_COPY_AND_MOVE_OPERATORS(MdsLog); +}; int gl_mds_log_level = 3; -static char *lf = nullptr; -static char process_name[MDS_MAX_PROCESS_NAME_LEN]; -static char mds_log_fname[kMaxMdsFileNameLen]; +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_{512}, +log_socket_{socket_name} { + pthread_mutexattr_t attr; + int result = pthread_mutexattr_init(&attr); + if (result != 0) osaf_abort(result); + result = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); + if (result != 0) osaf_abort(result); + result = pthread_mutex_init(&mutex_, &attr); + if (result != 0) osaf_abort(result); + result = pthread_mutexattr_destroy(&attr); + if (result != 0) osaf_abort(result); +} + +MdsLog::~MdsLog() { + int result = pthread_mutex_destroy(&mutex_); + if (result != 0) osaf_abort(result); +} /* Function NAME: get_process_name() Returns : [ or ] */ -static void get_process_name() { +bool MdsLog::Init() { + if (instance_ != nullptr) return false; + char app_name[MDS_MAX_PROCESS_NAME_LEN]; + char node_name[256]; char pid_path[1024]; uint32_t process_id = getpid(); char *token, *saveptr; char *pid_name = nullptr; + const char *node_name_file = PKGSYSCONFDIR "/node_name"; - snprintf(pid_path, sizeof(pid_path), "/proc/%d/cmdline", process_id); + snprintf(pid_path, sizeof(pid_path), "/proc/%" PRIu32 "/cmdline", process_id); FILE* f = fopen(pid_path, "r"); - if (f) { + if (f != nullptr) { size_t size; size = fread(pid_path, sizeof(char), 1024, f); if (size > 0) { @@ -62,16 +117,51 @@ static void get_process_name() { pid_path[size-1] = '\0'; } fclose(f); + } else { +pid_path[0] = '\0'; } token = strtok_r(pid_path, "/", &saveptr); while (token != nullptr) { pid_name = token; token = strtok_r(nullptr, "/", &saveptr); } - snprintf(process_name, MDS_MAX_PROCESS_NAME_LEN, "%s[%d]", pid_name, - process_id); - return; + if (snprintf(app_name, sizeof(app_name), "%s", pid_name) < 0) { +app_name[0] = '\0'; + } + FILE* fp = fopen(node_name_file, "r"); + if (fp != nullptr) { +if (fscanf(fp, "%255s", node_name) != 1) node_name[0] = '\0'; +fclose(fp); + } else { +node_name[0] = '\0'; + } + instance_ = new MdsLog{node_name, app_name, process_id, + PKGLOCALSTATEDIR "/mds_log.sock"}; + return instance_ != nullptr; } + +void MdsLog::Log(base::LogMessage::Severity severity, const char *str) { + if (instance_ != nullptr) instance_->LogInternal(severity, str); +} + +void MdsLog::LogInternal(base::LogMessage::Severity severity, const char *str) { + osaf_mutex_lock_ordie(&mutex_); + uint64_t id = msg_id_++; + buffer_.clear(); + base::LogMessage::Write(base::LogM
[devel] [PATCH 0 of 2] Review Request for base: Add Mutex, Lock and ConditionVariable classes [#2173]
Summary: base: Add Mutex, Lock and ConditionVariable classes [#2173] Review request for Trac Ticket(s): 2173 Peer Reviewer(s): 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 13cabe8bd812a04beab2270086d1ffeb4a2572a7 Author: Anders Widell Date: Tue, 08 Nov 2016 16:12:00 +0100 base: Add Mutex, Lock and ConditionVariable classes [#2173] Add classes for Mutex, Lock and ConditionVariable - similar to std::mutex, std::unique_lock and std::condition_variable. One reason for adding these to OpenSAF is that the C++ standard library casses are unapproved by the Google C++ Style Guide. Another reason is that we can integrate them better into OpenSAF: we select the appropriate options when creating the mutex and condition variable, and we call osaf_abort() in case an unexpected error is encountered. Also, we will use an error checking mutex when the ENABLE_DEBUG preprocessor macro is defined - paving the way for special OpenSAF debug builds. changeset 26bb6661c0aef547c61ca9358cbc8cc514acba31 Author: Anders Widell Date: Tue, 08 Nov 2016 16:16:10 +0100 base: Use the Mutex and Lock classes [#2173] Use the new Mutex and Lock classes instead of std::mutex, std::unique_lock and pthread_mutex_t. Complete diffstat: -- osaf/libs/core/cplusplus/base/Makefile.am | 4 osaf/libs/core/cplusplus/base/condition_variable.cc | 39 +++ osaf/libs/core/cplusplus/base/condition_variable.h | 95 +++ osaf/libs/core/cplusplus/base/mutex.cc | 46 ++ osaf/libs/core/cplusplus/base/mutex.h | 82 ++ osaf/libs/core/cplusplus/base/process.cc| 31 ++- osaf/libs/core/cplusplus/base/process.h | 19 ++- osaf/libs/core/cplusplus/base/unix_socket.cc| 17 ++--- osaf/libs/core/cplusplus/base/unix_socket.h | 3 ++- 9 files changed, 298 insertions(+), 38 deletions(-) Testing Commands: - Build and start OpenSAF. Run regression tests. 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 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 f
[devel] [PATCH 2 of 2] base: Use the Mutex and Lock classes [#2173]
osaf/libs/core/cplusplus/base/process.cc | 31 --- osaf/libs/core/cplusplus/base/process.h | 19 + osaf/libs/core/cplusplus/base/unix_socket.cc | 17 +- osaf/libs/core/cplusplus/base/unix_socket.h | 3 +- 4 files changed, 32 insertions(+), 38 deletions(-) Use the new Mutex and Lock classes instead of std::mutex, std::unique_lock and pthread_mutex_t. diff --git a/osaf/libs/core/cplusplus/base/process.cc b/osaf/libs/core/cplusplus/base/process.cc --- a/osaf/libs/core/cplusplus/base/process.cc +++ b/osaf/libs/core/cplusplus/base/process.cc @@ -50,10 +50,12 @@ Process::~Process() { } void Process::Kill(int sig_no, const Duration& wait_time) { - std::unique_lock lock(mutex_); - pid_t pgid = process_group_id_; - process_group_id_ = 0; - lock.unlock(); + pid_t pgid; + { +Lock lock(mutex_); +pgid = process_group_id_; +process_group_id_ = 0; + } if (pgid > 1) KillProc(-pgid, sig_no, wait_time); } @@ -119,20 +121,23 @@ void Process::Execute(int argc, char *ar LOG_WA("setpgid(%u, 0) failed: %s", (unsigned) child_pid, strerror(errno)); } -std::unique_lock lock(mutex_); -process_group_id_ = child_pid; -StartTimer(timeout); -lock.unlock(); +{ + Lock lock(mutex_); + process_group_id_ = child_pid; + StartTimer(timeout); +} int status; pid_t wait_pid; do { wait_pid = waitpid(child_pid, &status, 0); } while (wait_pid == (pid_t) -1 && errno == EINTR); -lock.lock(); -StopTimer(); -bool killed = process_group_id_ == 0; -process_group_id_ = 0; -lock.unlock(); +bool killed; +{ + Lock lock(mutex_); + StopTimer(); + killed = process_group_id_ == 0; + process_group_id_ = 0; +} bool successful = false; if (!killed && wait_pid != (pid_t) -1) { if (!WIFEXITED(status)) { diff --git a/osaf/libs/core/cplusplus/base/process.h b/osaf/libs/core/cplusplus/base/process.h --- a/osaf/libs/core/cplusplus/base/process.h +++ b/osaf/libs/core/cplusplus/base/process.h @@ -15,20 +15,19 @@ * */ -#ifndef OPENSAF_OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ -#define OPENSAF_OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ +#ifndef OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ +#define OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ +#include #include #include #include -#include -#include -#include "base/macros.h" +#include "osaf/libs/core/cplusplus/base/macros.h" +#include "osaf/libs/core/cplusplus/base/mutex.h" namespace base { class Process { - DELETE_COPY_AND_MOVE_OPERATORS(Process); public: using Duration = std::chrono::steady_clock::duration; Process(); @@ -96,18 +95,20 @@ class Process { * processes in the process group have terminated. */ static void KillProc(pid_t pid, int sig_no, const Duration& wait_time); + private: using Clock = std::chrono::steady_clock; using TimePoint = std::chrono::steady_clock::time_point; void StartTimer(const Duration& timeout); void StopTimer(); static void TimerExpirationEvent(sigval notification_data); - std::mutex mutex_; + Mutex mutex_; timer_t timer_id_; bool is_timer_created_; pid_t process_group_id_; + DELETE_COPY_AND_MOVE_OPERATORS(Process); }; -} // namespace base +} // namespace base -#endif /* OPENSAF_OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ */ +#endif // OSAF_LIBS_CORE_CPLUSPLUS_BASE_PROCESS_H_ 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 @@ -32,19 +32,10 @@ UnixSocket::UnixSocket(const std::string } else { addr_.sun_path[0] = '\0'; } - pthread_mutexattr_t attr; - int result = pthread_mutexattr_init(&attr); - if (result != 0) osaf_abort(result); - result = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT); - if (result != 0) osaf_abort(result); - result = pthread_mutex_init(&mutex_, &attr); - if (result != 0) osaf_abort(result); - result = pthread_mutexattr_destroy(&attr); - if (result != 0) osaf_abort(result); } int UnixSocket::Open() { - osaf_mutex_lock_ordie(&mutex_); + Lock lock(mutex_); int sock = fd_; if (sock < 0) { if (addr_.sun_path[0] != '\0') { @@ -60,18 +51,15 @@ int UnixSocket::Open() { errno = ENAMETOOLONG; } } - osaf_mutex_unlock_ordie(&mutex_); return sock; } UnixSocket::~UnixSocket() { Close(); - int result = pthread_mutex_destroy(&mutex_); - if (result != 0) osaf_abort(result); } void UnixSocket::Close() { - osaf_mutex_lock_ordie(&mutex_); + Lock lock(mutex_); int sock = fd_; if (sock >= 0) { int e = errno; @@ -80,7 +68,6 @@ void UnixSocket::Close() { CloseHook(); errno = e; } - osaf_mutex_unlock_ordie(&mutex_); } bool UnixSocket::OpenHook(int) { diff --git a/osaf/libs/core/cplusplus/base/unix_socket.h b/os
[devel] [PATCH 1 of 2] base: Add Mutex, Lock and ConditionVariable classes [#2173]
osaf/libs/core/cplusplus/base/Makefile.am | 4 + osaf/libs/core/cplusplus/base/condition_variable.cc | 39 osaf/libs/core/cplusplus/base/condition_variable.h | 95 + osaf/libs/core/cplusplus/base/mutex.cc | 46 ++ osaf/libs/core/cplusplus/base/mutex.h | 82 ++ 5 files changed, 266 insertions(+), 0 deletions(-) Add classes for Mutex, Lock and ConditionVariable - similar to std::mutex, std::unique_lock and std::condition_variable. One reason for adding these to OpenSAF is that the C++ standard library casses are unapproved by the Google C++ Style Guide. Another reason is that we can integrate them better into OpenSAF: we select the appropriate options when creating the mutex and condition variable, and we call osaf_abort() in case an unexpected error is encountered. Also, we will use an error checking mutex when the ENABLE_DEBUG preprocessor macro is defined - paving the way for special OpenSAF debug builds. 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 @@ -28,6 +28,8 @@ noinst_HEADERS = \ getenv.h \ log_message.h \ macros.h \ + mutex.h \ + condition_variable.h \ process.h \ time.h \ unix_client_socket.h \ @@ -48,6 +50,8 @@ libbase_la_SOURCES = \ getenv.cc \ log_message.cc \ process.cc \ + mutex.cc \ + condition_variable.cc \ unix_client_socket.cc \ unix_server_socket.cc \ unix_socket.cc diff --git a/osaf/libs/core/cplusplus/base/condition_variable.cc b/osaf/libs/core/cplusplus/base/condition_variable.cc new file mode 100644 --- /dev/null +++ b/osaf/libs/core/cplusplus/base/condition_variable.cc @@ -0,0 +1,39 @@ +/* -*- 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 "osaf/libs/core/cplusplus/base/condition_variable.h" + +namespace base { + +ConditionVariable::ConditionVariable() : condition_variable_{} { + pthread_condattr_t attr; + int result = pthread_condattr_init(&attr); + if (result != 0) osaf_abort(result); + result = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if (result != 0) osaf_abort(result); + result = pthread_cond_init(&condition_variable_, &attr); + if (result != 0) osaf_abort(result); + result = pthread_condattr_destroy(&attr); + if (result != 0) osaf_abort(result); +} + +ConditionVariable::~ConditionVariable() { + int result = pthread_cond_destroy(&condition_variable_); + if (result != 0) osaf_abort(result); +} + +} // namespace base diff --git a/osaf/libs/core/cplusplus/base/condition_variable.h b/osaf/libs/core/cplusplus/base/condition_variable.h new file mode 100644 --- /dev/null +++ b/osaf/libs/core/cplusplus/base/condition_variable.h @@ -0,0 +1,95 @@ +/* -*- 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 + * + */ + +#ifndef OSAF_LIBS_CORE_CPLUSPLUS_BASE_CONDITION_VARIABLE_H_ +#define OSAF_LIBS_CORE_CPLUSPLUS_BASE_CONDITION_VARIABLE_H_ + +#include +#include +#include "osaf/libs/core/common/include/osaf_utility.h" +#include "osaf/libs/core/cplusplus/base/macros.h" +#include "osaf/libs/core/cplusplus/base/mutex.h" +#include "osaf/libs/core/cplusplus/base/time.h" + +namespace base { + +enum class CvStatus { kNoTimeout, kTimeout }; + +// A condition variable, with an API similar to std::condition_variable. The +// timed methods always use the monotonic clock (clock id CLOCK_MONOTONIC). +class ConditionVariable { + public: + ConditionVariable(); + ~ConditionVariable(); + void Wait(Lock* lock) { +int result = pthread_cond_wait(&condition_variable_, + lock->mutex()->native_handle()); +if (result != 0) osaf_abort(re
Re: [devel] [PATCH 1 of 1] amfd: mark all SUs OOS on failed node before nodeswitchover recovery[#1934]
ack (review only) > On 26 Aug. 2016, at 10:53 pm, praveen.malv...@oracle.com wrote: > > osaf/services/saf/amf/amfd/sgproc.cc | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) > > > In the reported problem, AMFD failovers SU of a failed node to other SU on > the same > node as a part of node-switchover recovery.It generates unnecessary sequence > of Active and > quiesced assignment. > > Patch marks all the SUs OOS before performing recovery of any SU. > > diff --git a/osaf/services/saf/amf/amfd/sgproc.cc > b/osaf/services/saf/amf/amfd/sgproc.cc > --- a/osaf/services/saf/amf/amfd/sgproc.cc > +++ b/osaf/services/saf/amf/amfd/sgproc.cc > @@ -597,8 +597,10 @@ static void perform_nodeswitchover_recov > bool node_reboot = true; > TRACE_ENTER2("'%s'", node->name.c_str()); > > + //To avoid switchover to SUs of this node, mark all of them OOS. > + for (const auto& su : node->list_of_su) > + su->set_readiness_state(SA_AMF_READINESS_OUT_OF_SERVICE); > for (const auto& su : node->list_of_su) { > - su->set_readiness_state(SA_AMF_READINESS_OUT_OF_SERVICE); > > if (su->list_of_susi == nullptr) > continue; -- 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 1] mds: Remove use of mutex at TIPC receive (part 1) V2 [#2132]
Hi HansN, On 11/8/2016 3:28 PM, Hans Nordeback wrote: > "I checked the code and found that MSG_DONTWAIT flag is supported by > both send() and recv() functions since kernel v2.6.16. > > lxr.free-electrons.com/source/net/tipc/socket.c?v=3.11#L990 > > The documentation just specifies the send() support. Ok i will check the code ( i Have TIPC 1.7 code ). One more theoretical observation with this new logic is that , the new logic do either you completely loop through all Dsock recv , then we loop through BSRsock all recvfrom or vice versa , so this increases possibility of processing out of order of data and control event. In case of existing logic both FD_BSRSOCK & FD_DSOCK were getting alternate processing , so out of order time was manageable , now with new approach the out of order time time is unpredictable. I will also test piratically by fuddling lot of Data messages and provide my observation. = while(true) { recv(tipc_cb.Dsock ) while(true) { recvfrom_connectionless(tipc_cb.BSRsock ...) = -AVM On 11/8/2016 3:28 PM, Hans Nordeback wrote: > Hi Mahesh, > > I checked with the TIPC maintainers, with the following answer: > > "I checked the code and found that MSG_DONTWAIT flag is supported by > both send() and recv() functions since kernel v2.6.16. > > lxr.free-electrons.com/source/net/tipc/socket.c?v=3.11#L990 > > The documentation just specifies the send() support. > > Since the MSG_DONTWAIT flag was introduced in Linux 2.2 all networking > protocols in linux do support it. " > > /Regards HansN > > On 11/08/2016 08:21 AM, A V Mahesh wrote: >> Hi HansN, >> >> Based on TIPC Programmers_Guide, I can see TIPC supports the >> MSG_DONTWAIT flag when sending only, >> but this patch is using MSG_DONTWAIT flag while recv, can you please >> provide the reference document . >> >> -AVM >> >> On 10/27/2016 8:59 PM, Hans Nordeback wrote: >>> osaf/libs/core/mds/mds_dt_tipc.c | 374 >>> +- >>> 1 files changed, 203 insertions(+), 171 deletions(-) >>> >>> >>> This first part changes the socket descriptors to non blocking at >>> receive. >>> This to read all incoming messages before returning to the next poll >>> call. >>> >>> diff --git a/osaf/libs/core/mds/mds_dt_tipc.c >>> b/osaf/libs/core/mds/mds_dt_tipc.c >>> --- a/osaf/libs/core/mds/mds_dt_tipc.c >>> +++ b/osaf/libs/core/mds/mds_dt_tipc.c >>> @@ -565,15 +565,13 @@ static uint32_t mdtm_destroy_rcv_task(vo >>> ssize_t recvfrom_connectionless (int sd, void *buf, size_t nbytes, >>> int flags, >>> struct sockaddr *from, socklen_t *addrlen) >>> { >>> -struct msghdr msg; >>> -struct iovec iov; >>> +struct msghdr msg = {0}; >>> +struct iovec iov = {0}; >>> char anc_buf[CMSG_SPACE(8) + CMSG_SPACE(1024) + CMSG_SPACE(12)]; >>> struct cmsghdr *anc; >>> int has_addr; >>> int anc_data[2]; >>> -ssize_t sz; >>> - >>> has_addr = (from != NULL) && (addrlen != NULL); >>> iov.iov_base = buf; >>> @@ -586,55 +584,63 @@ ssize_t recvfrom_connectionless (int sd, >>> msg.msg_control = anc_buf; >>> msg.msg_controllen = sizeof(anc_buf); >>> -sz = recvmsg(sd, &msg, flags); >>> -if (sz >= 0) { >>> -anc = CMSG_FIRSTHDR(&msg); >>> -if (anc == NULL) { >>> -m_MDS_LOG_DBG("MDTM: size: %d anc is NULL", (int)sz); >>> +while (true) { >>> +ssize_t sz = recvmsg(sd, &msg, flags); >>> +if (sz == -1) { >>> +if (errno == EAGAIN || errno == EWOULDBLOCK) { >>> +return sz; >>> +} else if (errno == EINTR) { >>> +continue; >>> +} else { >>> +/* -1 indicates connection termination >>> connectionless this not possible */ >>> +abort(); >>> +} >>> } >>> -while (anc != NULL) { >>> - >>> -/* Receipt of a normal data message never creates the >>> TIPC_ERRINFO >>> - and TIPC_RETDATA objects, and only creates the >>> TIPC_DESTNAME object >>> - if the message was sent using a TIPC name or name >>> sequence as the >>> - destination rather than a TIPC port ID*/ >>> -if (anc->cmsg_type == TIPC_ERRINFO) { >>> -anc_data[0] = *((unsigned int*)(CMSG_DATA(anc) + 0)); >>> -if (anc_data[0] == TIPC_ERR_OVERLOAD) { >>> -LOG_CR("MDTM: undelivered message condition >>> ancillary data: TIPC_ERR_OVERLOAD"); >>> -m_MDS_LOG_CRITICAL("MDTM: undelivered message >>> condition ancillary data: TIPC_ERR_OVERLOAD"); >>> +if (sz >= 0) { >>> +anc = CMSG_FIRSTHDR(&msg); >>> +if (anc == NULL) { >>> +m_MDS_LOG_DBG("MDTM: size: %d anc is NULL", (int)sz); >>> +} >>> +
Re: [devel] [PATCH 0 of 3] Review Request for mds: Use osaftransportd for writing MDS log messages [#2015] (rebased)
ACK for patch series. -AVM On 11/8/2016 7:33 PM, Anders Widell wrote: > Summary: mds: Use osaftransportd for writing MDS log messages [#2015] rebased > Review request for Trac Ticket(s): 2015 > Peer Reviewer(s): Mahesh > 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 servicesy > Core libraries y > Samples n > Tests n > Other n > > > Comments (indicate scope for each "y" above): > - > > rebased: Changes since last review request: re-based patch 3 so that it can be > applied after ticket [#2091] was pushed. > > changeset 6f49da07674f2e9e16c7195b2f22187e831f71eb > Author: Anders Widell > Date: Tue, 08 Nov 2016 14:57:35 +0100 > > mds: Convert the mds_log.c file to C++ [#2015] > > Convert the mds_log.c file to C++ so that it can use C++ classes > without the > need for any wrappers. > > changeset 025f1c0b9160908b0460e7f36a270cbcfb40d7a9 > Author: Anders Widell > Date: Tue, 08 Nov 2016 14:57:40 +0100 > > mds: Use osaftransportd for writing MDS log messages [#2015] > > Instead of writing MDS log messages to a file directly from inside the > MDS > code, send the log messages to the osaftransportd process using a UNIX > socket. > > changeset aca6312a2e8c54805802072d8d6a04c84d54f196 > Author: Anders Widell > Date: Tue, 08 Nov 2016 14:57:44 +0100 > > dtm: Implement an MDS log server [#2015] > > Add a new thread that reads MDS log messages from a UNIX socket and > writes > them to disk. Rotate the MDS log file when it exceeds the maximum file > size > limit. > > > Complete diffstat: > -- > osaf/libs/core/mds/Makefile.am |2 +- > osaf/libs/core/mds/include/mds_dt2c.h|3 - > osaf/libs/core/mds/include/mds_log.h | 59 > +++--- > osaf/libs/core/mds/mds_dt_tipc.c |5 +- > osaf/libs/core/mds/mds_log.cc| 412 > +-- > osaf/libs/core/mds/mds_main.c|6 +- > osaf/services/infrastructure/dtms/scripts/osaf-transport.in |2 + > osaf/services/infrastructure/dtms/transport/Makefile.am |4 + > osaf/services/infrastructure/dtms/transport/log_server.cc| 62 > +++ > osaf/services/infrastructure/dtms/transport/log_server.h | 49 > +++ > osaf/services/infrastructure/dtms/transport/log_writer.cc| 111 > +++ > osaf/services/infrastructure/dtms/transport/log_writer.h | 68 > + > osaf/services/infrastructure/dtms/transport/main.cc | 113 > +-- > osaf/services/infrastructure/dtms/transport/transport_monitor.cc | 61 > +++ > osaf/services/infrastructure/dtms/transport/transport_monitor.h | 17 +--- > 15 files changed, 665 insertions(+), 309 deletions(-) > > > Testing Commands: > - > Build and start OpenSAF. > > > Testing, Expected Results: > -- > OpenSAF MDS logging should work as before. > > > 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 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 test