mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
If the connection is down, don't try another write.
This commit is contained in:
parent
c594d21fda
commit
344dbced50
@ -48,6 +48,7 @@ struct tldap_mod {
|
||||
bool tevent_req_is_ldap_error(struct tevent_req *req, int *perr);
|
||||
|
||||
struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd);
|
||||
bool tldap_connection_ok(struct tldap_context *ld);
|
||||
bool tldap_context_setattr(struct tldap_context *ld,
|
||||
const char *name, const void *pptr);
|
||||
void *tldap_context_getattr(struct tldap_context *ld, const char *name);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user