summaryrefslogtreecommitdiff
path: root/source3/lib/tldap.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-06-28 15:29:38 +0200
committerVolker Lendecke <vl@samba.org>2009-06-28 15:51:02 +0200
commit344dbced50dda7ad788b2e1908896ae926ae471a (patch)
tree9a49e6c5d855ff4a81065bcef11faf5560b6ebd3 /source3/lib/tldap.c
parentc594d21fdaea3fcee11afddc4f0d3e8c065db815 (diff)
downloadsamba-344dbced50dda7ad788b2e1908896ae926ae471a.tar.gz
samba-344dbced50dda7ad788b2e1908896ae926ae471a.tar.bz2
samba-344dbced50dda7ad788b2e1908896ae926ae471a.zip
If the connection is down, don't try another write.
Diffstat (limited to 'source3/lib/tldap.c')
-rw-r--r--source3/lib/tldap.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index cbd9648007..451bc18d2e 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -55,6 +55,7 @@ struct tldap_context {
int ld_sizelimit;
int ld_timelimit;
struct tstream_context *conn;
+ bool server_down;
int msgid;
struct tevent_queue *outgoing;
struct tevent_req **pending;
@@ -153,6 +154,14 @@ struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd)
return ctx;
}
+bool tldap_connection_ok(struct tldap_context *ld)
+{
+ if (ld == NULL) {
+ return false;
+ }
+ return !ld->server_down;
+}
+
static struct tldap_ctx_attribute *tldap_context_findattr(
struct tldap_context *ld, const char *name)
{
@@ -395,6 +404,11 @@ static struct tevent_req *tldap_msg_send(TALLOC_CTX *mem_ctx,
state->ev = ev;
state->id = id;
+ if (state->ld->server_down) {
+ tevent_req_error(req, TLDAP_SERVER_DOWN);
+ return tevent_req_post(req, ev);
+ }
+
tldap_push_controls(data, sctrls, num_sctrls);
asn1_pop_tag(data);
@@ -507,12 +521,15 @@ static void tldap_msg_sent(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
+ struct tldap_msg_state *state = tevent_req_data(
+ req, struct tldap_msg_state);
ssize_t nwritten;
int err;
nwritten = tstream_writev_queue_recv(subreq, &err);
TALLOC_FREE(subreq);
if (nwritten == -1) {
+ state->ld->server_down = true;
tevent_req_error(req, TLDAP_SERVER_DOWN);
return;
}