Skip to content

Commit

Permalink
Increase socket timeout to 30s
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterTea committed Jun 3, 2024
1 parent 271d2a6 commit 88f1192
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/base/SocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#include "base64.h"

namespace et {
#define SOCKET_DATA_TRANSFER_TIMEOUT (10)
#define SOCKET_DATA_TRANSFER_TIMEOUT (30)

void SocketHandler::readAll(int fd, void* buf, size_t count, bool timeout) {
time_t startTime = time(NULL);
size_t pos = 0;
while (pos < count) {
if (!waitOnSocketData(fd)) {
time_t currentTime = time(NULL);
if (timeout && currentTime > startTime + 10) {
if (timeout && currentTime > startTime + SOCKET_DATA_TRANSFER_TIMEOUT) {
throw std::runtime_error("Socket Timeout");
}
continue;
Expand Down Expand Up @@ -46,7 +46,7 @@ int SocketHandler::writeAllOrReturn(int fd, const void* buf, size_t count) {
time_t startTime = time(NULL);
while (pos < count) {
time_t currentTime = time(NULL);
if (currentTime > startTime + 10) {
if (currentTime > startTime + SOCKET_DATA_TRANSFER_TIMEOUT) {
return -1;
}
ssize_t bytesWritten = write(fd, ((const char*)buf) + pos, count - pos);
Expand Down Expand Up @@ -77,7 +77,7 @@ void SocketHandler::writeAllOrThrow(int fd, const void* buf, size_t count,
size_t pos = 0;
while (pos < count) {
time_t currentTime = time(NULL);
if (timeout && currentTime > startTime + 10) {
if (timeout && currentTime > startTime + SOCKET_DATA_TRANSFER_TIMEOUT) {
throw std::runtime_error("Socket Timeout");
}
ssize_t bytesWritten = write(fd, ((const char*)buf) + pos, count - pos);
Expand Down

0 comments on commit 88f1192

Please sign in to comment.