Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <type_traits>

#include "miniocpp/error.h"
Expand Down Expand Up @@ -431,18 +432,28 @@ Response Request::execute() {
fd_set fdread{};
fd_set fdwrite{};
fd_set fdexcep{};
int maxfd = 0;
int maxfd = -1;

FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);

requests.fdset(&fdread, &fdwrite, &fdexcep, &maxfd);

if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, nullptr) < 0) {
std::cerr << "select() failed; this should not happen" << std::endl;
std::terminate();
timeval timeout{};
timeout.tv_sec = 0;
timeout.tv_usec = 10000;

if (maxfd == -1) {
std::this_thread::sleep_for(10);
} else {
int ret = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
if (ret < 0) {
std::cerr << "select() failed; this should not happen" << std::endl;
std::terminate();
}
}

while (!requests.perform(&left)) {
}
}
Expand Down