changeset 1271:3e784a367043

Added a_Chain_bfcb() to the CCC API (fixed three bugs with it)
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 07 Aug 2009 18:27:48 -0400
parents aee7a2cccb71
children 83a462cf5d02
files src/IO/http.c src/chain.c src/chain.h
diffstat 3 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/IO/http.c	Thu Aug 06 18:05:39 2009 -0400
+++ b/src/IO/http.c	Fri Aug 07 18:27:48 2009 -0400
@@ -473,8 +473,7 @@
    S = a_Klist_get_data(ValidSocks, SKey);
    if (S) {
       if (!a_Web_valid(S->web)) {
-         a_Chain_bcb(OpAbort, S->Info, NULL, NULL);
-         a_Chain_fcb(OpAbort, S->Info, NULL, NULL);
+         a_Chain_bfcb(OpAbort, S->Info, NULL, "Both");
          dFree(S->Info);
          Http_socket_free(SKey);
 
@@ -484,8 +483,7 @@
          /* start connecting the socket */
          if (Http_connect_socket(S->Info) < 0) {
             MSG_BW(S->web, 1, "ERROR: %s", dStrerror(S->Err));
-            a_Chain_bcb(OpAbort, S->Info, NULL, NULL);
-            a_Chain_fcb(OpAbort, S->Info, NULL, NULL);
+            a_Chain_bfcb(OpAbort, S->Info, NULL, "Both");
             dFree(S->Info);
             Http_socket_free(SKey);
          }
@@ -494,9 +492,7 @@
          /* DNS wasn't able to resolve the hostname */
          MSG_BW(S->web, 0, "ERROR: Dns can't resolve %s",
             (S->use_proxy) ? URL_HOST_(HTTP_Proxy) : URL_HOST_(S->web->url));
-         a_Chain_bcb(OpAbort, S->Info, NULL, NULL);
-         S->Info->Flags &= ~CCC_Aborted;
-         a_Chain_fcb(OpAbort, S->Info, NULL, "Both");
+         a_Chain_bfcb(OpAbort, S->Info, NULL, "Both");
          dFree(S->Info);
          Http_socket_free(SKey);
       }
--- a/src/chain.c	Thu Aug 06 18:05:39 2009 -0400
+++ b/src/chain.c	Fri Aug 07 18:27:48 2009 -0400
@@ -139,6 +139,28 @@
    return ret;
 }
 
+/*
+ * Issue the backward callback of the 'Info' link and then the
+ * forward callback (used for OpAbort and OpStop).
+ * Return value: 1 if OK, 0 if not operative.
+ */
+int a_Chain_bfcb(int Op, ChainLink *Info, void *Data1, void *Data2)
+{
+   int ret;
+
+   ret = a_Chain_bcb(Op, Info, Data1, Data2);
+   if (ret == 1) {
+      /* we need to clear the flag to reuse this 'Info' ChainLink */
+      if (Op == OpEnd)
+         Info->Flags &= ~CCC_Ended;
+      else if (Op == OpAbort)
+         Info->Flags &= ~CCC_Aborted;
+
+      ret = a_Chain_fcb(Op, Info, Data1, Data2);
+   }
+   return ret;
+}
+
 
 /*
  * Allocate and initialize a new DataBuf structure
--- a/src/chain.h	Thu Aug 06 18:05:39 2009 -0400
+++ b/src/chain.h	Fri Aug 07 18:27:48 2009 -0400
@@ -69,6 +69,7 @@
 void a_Chain_unlink(ChainLink *Info, int Direction);
 int a_Chain_fcb(int Op, ChainLink *Info, void *Data1, void *Data2);
 int a_Chain_bcb(int Op, ChainLink *Info, void *Data1, void *Data2);
+int a_Chain_bfcb(int Op, ChainLink *Info, void *Data1, void *Data2);
 int a_Chain_check(char *FuncStr, int Op, int Branch, int Dir,
                   ChainLink *Info);