mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 23:28:12 +00:00
ProtocolServer: Avoid blocking all downloads when client stops reading
Fixes #4668.
This commit is contained in:
parent
83fed3fd5d
commit
2568a93b5d
7 changed files with 45 additions and 28 deletions
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include <AK/HashMap.h>
|
||||
#include <ProtocolServer/Protocol.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace ProtocolServer {
|
||||
|
||||
|
@ -50,4 +52,16 @@ Protocol::~Protocol()
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
Result<Protocol::Pipe, String> Protocol::get_pipe_for_download()
|
||||
{
|
||||
int fd_pair[2] { 0 };
|
||||
if (pipe(fd_pair) != 0) {
|
||||
auto saved_errno = errno;
|
||||
dbgln("Protocol: pipe() failed: {}", strerror(saved_errno));
|
||||
return String { strerror(saved_errno) };
|
||||
}
|
||||
fcntl(fd_pair[1], F_SETFL, fcntl(fd_pair[1], F_GETFL) | O_NONBLOCK);
|
||||
return Pipe { fd_pair[0], fd_pair[1] };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue