unsigned int BIO::doWrite(const data_chunk& data_to_write, int offset) const { int written = 0; int num2wr = data_to_write.size() - offset; assert(num2wr > 0); DBG << "Writing " << num2wr << "B - " << Utils::DataToString(data_to_write) << std::endl; if (num2wr == 0) { return 0; } for (;;) { written = BIO_write(itsBIO, &data_to_write.at(offset), num2wr); if (written <= 0) { if (this->ShouldRetry()) { std::string s("Recoverable error when writing to BIO"); if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { throw RecoverableException(s); } } std::string s("Fatal error when writing to BIO; "); s += Utils::getLastErrorSSL(); throw RemoteDiedException(s); } break; } DBG << "Written " << written << "B" << std::endl; return written; }
/*-------------------------------------------------------------Routine::raise-+ | DO NOT USE for SIG_SYNTAX! (use: m_erh << ECE__ERROR) | +----------------------------------------------------------------------------*/ void Routine::raise(Signaled sig) { if ((m_signals & sig) && (!(m_signals & SIG_DISABLED))) { throw RecoverableException(sig, true); }else if (m_callons & sig) { m_raisedConds |= sig; // wait 'til end of clause } }
data_chunk BIO::doRead() const { data_chunk tempData(itsChunkSize); DBG << "BIO read will be attempted" << std::endl; int rxedNumber = -1; while (rxedNumber < 0) { rxedNumber = BIO_read(itsBIO, &tempData.at(0), itsChunkSize); if (rxedNumber <= 0) { NFO << "BIO read interrupted" << std::endl; if (this->ShouldRetry()) { std::string s("Recoverable error when reading from BIO"); if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { throw RecoverableException(s); } } else { std::string s("Fatal error when reading from BIO; "); s += Utils::getLastErrorSSL(); throw RemoteDiedException(s); } } else { tempData.resize(rxedNumber); DBG << "Data read from BIO" << Utils::DataToString(tempData) << std::endl; } } return tempData; }
Handle * VectorValue::elementAt( int i) { MCAssertValidInstance(); if (i < static_cast<int>( m_values.size())) return m_values[i]; else //FIXME: create proper hierarchy of exceptions throw RecoverableException( "index out of bounds", __FILE__, __LINE__); }
/*------------------------------------------------Routines::raisePendingConds-+ | | +----------------------------------------------------------------------------*/ void Routines::raisePendingConds() { Signaled sig; if (m_pendingConds & SIG_ERROR) { sig = SIG_ERROR; }else if (m_pendingConds & SIG_FAILURE) { sig = SIG_FAILURE; }else if (m_pendingConds & SIG_HALT) { sig = SIG_HALT; }else if (m_pendingConds & SIG_NOTREADY) { sig = SIG_NOTREADY; }else { return; } m_pendingConds &= ~sig; throw RecoverableException(sig, false); }