Honor proxy server timeout with one second buffer
This commit is contained in:
@ -399,8 +399,9 @@ int proxy_init(proxy_ctx_t **proxy_ptr, http_req *req, http_res *res, http_statu
|
|||||||
if (!retry)
|
if (!retry)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
// honor server timeout with one second buffer
|
||||||
if (!proxy->initialized || sock_has_pending(&proxy->proxy, SOCK_DONTWAIT) != 0 || srv_error ||
|
if (!proxy->initialized || sock_has_pending(&proxy->proxy, SOCK_DONTWAIT) != 0 || srv_error ||
|
||||||
(proxy->http_timeout != 0 && (clock_micros() - proxy->proxy.ts_last) >= proxy->http_timeout))
|
(proxy->http_timeout != 0 && (clock_micros() - proxy->proxy.ts_last_send) >= proxy->http_timeout - 1000000))
|
||||||
{
|
{
|
||||||
if (proxy->initialized)
|
if (proxy->initialized)
|
||||||
proxy_close(proxy);
|
proxy_close(proxy);
|
||||||
|
@ -86,6 +86,7 @@ int sock_init(sock *s, int fd, int flags) {
|
|||||||
s->pipe = !!(flags & SOCK_PIPE);
|
s->pipe = !!(flags & SOCK_PIPE);
|
||||||
s->ts_start = clock_micros();
|
s->ts_start = clock_micros();
|
||||||
s->ts_last = s->ts_start;
|
s->ts_last = s->ts_start;
|
||||||
|
s->ts_last_send = s->ts_last;
|
||||||
s->timeout_us = -1;
|
s->timeout_us = -1;
|
||||||
s->ssl = NULL;
|
s->ssl = NULL;
|
||||||
s->addr = NULL;
|
s->addr = NULL;
|
||||||
@ -224,6 +225,7 @@ long sock_send(sock *s, void *buf, unsigned long len, int flags) {
|
|||||||
|
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
s->ts_last = clock_micros();
|
s->ts_last = clock_micros();
|
||||||
|
s->ts_last_send = s->ts_last;
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -31,7 +31,7 @@ typedef struct {
|
|||||||
char *addr, *s_addr;
|
char *addr, *s_addr;
|
||||||
SSL_CTX *ctx;
|
SSL_CTX *ctx;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
long ts_start, ts_last, timeout_us;
|
long ts_start, ts_last, ts_last_send, timeout_us;
|
||||||
} sock;
|
} sock;
|
||||||
|
|
||||||
void sock_error(sock *s, int ret);
|
void sock_error(sock *s, int ret);
|
||||||
|
@ -84,6 +84,7 @@ static int tcp_acceptor(client_ctx_t *ctx) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
client->ts_last = clock_micros();
|
client->ts_last = clock_micros();
|
||||||
|
client->ts_last_send = client->ts_last;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->req_num = 0;
|
ctx->req_num = 0;
|
||||||
|
Reference in New Issue
Block a user