pixelflut: Ignore EAGAIN errors
Very contested servers are likely to cause EAGAIN socket errors on the client. Since these errors are not supposed to be fatal, just try sending the pixel again. This was tested successfully against massively contested 37c3 pixelflut servers.
This commit is contained in:
parent
ca2be5c51b
commit
fdfd4b5e3d
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/fdfd4b5e3d Pull-request: https://github.com/SerenityOS/serenity/pull/22498
1 changed files with 6 additions and 1 deletions
|
@ -118,7 +118,12 @@ ErrorOr<void> Client::send_current_pixel()
|
|||
auto hex_without_hash = hex.substring(1);
|
||||
|
||||
// PX <x> <y> <hex color>
|
||||
TRY(m_socket->write_formatted("PX {} {} {}\n", m_current_point.x() + m_image_offset.x(), m_current_point.y() + m_image_offset.y(), hex_without_hash));
|
||||
while (true) {
|
||||
auto result = m_socket->write_formatted("PX {} {} {}\n", m_current_point.x() + m_image_offset.x(), m_current_point.y() + m_image_offset.y(), hex_without_hash);
|
||||
// Very contested servers will cause frequent EAGAIN errors.
|
||||
if (!result.is_error() || result.error().code() != EAGAIN)
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue