void BULKIO_dataOctet_In_i::pushPacket(const CF::OctetSequence& data, const BULKIO::PrecisionUTCTime& T, CORBA::Boolean EOS, const char* streamID) { if (queueSem->getMaxValue() == 0) { return; } BULKIO::StreamSRI tmpH = {1, 0.0, 1.0, 1, 0, 0.0, 0.0, 0, 0, streamID, false, 0}; bool sriChanged = false; bool portBlocking = false; RH_SRIMap::iterator currH; { boost::mutex::scoped_lock lock(sriUpdateLock); currH = currentHs.find(std::string(streamID)); if (currH != currentHs.end()) { tmpH = currH->second.first; sriChanged = currH->second.second; currentHs[streamID] = std::make_pair(currH->second.first, false); } portBlocking = blocking; } if(portBlocking) { queueSem->incr(); boost::mutex::scoped_lock lock(dataBufferLock); stats.update(data.length(), workQueue.size()/queueSem->getMaxValue(), EOS, streamID, false); BULKIO_dataOctet_In_i::dataTransfer *tmpIn = new BULKIO_dataOctet_In_i::dataTransfer(data, T, EOS, streamID, tmpH, sriChanged, false); workQueue.push_back(tmpIn); dataAvailable.notify_all(); } else { boost::mutex::scoped_lock lock(dataBufferLock); bool flushToReport = false; if (workQueue.size() == queueSem->getMaxValue()) { // reached maximum queue depth - flush the queue flushToReport = true; BULKIO_dataOctet_In_i::dataTransfer *tmp; while (workQueue.size() != 0) { tmp = workQueue.front(); workQueue.pop_front(); delete tmp; } } stats.update(data.length(), workQueue.size()/queueSem->getMaxValue(), EOS, streamID, flushToReport); BULKIO_dataOctet_In_i::dataTransfer *tmpIn = new BULKIO_dataOctet_In_i::dataTransfer(data, T, EOS, streamID, tmpH, sriChanged, flushToReport); workQueue.push_back(tmpIn); dataAvailable.notify_all(); } }
void File_impl::write (const CF::OctetSequence& data) throw (CORBA::SystemException, CF::File::IOException) { TRACE_ENTER(File_impl) boost::mutex::scoped_lock lock(interfaceAccess); int writeSuccessAttempts = 0; bool writeSuccess = false; while (!writeSuccess) { try { f.write((const char*)data.get_buffer(), data.length()); writeSuccess = true; } catch ( const fs::filesystem_error& ex ) { LOG_WARN(File_impl, "Error in filesystem: "<<ex.what()<<". Attempting again") writeSuccessAttempts++; if (writeSuccessAttempts == 10) { break; } usleep(10000); } catch ( ... ) { LOG_WARN(File_impl, "Caught an unhandled file system exception. Attempting again") writeSuccessAttempts++; if (writeSuccessAttempts == 10) { break; } usleep(10000); } } if (!writeSuccess) { LOG_ERROR(File_impl, "Error writing to file, " << fName); throw (CF::File::IOException (CF::CF_EIO, "[File_impl::write] Error writing to file")); } if (f.fail()) { LOG_ERROR(File_impl, "Error writing to file, " << fName); throw (CF::File::IOException (CF::CF_EIO, "[File_impl::write] Error writing to file")); } TRACE_EXIT(File_impl) }