Menu

#2452 log: mutex lock missing in error cases of write_log_record_hdl()

5.1.0
fixed
None
defect
log
-
major
False
2017-05-15
2017-05-04
No

Unlock is being called twice before waiting hence LOGD crashes.

This because of write_log_record_hdl() is being returned with out
osaf_mutex_lock_ordie(&lgs_ftcom_mutex);

=================================================================================

int write_log_record_hdl(void indata, void outdata, size_t max_outsize, bool timeout_f) {
int rc = 0;
uint32_t bytes_written = 0;
off_t file_length = 0;
wlrh_t
params_in = static_cast<wlrh_t *="">(indata);
/ Get log record pointed by lgs_rec pointer /
char logrecord = const_cast<char *="">(static_cast<const char*="">(params_in->lgs_rec));
int
errno_out_p = static_cast<int *="">(outdata);
*errno_out_p = 0;

TRACE_ENTER();

osaf_mutex_unlock_ordie(&lgs_ftcom_mutex); / UNLOCK Critical section /

retry:
rc = write(params_in->fd, &logrecord[bytes_written],
params_in->record_size - bytes_written);
if (rc == -1) {
if (errno == EINTR)
goto retry;

LOG_ER("%s - write FAILED: %s",__FUNCTION__, strerror(errno));
*errno_out_p = errno;
goto done;  <-------------------------------------------------------------------

} else {
/ Handle partial writes /
bytes_written += rc;
if (bytes_written < params_in->record_size)
goto retry;
}
osaf_mutex_lock_ordie(&lgs_ftcom_mutex);
=================================================================================

Related

Tickets: #1470
Tickets: #2452
Wiki: ChangeLog-5.17.07

Discussion

  • A V Mahesh (AVM)

    • status: assigned --> accepted
     
  • Vu Minh Nguyen

    Vu Minh Nguyen - 2017-05-04

    Seems it is duplicated with this ticket [#1470]

     

    Related

    Tickets: #1470

  • Vu Minh Nguyen

    Vu Minh Nguyen - 2017-05-12
    • status: accepted --> review
     
  • A V Mahesh (AVM)

     
  • A V Mahesh (AVM)

    http://hg.code.sf.net/p/opensaf/staging

    changeset: 8793:55c2a1420b3b
    user: A V Mahesh mahesh.valla@oracle.com
    date: Mon May 15 10:14:23 2017 +0530
    summary: log: correct mutex lock and unlock sequence in logd [#2452]

    changeset: 8794:79f068cb5ef5
    branch: opensaf-5.1.x
    tag: tip
    parent: 8782:9d4e9d9cbcb9
    user: A V Mahesh mahesh.valla@oracle.com
    date: Mon May 15 10:16:17 2017 +0530
    summary: log: correct mutex lock and unlock sequence in logd [#2452]

     

    Related

    Tickets: #2452

  • A V Mahesh (AVM)

    • status: review --> fixed
     
  • A V Mahesh (AVM)

    5.17.08
    commit b750bdddb00444276b88a19fa1be9131753bd80d
    Author: A V Mahesh mahesh.valla@oracle.com
    Date: Wed May 10 15:24:46 2017 +0530

    log: correct mutex lock and unlock sequence in logd [#2452]
    

    5.17.06
    commit 91341ee47e84b298ae82a1d28db119a9b56f1d0b
    Author: A V Mahesh mahesh.valla@oracle.com
    Date: Wed May 10 15:24:46 2017 +0530

    log: correct mutex lock and unlock sequence in logd [#2452]
    
     

Log in to post a comment.