summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/IO/http.c10
-rw-r--r--src/chain.c22
-rw-r--r--src/chain.h1
3 files changed, 26 insertions, 7 deletions
diff --git a/src/IO/http.c b/src/IO/http.c
index 32f370b3..c8562fbf 100644
--- a/src/IO/http.c
+++ b/src/IO/http.c
@@ -473,8 +473,7 @@ void a_Http_dns_cb(int Status, Dlist *addr_list, void *data)
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 @@ void a_Http_dns_cb(int Status, Dlist *addr_list, void *data)
/* 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 @@ void a_Http_dns_cb(int Status, Dlist *addr_list, void *data)
/* 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);
}
diff --git a/src/chain.c b/src/chain.c
index 04d97baa..d4098a2d 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -139,6 +139,28 @@ int a_Chain_bcb(int Op, ChainLink *Info, void *Data1, void *Data2)
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
diff --git a/src/chain.h b/src/chain.h
index b6b41bd4..fd86557c 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -69,6 +69,7 @@ ChainLink *a_Chain_link_new(ChainLink *AInfo, ChainFunction_t AFunc,
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);