From: Adam Dickmeiss Date: Fri, 5 Jan 1996 16:21:20 +0000 (+0000) Subject: Bug fix: shell (wproto) sometimes closed server FIFO before cgi X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=ebbedbe0d49ac7cae8d511bf051eed59d9e14e50;p=egate.git Bug fix: shell (wproto) sometimes closed server FIFO before cgi program opened it - solution: cgi sends OK when response has been read. --- diff --git a/www/wcgi.c b/www/wcgi.c index 06b8ace..a94c5ff 100644 --- a/www/wcgi.c +++ b/www/wcgi.c @@ -41,7 +41,11 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wcgi.c,v $ - * Revision 1.9 1995/12/20 16:31:33 adam + * Revision 1.10 1996/01/05 16:21:20 adam + * Bug fix: shell (wproto) sometimes closed server FIFO before cgi + * program opened it - solution: cgi sends OK when response has been read. + * + * Revision 1.9 1995/12/20 16:31:33 adam * Bug fix: shell might terminate even though new request was initiated * by the cgi interface program. * Work on more simple user interface and Europagate buttons. @@ -299,10 +303,14 @@ int main() gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); fatal("Internal server error"); } - if (linein < 0 && (linein = open(serverp, O_RDONLY)) < 0) + if (linein < 0) { - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "open %s", serverp); - fatal("Internal error in server"); + gw_log (GW_LOG_DEBUG, prog, "open %s", serverp); + if ((linein = open(serverp, O_RDONLY)) < 0) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "open %s", serverp); + fatal("Internal error in server"); + } } gw_log (GW_LOG_DEBUG, prog, "Reading response"); @@ -310,6 +318,8 @@ int main() while ((data = read(linein, combuf, COMBUF)) > 0) { gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data); + if (combuf[data-1] == '\0') + break; if (write(1, combuf, data) < data) { gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); @@ -321,6 +331,15 @@ int main() gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "read"); exit (1); } + if (data > 0) + { + --data; + if (write(1, combuf, data) < data) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); + exit (1); + } + } #else # if 1 fcntl (linein, F_SETFL, O_NONBLOCK); @@ -394,6 +413,12 @@ int main() } } #endif + +#if 1 + gw_log (GW_LOG_DEBUG, prog, "writing ack"); + if (write(lineout, "OK", 2) < 2) + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); +#endif gw_log (GW_LOG_DEBUG, prog, "Cleaning up."); close(linein); unlink(serverp); diff --git a/www/wproto.c b/www/wproto.c index ece3be5..e27c99b 100644 --- a/www/wproto.c +++ b/www/wproto.c @@ -41,7 +41,11 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.c,v $ - * Revision 1.10 1995/12/22 14:21:16 adam + * Revision 1.11 1996/01/05 16:21:21 adam + * Bug fix: shell (wproto) sometimes closed server FIFO before cgi + * program opened it - solution: cgi sends OK when response has been read. + * + * Revision 1.10 1995/12/22 14:21:16 adam * More work on scan. The search.egw script takes care of cached * query page (doesn't always increment nextSetNo). To make new search set * either 'New query' must be selected or the query page must be reloaded. @@ -210,11 +214,19 @@ int wo_overflow(WCLIENT wc, char ch) int wo_finish(WCLIENT wc) { + char buf[4]; gw_log (GW_LOG_DEBUG, mod, "wo_finish"); - + wo_putc (wc, 0); if (wo_flush(wc) < 0) return -1; +#if 1 + gw_log (GW_LOG_DEBUG, mod, "reading ack"); + if (read(wc->linein, buf, 2) != 2) + { + gw_log (GW_LOG_DEBUG, mod, "read ack"); + } +#endif close(wc->lineout); wc->lineout = -1; if (wc->cache_fd >= 0) @@ -344,16 +356,21 @@ int wproto_process(WCLIENT wc, int timeout) p++; p++; /* we don't deal with envvars yet */ decode_form(wc->wf_data, p); - if (wc->lineout < 0 && (wc->lineout = open(wc->wf_serverp, O_WRONLY)) - < 0) - { - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "open %s", wc->wf_serverp); - exit(1); - } + if (wc->lineout < 0) + { + gw_log (GW_LOG_DEBUG, mod, "open %s", wc->wf_serverp); + if ((wc->lineout = open(wc->wf_serverp, O_WRONLY)) < 0) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "open %s", + wc->wf_serverp); + exit(1); + } + } /* look in cache only if request carries no forms data. */ if (!*wc->wf_data[0].name && (level = wproto_findcache(wc, wc->wf_parms)) >= 0) { + gw_log (GW_LOG_DEBUG, mod, "wproto_dumpcache"); wproto_dumpcache(wc, level); wo_finish(wc); }