Noux: add is_nonblocking() method

Certain programs tend to set their sockets non-blocking. As previously
descriptors in Noux were only blocking we now introduce a method to mark
the used Io_channel as non-blocking.
This commit is contained in:
Josef Söntgen 2012-08-21 15:46:30 +02:00 committed by Norman Feske
parent 343266b06e
commit 95f71a5f71
2 changed files with 11 additions and 4 deletions

View File

@ -70,6 +70,11 @@ namespace Noux {
virtual bool check_unblock(bool rd, bool wr, bool ex) const {
return false; }
/**
* Return true if the channel is set to non-blocking mode
*/
virtual bool is_nonblocking() { return false; }
/**
* Register blocker for getting waked up on an I/O channel event
*

View File

@ -140,6 +140,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
Shared_pointer<Io_channel> io = _lookup_channel(_sysio->write_in.fd);
if (!io->is_nonblocking())
if (!io->check_unblock(false, true, false))
_block_for_io_channel(io);
@ -156,6 +157,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio->read_in.fd);
if (!io->is_nonblocking())
while (!io->check_unblock(true, false, false))
_block_for_io_channel(io);