mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
LibIPC: Actually yield to the event loop when EMSGSIZE or EAGAIN
Previously this just yielded the time slice, which blocked the event loop until the other side read some data from the socket. This "fixed" impl is still equally bad, but at least it doesn't block the event loop.
This commit is contained in:
parent
ba54c9adb2
commit
30c41835e6
1 changed files with 3 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Checked.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibIPC/Message.h>
|
||||
#include <sched.h>
|
||||
|
@ -75,8 +76,8 @@ ErrorOr<void> MessageBuffer::transfer_message(Core::LocalSocket& socket)
|
|||
if (auto error = maybe_nwritten.release_error(); error.is_errno()) {
|
||||
// FIXME: This is a hacky way to at least not crash on large messages
|
||||
// The limit of 100 writes is arbitrary, and there to prevent indefinite spinning on the EventLoop
|
||||
if (error.code() == EAGAIN && writes_done < 100) {
|
||||
sched_yield();
|
||||
if ((error.code() == EAGAIN || error.code() == EMSGSIZE) && writes_done < 100) {
|
||||
Core::EventLoop::current().pump();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue