Mark proxy connection free on error
This commit is contained in:
@ -90,6 +90,7 @@ static proxy_ctx_t *proxy_get_by_conf(host_config_t *conf) {
|
||||
n++;
|
||||
}
|
||||
|
||||
// TODO use semaphore to keep track of number of free proxy connections
|
||||
try_again:
|
||||
if (sem_wait(&lock) != 0) {
|
||||
if (errno == EINTR) {
|
||||
|
@ -306,6 +306,7 @@ int main(int argc, char *const argv[]) {
|
||||
|
||||
notice("Ready to accept connections");
|
||||
|
||||
// TODO handle timeouts in epoll
|
||||
async_thread();
|
||||
|
||||
notice("Goodbye!");
|
||||
|
@ -26,11 +26,14 @@ void proxy_handler_func(client_ctx_t *ctx) {
|
||||
respond(ctx);
|
||||
|
||||
if (ret == 1) {
|
||||
|
||||
ctx->proxy->in_use = 0;
|
||||
ctx->proxy = NULL;
|
||||
} else if (ctx->use_proxy == 0) {
|
||||
proxy_close(ctx->proxy);
|
||||
} else if (ctx->use_proxy == 1) {
|
||||
proxy_handler_2(ctx);
|
||||
ctx->proxy->in_use = 0;
|
||||
ctx->proxy = NULL;
|
||||
} else if (ctx->use_proxy == 2) {
|
||||
// WebSocket
|
||||
ws_handle_connection(ctx);
|
||||
@ -137,8 +140,6 @@ static int proxy_handler_2(client_ctx_t *ctx) {
|
||||
|
||||
int flags = (chunked ? PROXY_CHUNKED : 0) | (ctx->use_proxy & PROXY_COMPRESS);
|
||||
int ret = proxy_send(ctx->proxy, &ctx->socket, len_to_send, flags);
|
||||
ctx->proxy->in_use = 0;
|
||||
ctx->proxy = NULL;
|
||||
|
||||
if (ret < 0) {
|
||||
ctx->c_keep_alive = 0;
|
||||
|
Reference in New Issue
Block a user