Bug fix: shell (wproto) sometimes closed server FIFO before cgi
[egate.git] / www / wproto.c
index ece3be5..e27c99b 100644 (file)
  * 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);
        }