mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 23:35:41 +00:00
repeat sendfile() until all data is sent
This commit is contained in:
parent
8b753ab6ea
commit
82a6d4af60
@ -831,13 +831,17 @@ void TNetwork::SplitLoad(TClient& c, size_t Offset, size_t End, bool D, const st
|
||||
// native handle, needed in order to make native syscalls with it
|
||||
int socket = D ? c.GetDownSock().native_handle() : c.GetTCPSock().native_handle();
|
||||
|
||||
auto SysOffset = off_t(Offset);
|
||||
|
||||
ssize_t ret = sendfile64(socket, fd, &SysOffset, End - Offset);
|
||||
ssize_t ret = 0;
|
||||
auto ToSendTotal = End - Offset;
|
||||
auto Start = Offset;
|
||||
while (ret < ssize_t(ToSendTotal)) {
|
||||
auto SysOffset = off_t(Start + size_t(ret));
|
||||
ret = sendfile(socket, fd, &SysOffset, ToSendTotal - size_t(ret));
|
||||
if (ret < 0) {
|
||||
beammp_errorf("Failed to send mod '{}' to client {}: {}", Name, c.GetID(), std::strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
std::ifstream f(Name.c_str(), std::ios::binary);
|
||||
|
Loading…
x
Reference in New Issue
Block a user