* 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.
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");
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");
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);
}
}
#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);
* 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.
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)
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);
}