unique_ptr<char, void (*)(
void*)>
94 string result(
"[CConn_Streambuf::");
118::sprintf(x_timeout,
"[%u.%06us]",
119timeout->
usec/ 1000000 + timeout->
sec,
120timeout->
usec% 1000000);
135: m_Conn(0), x_Connector(connector),
136m_WriteBuf(0), m_ReadBuf(&x_Buf), m_BufSize(1), m_Status(status),
186: m_Conn(
conn), x_Connector(0),
187m_WriteBuf(0), m_ReadBuf(&x_Buf), m_BufSize(1), m_Status(
eIO_Success),
243unique_ptr<CT_CHAR_TYPE[]> wbp;
260setp(write_buf, write_buf + buf_size);
266setg(ptr, ptr, ptr +
size);
283 "Failed to open",
m_Status, timeout));
298 size_t count= (size_t)(egptr() - gptr());
304gbump(
int(
count));
323 "CONN_Pushback() failed"));
329 if(pbase() < pptr()) {
335 "Cannot finalize implicitly" 336 ", data loss may result"));
339 boolsynced =
false;
380 "CONN_Close() failed",
386}
else if(cb_valid &&
m_Cb.
func) {
411 if(
buf|| buf_size) {
413 "CConn_Streambuf::setbuf() only allowed with (0, 0)");
420 "Read data pending",
425 "Write data pending"));
445 _ASSERT(pbase() <= pptr() && pptr() <= epptr());
451 size_tn_towrite = (size_t)(pptr() - pbase());
458 _ASSERT(n_written <= n_towrite);
464 memmove(pbase(), pbase() + n_written, n_towrite - n_written);
466pbump(-
int(n_written));
471n_towrite -= n_written;
518 _ASSERT(pbase() <= pptr() && pptr() <= epptr());
525 size_t n= (size_t) m;
526 size_tn_written = 0;
531 if(
n&& pbase() +
n< epptr()) {
533x_written = (size_t)(epptr() - pptr());
537memcpy(pptr(),
buf, x_written);
538pbump(
int(x_written));
539n_written += x_written;
542 return(streamsize) n_written;
547 size_tx_towrite = (size_t)(pptr() - pbase());
551 _ASSERT(x_written <= x_towrite);
560 memmove(pbase(), pbase() + x_written, x_towrite - x_written);
562pbump(-
int(x_written));
570 if(!x_written &&
n) {
573 "CONN_Write(direct) failed",
m_Status,
579n_written += x_written;
582 return(streamsize) n_written;
589x_written = (size_t)(epptr() - pptr());
593memcpy(pptr(),
buf, x_written);
594n_written += x_written;
595pbump(
int(x_written));
601 return(streamsize) n_written;
616 #ifdef NCBI_COMPILER_MIPSPRO 617 if(m_MIPSPRO_ReadsomeGptrSetLevel && m_MIPSPRO_ReadsomeGptr != gptr())
661 size_t n= (size_t) m;
666n_read = (size_t)(egptr() - gptr());
670memcpy(
buf, gptr(), n_read);
671gbump(
int(n_read));
674 return(streamsize) n_read;
703 size_txx_read = x_read;
725 return(streamsize) n_read;
739 #define POLLING &CConn_IOStream::kZeroTimeout 753 boolpolling = !x_tmo
|| (x_tmo->
sec| x_tmo->
usec);
801IOS_BASE::seekdir whence,
802IOS_BASE::openmode which)
804 if(whence == IOS_BASE::cur && off == 0) {
815&& ((whence == IOS_BASE::cur && (off > 0)) ||
816(whence == IOS_BASE::beg && (off -=
x_GetGPos()) >= 0))){
817 if(
m_Conn&&
x_Read(0, (streamsize) off) == (streamsize) off)
836 "CONN_Pushback() failed"));
856 if(pbase() < pptr()) {
859 boolsynced =
false;
884 if(gptr() < egptr())
893 "CONN_Wait() failed",
902 switch(GetErrCode()) {
903 case eConn:
return "eConn";
912 switch(GetErrCode()) {
913 case eTimeout:
return "eIO_Timeout";
917 case eUnknown:
return "eIO_Unknown";
918 case eClosed:
return "eIO_Closed";
CConn_Streambuf(CONNECTOR connector, EIO_Status status, const STimeout *timeout, size_t buf_size, CConn_IOStream::TConn_Flags flags, CT_CHAR_TYPE *ptr, size_t size)
virtual ~CConn_Streambuf()
EIO_Status Status(EIO_Event direction) const
virtual CT_INT_TYPE underflow(void)
streamsize x_Read(CT_CHAR_TYPE *buf, streamsize n)
void x_Init(const STimeout *timeout, size_t buf_size, CConn_IOStream::TConn_Flags flags, CT_CHAR_TYPE *ptr, size_t size)
CT_POS_TYPE x_GetPPos(void)
CT_CHAR_TYPE * m_WriteBuf
string x_Message(const char *method, const char *message, EIO_Status status=eIO_Success, const STimeout *timeout=kInfiniteTimeout)
virtual CT_INT_TYPE overflow(CT_INT_TYPE c)
virtual streamsize xsgetn(CT_CHAR_TYPE *buf, streamsize n)
static EIO_Status x_OnClose(CONN conn, TCONN_Callback type, void *data)
EIO_Status Fetch(const STimeout *timeout)
virtual CT_POS_TYPE seekoff(CT_OFF_TYPE off, IOS_BASE::seekdir whence, IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out)
Only seekoff(0, IOS_BASE::cur, *) to obtain the current position, and input skip-forward are permitte...
EIO_Status x_Close(bool close)
virtual streamsize xsputn(const CT_CHAR_TYPE *buf, streamsize n)
EIO_Status Pushback(const CT_CHAR_TYPE *data, streamsize size, bool push)
Push the specified data "data" of size "size" back into the underlying connection CONN.
virtual CNcbiStreambuf * setbuf(CT_CHAR_TYPE *buf, streamsize buf_size)
Only setbuf(0, 0) is allowed to make I/O unbuffered, other parameters will cause an exception thrown ...
virtual streamsize showmanyc(void)
EIO_Status x_Pushback(void) THROWS_NONE
CT_POS_TYPE x_GetGPos(void)
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
virtual const char * GetErrCodeString(void) const override
virtual const char * GetErrCodeString(void) const override
#define NCBI_IO_CHECK(errnum)
Check EIO_Status, throw an exception if something is wrong.
@ eConn
Unspecified connect problem.
unsigned int TConn_Flags
bitwise OR of EConn_Flag
@ fConn_ReadUnbuffered
read buffer NOT to be alloc'd
@ fConn_WriteUnbuffered
write buffer NOT 2.b. alloc'd
@ fConn_DelayOpen
do not force CONN open in ctor
@ fConn_Untie
do not flush before reading
EIO_Status CONN_CreateEx(CONNECTOR connector, TCONN_Flags flags, CONN *conn)
Create all data necessary to establish a new connection (merely bind it to the specified CONNECTOR).
EIO_Status CONN_Read(CONN conn, void *buf, size_t size, size_t *n_read, EIO_ReadMethod how)
EIO_Status CONN_Flush(CONN conn)
Explicitly flush connection from any pending data written by CONN_Write().
EIO_Status CONN_SetCallback(CONN conn, ECONN_Callback type, const SCONN_Callback *new_cb, SCONN_Callback *old_cb)
unsigned int TCONN_Callback
EIO_Status CONN_Write(CONN conn, const void *buf, size_t size, size_t *n_written, EIO_WriteMethod how)
CONNECTOR next
linked list
void * data
data to pass to the callback as its last arg
EIO_Status CONN_SetTimeout(CONN conn, EIO_Event event, const STimeout *timeout)
Specify timeout for the connection I/O, including "Connect" (aka "Open") and "Close".
char * CONN_Description(CONN conn)
Return a human-readable description of the connection as a character '\0'-terminated string.
FDestroy destroy
destroys handle, can be NULL
EIO_Status CONN_Wait(CONN conn, EIO_Event event, const STimeout *timeout)
Block on the connection until it becomes available for either reading or writing (depending on "event...
SMetaConnector * meta
back link to original meta
const char * CONN_GetType(CONN conn)
Get verbal representation of connection type as a character string.
EIO_Status CONN_Close(CONN conn)
Close the connection and destroy all relevant internal data.
EIO_Status CONN_GetSOCK(CONN conn, SOCK *sock)
Get an underlying SOCK handle for connection that is implemented as a socket.
const STimeout * CONN_GetTimeout(CONN conn, EIO_Event event)
Retrieve current timeout, return NULL(kInfiniteTimeout) if it is infinite.
const STimeout g_NcbiDefConnTimeout
DEF_CONN_TIMEOUT as STimeout.
EIO_Status CONN_Status(CONN conn, EIO_Event dir)
Obtain status of the last I/O operation.
EIO_Status CONN_Pushback(CONN conn, const void *data, size_t size)
Push "size" bytes from the buffer "data" back into connection.
FCONN_Callback func
function address to call on the event
@ eCONN_OnClose
NB: CONN has been flushed prior to the call.
@ fCONN_Untie
do not call flush method prior to reading
@ fCONN_Supplement
supplement I/O with extended return codes
#define _ALWAYS_TRACE(message)
Define macros to support debugging.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Critical(CExceptionArgs_Base &args)
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Trace(CExceptionArgs_Base &args)
void Warning(CExceptionArgs_Base &args)
#define THROWS_NONE
Do not use 'throw' dynamic exception specification for C++11 compilers.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::streambuf CNcbiStreambuf
Portable alias for streambuf.
unsigned int usec
microseconds (modulo 1,000,000)
const char * IO_StatusStr(EIO_Status status)
Get the text form of an enum status value.
EIO_Event
I/O event (or direction).
@ eIO_Timeout
timeout expired before any I/O succeeded
@ eIO_NotSupported
operation is not supported or is not available
@ eIO_Success
everything is fine, no error occurred
@ eIO_InvalidArg
bad argument / parameter value(s) supplied
@ eIO_ReadPlain
read readily available data only, wait if none
@ eIO_WritePlain
write as much as possible, report back how much
@ eIO_ReadWrite
eIO_Read | eIO_Write (also, eCONN_OnFlush)
@ eIO_Open
also serves as no-event indicator in SOCK_Poll
@ eIO_Close
also serves as an error indicator in SOCK_Poll
Definition of all error codes used in connect library (xconnect.lib, xconnext.lib etc).
static const CS_INT unused
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
static bool x_CheckConn(const CONN conn)
static bool x_IsThrowable(EIO_Status status)
static const STimeout * x_GetDefaultTimeout(const CONN conn)
NCBI C++ auxiliary debug macros.
std::istream & in(std::istream &in_, double &x_)
const CNSPreciseTime default_timeout(3600, 0)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4