Hi,
I’m writing a classes-wrappers around MsgSend/MsgReceive (QNX 6.3.2). First version is done. I’ve planned to set timeouts for client MsgSend calls by TimerTimeout:
int CClient::Write( const void* sendBuf, size_t bufSz )
{
int res;
struct _io_write whdr;
iov_t iov[2];
SETIOV( iov+0, &whdr, sizeof(whdr) );
SETIOV( iov+1, sendBuf, bufSz );
whdr.type = _IO_WRITE;
whdr.nbytes = bufSz;
//timeout set (if server is down we will get ETIMEDOUT error)
uint64_t timeout = 1*1000000000;
TimerTimeout( CLOCK_REALTIME, _NTO_TIMEOUT_SEND | _NTO_TIMEOUT_REPLY, NULL, &timeout, NULL );
//
res = MsgSendv_r( m_serverId, iov, 2, iov, 1 );
if( res < 0 )
res = -res;
return res;
}
At the server side there is an endless cycle with MsgReceive. I simulate server crash by sleep function. If i want to make client SEND blocked i place sleep(20) before MsgReceive. If i want the clinet be REPLY blocked, i place sleep(20) before MsgReply (after MsgReceive).
...
//sleep(20);
rcvid = MsgReceive( pServer->m_nameAttach->chid, &header, sizeof(header), &msg_info );
....
switch( header.type )
{
case _IO_WRITE:
//sleep(20);
pServer->OnWrite( rcvid, header.io_write.xtype, header.io_write.nbytes );
MsgReply( rcvid, EOK, NULL, 0 );
break;
The problem is timeout doesn’t work in case of REPLY blocked client (when i uncomment sleep before MsgReply).
Documentation says:
But i don’t set _NTO_CHF_UNBLOCK for the channel ( i do name_attach , that doesn’t set any flag for channel ). So, my client should be unblocked on timeout.
Is there any method to set timeout for MsgSend?
Thanks