summaryrefslogtreecommitdiffstats
path: root/server/providers/data_provider_fo.c
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-12-10 22:23:04 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-12-15 08:33:55 -0500
commit796a6c947951a5a4459545b99bf97e0523f71402 (patch)
tree35725ab411fd405a0f4b781e183bd7ac6d35ba73 /server/providers/data_provider_fo.c
parentc48d88aa2fc016670c30ad0a426e7e86ff9090d7 (diff)
downloadsssd-796a6c947951a5a4459545b99bf97e0523f71402.tar.gz
sssd-796a6c947951a5a4459545b99bf97e0523f71402.tar.xz
sssd-796a6c947951a5a4459545b99bf97e0523f71402.zip
Don't consider one address with different port numbers as the same
There were two problems with the code. We were using fo_set_server_status() instead of fo_set_port_status() when we failed to connect to a service. This is a problem because if two services use the same server, or we want to use one server with two different ports, marking the whole server as bad is incorrect. The other problem was that be_resolve_server_done() was comparing the hostent structures -- these are, however, equal across multiple server:port pairs with the same server addresses. Fixes: #321
Diffstat (limited to 'server/providers/data_provider_fo.c')
-rw-r--r--server/providers/data_provider_fo.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/server/providers/data_provider_fo.c b/server/providers/data_provider_fo.c
index bc274cef8..23c857aa0 100644
--- a/server/providers/data_provider_fo.c
+++ b/server/providers/data_provider_fo.c
@@ -41,7 +41,7 @@ struct be_svc_data {
const char *name;
struct fo_service *fo_service;
- struct hostent *last_good_srvaddr;
+ struct fo_server *last_good_srv;
struct be_svc_callback *callbacks;
};
@@ -267,7 +267,6 @@ static void be_resolve_server_done(struct tevent_req *subreq)
struct be_resolve_server_state *state = tevent_req_data(req,
struct be_resolve_server_state);
struct be_svc_callback *callback;
- struct hostent *srvaddr;
int ret;
ret = fo_resolve_service_recv(subreq, &state->srv);
@@ -295,9 +294,6 @@ static void be_resolve_server_done(struct tevent_req *subreq)
DEBUG(6, ("Couldn't resolve server (%s), resolver returned (%d)\n",
fo_get_server_name(state->srv), ret));
- /* mark as bad server */
- fo_set_server_status(state->srv, SERVER_NOT_WORKING);
-
state->attempts++;
if (state->attempts >= 10) {
DEBUG(2, ("Failed to find a server after 10 attempts\n"));
@@ -320,10 +316,11 @@ static void be_resolve_server_done(struct tevent_req *subreq)
}
/* all fine we got the server */
- srvaddr = fo_get_server_hostent(state->srv);
if (debug_level >= 4) {
+ struct hostent *srvaddr;
char ipaddr[128];
+ srvaddr = fo_get_server_hostent(state->srv);
inet_ntop(srvaddr->h_addrtype, srvaddr->h_addr_list[0],
ipaddr, 128);
@@ -332,8 +329,8 @@ static void be_resolve_server_done(struct tevent_req *subreq)
}
/* now call all svc callbacks if server changed */
- if (srvaddr != state->svc->last_good_srvaddr) {
- state->svc->last_good_srvaddr = srvaddr;
+ if (state->srv != state->svc->last_good_srv) {
+ state->svc->last_good_srv = state->srv;
DLIST_FOR_EACH(callback, state->svc->callbacks) {
callback->fn(callback->private_data, state->srv);