--- a/src/server/safs/cgi.c Thu Jan 26 17:23:11 2017 +0100 +++ b/src/server/safs/cgi.c Thu Jan 26 18:53:52 2017 +0100 @@ -32,10 +32,6 @@ #include <stdlib.h> #include <unistd.h> -#include <sys/types.h> -#include <signal.h> -#include <sys/wait.h> - #include "../util/util.h" #include "../util/pblock.h" #include "../../ucx/string.h" @@ -103,22 +99,11 @@ while(n < content_length) { r = netbuf_getbytes(sn->inbuf, buf, 4096); if(r <= 0) { - // TODO: handle error - log_ereport(LOG_FAILURE, "send-cgi: Cannot read request body"); - kill(cgip.pid, SIGTERM); + // TODO: handleerror cgi_close(&cgip); - return REQ_ABORTED; + return REQ_ABORTED; } - ssize_t w = write(cgip.in[1], buf, r); - if(w <= 0) { - // TODO: handle error - log_ereport( - LOG_FAILURE, - "send-cgi: Cannot send request body to cgi process"); - kill(cgip.pid, SIGTERM); - cgi_close(&cgip); - return REQ_ABORTED; - } + write(cgip.in[1], buf, r); n += r; } } @@ -135,12 +120,11 @@ size_t pos; ret = cgi_parse_response(parser, buf, r, &pos); if(ret == -1) { - log_ereport( - LOG_FAILURE, - "broken cgi script response: path: %s", path); protocol_status(sn, rq, 500, NULL); result = REQ_ABORTED; break; + } else if(ret == 0) { + } else if(ret == 1) { cgiheader = FALSE; if(parser->status > 0) { @@ -164,7 +148,7 @@ } } - cgi_close(&cgip); // TODO: check return value + cgi_close(&cgip); cgi_parser_free(parser); return result; @@ -225,10 +209,7 @@ return REQ_PROCEED; } -int cgi_close(CGIProcess *p) { - int status = -1; - waitpid(p->pid, &status, 0); - +void cgi_close(CGIProcess *p) { if(p->in[0] != -1) { close(p->in[0]); } @@ -241,8 +222,6 @@ if(p->out[1] != -1) { close(p->out[1]); } - - return 0; } CGIResponseParser* cgi_parser_new(Session *sn, Request *rq) {