Fix FastCGI error handling
This commit is contained in:
@ -213,6 +213,8 @@ int fastcgi_close_cnx(fastcgi_cnx_t *cnx) {
|
||||
sock_close(&cnx->out);
|
||||
if (cnx->fd_err != -1) close(cnx->fd_err);
|
||||
if (cnx->fd_out != -1) close(cnx->fd_out);
|
||||
cnx->fd_err = -1;
|
||||
cnx->fd_out = -1;
|
||||
|
||||
errno = e;
|
||||
return 0;
|
||||
|
@ -51,10 +51,9 @@ int fastcgi_handle_connection(client_ctx_t *ctx, fastcgi_cnx_t **cnx) {
|
||||
}
|
||||
|
||||
void fastcgi_close(fastcgi_ctx_t *ctx) {
|
||||
if (ctx->closed == 0) {
|
||||
ctx->closed++;
|
||||
ctx->closed++;
|
||||
if (ctx->closed != 2)
|
||||
return;
|
||||
}
|
||||
|
||||
logger_set_prefix("[%*s]%s", ADDRSTRLEN, ctx->client->socket.s_addr, ctx->client->log_prefix);
|
||||
|
||||
@ -70,3 +69,8 @@ void fastcgi_close(fastcgi_ctx_t *ctx) {
|
||||
free(ctx);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
void fastcgi_close_error(fastcgi_ctx_t *ctx) {
|
||||
logger_set_prefix("[%*s]%s", ADDRSTRLEN, ctx->client->socket.s_addr, ctx->client->log_prefix);
|
||||
fastcgi_close_cnx(&ctx->cnx);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void fastcgi_error_cb(chunk_ctx_t *ctx) {
|
||||
// FIXME segfault on error_cb
|
||||
warning("Closing connection due to FastCGI error");
|
||||
if(ctx->client->fcgi_ctx) {
|
||||
fastcgi_close(ctx->client->fcgi_ctx);
|
||||
fastcgi_close_error(ctx->client->fcgi_ctx);
|
||||
ctx->client->fcgi_ctx = NULL;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ typedef struct {
|
||||
} ws_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
int closed:2;
|
||||
unsigned char closed:4;
|
||||
client_ctx_t *client;
|
||||
fastcgi_cnx_t cnx;
|
||||
} fastcgi_ctx_t;
|
||||
@ -95,4 +95,6 @@ int fastcgi_handle_connection(client_ctx_t *ctx, fastcgi_cnx_t **cnx);
|
||||
|
||||
void fastcgi_close(fastcgi_ctx_t *ctx);
|
||||
|
||||
void fastcgi_close_error(fastcgi_ctx_t *ctx);
|
||||
|
||||
#endif //SESIMOS_FUNC_H
|
||||
|
Reference in New Issue
Block a user