Closed slavak closed 3 years ago
You're right, ldap.timeout
isn't re-initialized and the connection hangs. Try this patch:
--- a/src/search.rs
+++ b/src/search.rs
@@ -663,6 +663,7 @@ where
}
self.ldap.op_call(LdapOp::Search(tx), req).await.map(|_| {
self.state = StreamState::Active;
+ self.ldap.timeout = self.timeout;
})
}
I'll have to re-analyze adapter chaining, but the purpose of setting self.ldap.timeout
to the initial value is to preserve that value for use by adapters. Using self.timeout
in next_inner()
may well be correct, regardless.
I went with using self.timeout
(the value from the stream instance) in next_inner()
, since it works as well.
Awesome, thank you!
The
with_timeout
method should cause the next operation to run with the specified timeout. When that operation is a call tosearch
this does not work as expected. Specifically, because internallysearch
is implemented as a wrapper aroundstreaming_search_with
, it seems only a part of the required operations are actually executed with the specified timeout.If I use iptables to DROP packets to the LDAP port before running the search operation, the search will block forever, despite being ostensibly run with a timeout.
The
stream.ldap.timeout
field gets reset toNone
by thetake
inLdap::op_call
(line 121 in ldap.rs), called fromSearchSteam::start_inner
, called fromSearchStream::start
. Then,SearchStream::next_inner
executes an operation using the timeout fromself.ldap.timeout
, which is nowNone
.I suspect the bug is that
SearchStream::next_inner
should be usingself.timeout
, and notself.ldap.timeout
, but I don't understand the code enough and would need some confirmation.