diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-10-26 18:48:55 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-10-28 16:00:59 -0400 |
commit | 5984e8ef15ff0888a11383fc655f8a700bc3e6fe (patch) | |
tree | e23458e0a1c848b5ec1aef1580a8359f48117a62 /server | |
parent | 6ff508c02836dc62c3a5218c498f24964aed4c7d (diff) | |
download | sssd-5984e8ef15ff0888a11383fc655f8a700bc3e6fe.tar.gz sssd-5984e8ef15ff0888a11383fc655f8a700bc3e6fe.tar.bz2 sssd-5984e8ef15ff0888a11383fc655f8a700bc3e6fe.zip |
Kill the ldap connection when we go offline
This patch uses a wrapper to kill the ldap connection when we are marked
offline. This also makes sure we do not try to reuse a bad connection handler
after a fatal error.
Diffstat (limited to 'server')
-rw-r--r-- | server/providers/ldap/ldap_id.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/server/providers/ldap/ldap_id.c b/server/providers/ldap/ldap_id.c index ecb87617..9fd0d4f1 100644 --- a/server/providers/ldap/ldap_id.c +++ b/server/providers/ldap/ldap_id.c @@ -73,6 +73,17 @@ static bool connected(struct sdap_id_ctx *ctx) return false; } +static void mark_offline(struct sdap_id_ctx *ctx) +{ + if (ctx->gsh) { + /* make sure we mark the connection as gone when we go offline so that + * we do not try to reuse a bad connection by mistale later */ + talloc_zfree(ctx->gsh); + } + + be_mark_offline(ctx->be); +} + /* =Users-Related-Functions-(by-name,by-uid)============================== */ struct users_get_state { @@ -233,7 +244,7 @@ static void users_get_done(struct tevent_req *req) if (ret == ETIMEDOUT || ret == EFAULT) { ctx = talloc_get_type(breq->be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx); - be_mark_offline(ctx->be); + mark_offline(ctx); } } @@ -400,7 +411,7 @@ static void groups_get_done(struct tevent_req *req) if (ret == ETIMEDOUT || ret == EFAULT) { ctx = talloc_get_type(breq->be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx); - be_mark_offline(ctx->be); + mark_offline(ctx); } } @@ -542,7 +553,7 @@ static void groups_by_user_done(struct tevent_req *req) if (ret == ETIMEDOUT || ret == EFAULT) { ctx = talloc_get_type(breq->be_ctx->bet_info[BET_ID].pvt_bet_data, struct sdap_id_ctx); - be_mark_offline(ctx->be); + mark_offline(ctx); } } @@ -809,7 +820,7 @@ fail: DEBUG(9, ("User enumeration failed with: (%d)[%s]\n", (int)err, strerror(err))); - be_mark_offline(state->ctx->be); + mark_offline(state->ctx); } DEBUG(1, ("Failed to enumerate users, retrying later!\n")); @@ -835,7 +846,7 @@ static void ldap_id_enum_groups_done(struct tevent_req *subreq) fail: /* always go offline on failures */ - be_mark_offline(state->ctx->be); + mark_offline(state->ctx); DEBUG(1, ("Failed to enumerate groups (%d [%s]), retrying later!\n", (int)err, strerror(err))); tevent_req_done(req); |