//this function is called when writer thread is sleeping int DbDumperWriter::rotate_date_dir() { char datebuf[MAX_DATE_LEN]; int ret = OB_SUCCESS; get_current_date(datebuf, MAX_DATE_LEN); CThreadGuard guard(&records_lock_); //need to change dir if (current_date_.compare(datebuf)) { std::string tmp_path = path_ + "/" + current_date_ ; tmp_path += "/"; ret = output_files_.output_done(tmp_path); if (ret != OB_SUCCESS) { TBSYS_LOG(ERROR, "can't write done file, path:%s, %d", tmp_path.c_str(), ret); report_msg(MSG_ERROR, "can't write done file, path:%s", tmp_path.c_str()); } TBSYS_LOG(INFO, "max writen files number=[%ld]", log_id_); //finish all tmp file if (ret == OB_SUCCESS) { if (file_ != NULL) { file_->Sync(); delete file_; file_ = NULL; } ret = mv_output_file(); if (ret != OB_SUCCESS) { TBSYS_LOG(ERROR, "can't mv_out_file "); } } if (ret == OB_SUCCESS) { //date has changed, rotate to new dir current_date_ = datebuf; TBSYS_LOG(INFO, "change to new date, %s", current_date_.c_str()); ret = init_output_files(); if (ret != OB_SUCCESS) { TBSYS_LOG(ERROR, "can't change directory"); } } } else { TBSYS_LOG(WARN, "can't roate date dir,because date hasn't changed"); } return ret; }
void _q931_msg_put( struct q931_message *msg) { assert(msg); assert(msg->refcnt > 0); msg->refcnt--; if (msg->refcnt == 0) { report_msg(msg, LOG_DEBUG, "Releasing message\n"); if (msg->dlc) q931_dlc_put(msg->dlc); free(msg); } }