mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
Kernel: Fix non-blocking write() blocking instead of short-writing
If a partial write succeeded, we could then be in an unexpected state where the file description was non-blocking, but we could no longer write to it. Previously, the kernel would block in that state, but instead we now handle this as a proper short write and return the number of bytes we were able to write. Fixes #2645.
This commit is contained in:
parent
fc79fefb5e
commit
a98712035c
1 changed files with 5 additions and 0 deletions
|
@ -1716,6 +1716,11 @@ ssize_t Process::do_write(FileDescription& description, const u8* data, int data
|
|||
dbg() << "while " << nwritten << " < " << size;
|
||||
#endif
|
||||
if (!description.can_write()) {
|
||||
if (!description.is_blocking()) {
|
||||
// Short write: We can no longer write to this non-blocking description.
|
||||
ASSERT(nwritten > 0);
|
||||
return nwritten;
|
||||
}
|
||||
#ifdef IO_DEBUG
|
||||
dbg() << "block write on " << description.absolute_path();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue