Add `is_blocking()` method to FileHandle

There was no way to check current blocking state, so no way to modify
and restore status.

Also have default FileHandle::set_blocking() used by real files return a
correct error code when asked for non-blocking, and success when asked
for blocking.

These were minor omissions that are required to implement POSIX fcntl
properly.

fixup! Add `is_blocking()` method to FileHandle
pull/6791/head
Kevin Bracey 2018-05-02 13:52:02 +03:00
parent c8d72c524d
commit 59f49e2b96
2 changed files with 19 additions and 1 deletions

View File

@ -142,6 +142,15 @@ public:
return 0;
}
/** Check current blocking or non-blocking mode for file operations.
*
* @return true for blocking mode, false for non-blocking mode.
*/
virtual bool is_blocking() const
{
return _blocking;
}
/** Register a callback on state change of the file.
*
* The specified callback will be called on state changes such as when

View File

@ -192,7 +192,16 @@ public:
*/
virtual int set_blocking(bool blocking)
{
return -1;
return blocking ? 0 : -ENOTTY;
}
/** Check current blocking or non-blocking mode for file operations.
*
* @return true for blocking mode, false for non-blocking mode.
*/
virtual bool is_blocking() const
{
return true;
}
/** Check for poll event flags