mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 02:59:49 +01:00
http: Add timeout on no response.
Firewalls can cause this, by opening a connection but never responding.
This commit is contained in:
1 parent
2dbdd73e5f
commit
359afb2d6b
5 files changed
+25
-8
No files matched your search
@@ -146,8 +146,12 @@ bool Buffer::FlushToFile(const char *filename) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Buffer::FlushSocket(uintptr_t sock) {
|
||||
bool Buffer::FlushSocket(uintptr_t sock, double timeout) {
|
||||
for (size_t pos = 0, end = data_.size(); pos < end; ) {
|
||||
if (timeout >= 0.0 && !fd_util::WaitUntilReady(sock, timeout, true)) {
|
||||
ELOG("FlushSocket timed out");
|
||||
return false;
|
||||
}
|
||||
int sent = send(sock, &data_[pos], (int)(end - pos), MSG_NOSIGNAL);
|
||||
if (sent < 0) {
|
||||
ELOG("FlushSocket failed");
|
||||
@@ -156,7 +160,7 @@ bool Buffer::FlushSocket(uintptr_t sock) {
|
||||
pos += sent;
|
||||
|
||||
// Buffer full, don't spin.
|
||||
if (sent == 0) {
|
||||
if (sent == 0 && timeout < 0.0) {
|
||||
sleep_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user