Fix FastCGI fds default value

This commit is contained in:
2023-07-05 13:11:49 +02:00
parent 733b73760c
commit 2e3146f69a
3 changed files with 8 additions and 6 deletions

View File

@ -82,7 +82,9 @@ int fastcgi_init(fastcgi_cnx_t *conn, int mode, unsigned int req_num, const sock
conn->webroot = uri->webroot; conn->webroot = uri->webroot;
conn->err = NULL; conn->err = NULL;
conn->fd_err_bytes = 0; conn->fd_err_bytes = 0;
sock_init(&conn->out, 0, SOCK_PIPE); conn->fd_out = -1;
conn->fd_err = -1;
sock_init(&conn->out, -1, SOCK_PIPE);
conn->socket.enc = 0; conn->socket.enc = 0;
if ((conn->socket.socket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { if ((conn->socket.socket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
@ -205,11 +207,11 @@ int fastcgi_close_cnx(fastcgi_cnx_t *cnx) {
if (cnx->err) fclose(cnx->err); if (cnx->err) fclose(cnx->err);
cnx->err = NULL; cnx->err = NULL;
if (cnx->socket.socket) sock_close(&cnx->socket); sock_close(&cnx->socket);
sock_close(&cnx->out); sock_close(&cnx->out);
close(cnx->fd_err); if (cnx->fd_err != -1) close(cnx->fd_err);
close(cnx->fd_out); if (cnx->fd_out != -1) close(cnx->fd_out);
errno = e; errno = e;
return 0; return 0;

View File

@ -379,7 +379,7 @@ int sock_close(sock *s) {
SSL_free(s->ssl); SSL_free(s->ssl);
s->ssl = NULL; s->ssl = NULL;
} }
close(s->socket); if (s->socket != -1) close(s->socket);
s->socket = -1; s->socket = -1;
s->enc = 0, s->pipe = 0; s->enc = 0, s->pipe = 0;
errno = e; errno = e;

View File

@ -58,7 +58,7 @@ static int fastcgi_handler_1(client_ctx_t *ctx, fastcgi_cnx_t **fcgi_cnx) {
} }
fastcgi_cnx_t fcgi_cnx_buf; fastcgi_cnx_t fcgi_cnx_buf;
sock_init(&fcgi_cnx_buf.socket, 0, 0); sock_init(&fcgi_cnx_buf.socket, -1, 0);
fcgi_cnx_buf.req_id = 0; fcgi_cnx_buf.req_id = 0;
fcgi_cnx_buf.r_addr = ctx->socket.addr; fcgi_cnx_buf.r_addr = ctx->socket.addr;
fcgi_cnx_buf.r_host = (ctx->host[0] != 0) ? ctx->host : NULL; fcgi_cnx_buf.r_host = (ctx->host[0] != 0) ? ctx->host : NULL;