|
@@ -49,11 +49,20 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
ReadonlyBytes bytes_to_write { buffer.data.span() };
|
|
ReadonlyBytes bytes_to_write { buffer.data.span() };
|
|
|
|
+ int writes_done = 0;
|
|
|
|
+ size_t initial_size = bytes_to_write.size();
|
|
while (!bytes_to_write.is_empty()) {
|
|
while (!bytes_to_write.is_empty()) {
|
|
auto maybe_nwritten = m_socket->write(bytes_to_write);
|
|
auto maybe_nwritten = m_socket->write(bytes_to_write);
|
|
|
|
+ writes_done++;
|
|
if (maybe_nwritten.is_error()) {
|
|
if (maybe_nwritten.is_error()) {
|
|
auto error = maybe_nwritten.release_error();
|
|
auto error = maybe_nwritten.release_error();
|
|
if (error.is_errno()) {
|
|
if (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();
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
shutdown_with_error(error);
|
|
shutdown_with_error(error);
|
|
switch (error.code()) {
|
|
switch (error.code()) {
|
|
case EPIPE:
|
|
case EPIPE:
|
|
@@ -70,6 +79,9 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
|
|
|
|
|
|
bytes_to_write = bytes_to_write.slice(maybe_nwritten.value());
|
|
bytes_to_write = bytes_to_write.slice(maybe_nwritten.value());
|
|
}
|
|
}
|
|
|
|
+ if (writes_done > 1) {
|
|
|
|
+ dbgln("LibIPC::Connection FIXME Warning, needed {} writes needed to send message of size {}B, this is pretty bad, as it spins on the EventLoop", writes_done, initial_size);
|
|
|
|
+ }
|
|
|
|
|
|
m_responsiveness_timer->start();
|
|
m_responsiveness_timer->start();
|
|
return {};
|
|
return {};
|