- **status**: accepted --> review


---

** [tickets:#2452] log: mutex lock missing in error cases of 
write_log_record_hdl() **

**Status:** review
**Milestone:** 5.1.0
**Created:** Thu May 04, 2017 05:54 AM UTC by A V Mahesh (AVM)
**Last Updated:** Thu May 04, 2017 06:59 AM UTC
**Owner:** A V Mahesh (AVM)


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);
  
=================================================================================


---

Sent from sourceforge.net because opensaf-tickets@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/opensaf/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/opensaf/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-tickets mailing list
Opensaf-tickets@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets

Reply via email to