summaryrefslogtreecommitdiff
path: root/server/responder
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-07-31 09:52:14 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-08-10 09:42:18 -0400
commit2b0f40eaba44742fa38bb5b67ada510e7b2b6324 (patch)
tree10317ab1e5428020e0363c45a3e943141a14e519 /server/responder
parent508b5b2a360c9530c6ea67a7b7ed6d61559846e4 (diff)
downloadsssd-2b0f40eaba44742fa38bb5b67ada510e7b2b6324.tar.gz
sssd-2b0f40eaba44742fa38bb5b67ada510e7b2b6324.tar.bz2
sssd-2b0f40eaba44742fa38bb5b67ada510e7b2b6324.zip
Remove redundant memory contexts
Simplify code by removing stuff that is never used or redundant.
Diffstat (limited to 'server/responder')
-rw-r--r--server/responder/common/responder.h5
-rw-r--r--server/responder/common/responder_common.c25
-rw-r--r--server/responder/common/responder_dp.c20
-rw-r--r--server/responder/nss/nsssrv.c6
-rw-r--r--server/responder/pam/pamsrv.c6
-rw-r--r--server/responder/pam/pamsrv_dp.c4
6 files changed, 36 insertions, 30 deletions
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h
index d901704a..408ee4da 100644
--- a/server/responder/common/responder.h
+++ b/server/responder/common/responder.h
@@ -63,8 +63,9 @@ struct resp_ctx {
struct confdb_ctx *cdb;
const char *sock_name;
const char *priv_sock_name;
- struct service_sbus_ctx *ss_ctx;
- struct service_sbus_ctx *dp_ctx;
+
+ struct sbus_conn_ctx *conn_ctx;
+ struct sbus_method_ctx *sm_ctx;
struct sss_domain_info *domains;
diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c
index 825d77e7..f8744b67 100644
--- a/server/responder/common/responder_common.c
+++ b/server/responder/common/responder_common.c
@@ -287,10 +287,8 @@ static void accept_fd_handler(struct tevent_context *ev,
static int sss_sbus_init(struct resp_ctx *rctx)
{
- int ret;
char *sbus_address;
- struct service_sbus_ctx *ss_ctx;
- struct sbus_method_ctx *sm_ctx;
+ int ret;
/* Set up SBUS connection to the monitor */
ret = monitor_get_sbus_address(rctx, rctx->cdb, &sbus_address);
@@ -299,17 +297,22 @@ static int sss_sbus_init(struct resp_ctx *rctx)
return ret;
}
- ret = monitor_init_sbus_methods(rctx, rctx->sss_sbus_methods, &sm_ctx);
+ ret = monitor_init_sbus_methods(rctx, rctx->sss_sbus_methods,
+ &rctx->sm_ctx);
if (ret != EOK) {
DEBUG(0, ("Could not initialize SBUS methods.\n"));
return ret;
}
- ret = sbus_client_init(rctx, rctx->ev,
- sbus_address, sm_ctx,
- NULL /* Private Data */,
- NULL /* Destructor */,
- &ss_ctx);
+ /* FIXME: remove this */
+ if (talloc_reference(rctx, rctx->sm_ctx) == NULL) {
+ DEBUG(0, ("Failed to take memory reference\n"));
+ return ENOMEM;
+ }
+
+ ret = sbus_client_init(rctx, rctx->ev, rctx->sm_ctx,
+ sbus_address, &rctx->conn_ctx,
+ NULL, NULL);
if (ret != EOK) {
DEBUG(0, ("Failed to connect to monitor services.\n"));
return ret;
@@ -318,8 +321,6 @@ static int sss_sbus_init(struct resp_ctx *rctx)
/* Set up NSS-specific listeners */
/* None currently used */
- rctx->ss_ctx = ss_ctx;
-
return EOK;
}
@@ -496,7 +497,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx,
DEBUG(0, ("fatal error setting up backend connector\n"));
return ret;
}
- else if (!rctx->dp_ctx) {
+ else if (!rctx->conn_ctx) {
DEBUG(0, ("Data Provider is not yet available. Retrying.\n"));
return EIO;
}
diff --git a/server/responder/common/responder_dp.c b/server/responder/common/responder_dp.c
index bfc533b9..9083a173 100644
--- a/server/responder/common/responder_dp.c
+++ b/server/responder/common/responder_dp.c
@@ -25,7 +25,6 @@ static void sss_dp_conn_reconnect(struct sss_dp_pvt_ctx *pvt)
struct resp_ctx *rctx;
struct tevent_timer *te;
struct timeval tv;
- struct sbus_method_ctx *sm_ctx;
char *sbus_address;
time_t now;
int ret;
@@ -50,16 +49,21 @@ static void sss_dp_conn_reconnect(struct sss_dp_pvt_ctx *pvt)
return;
}
- ret = dp_init_sbus_methods(rctx, pvt->methods, &sm_ctx);
+ ret = dp_init_sbus_methods(rctx, pvt->methods, &rctx->sm_ctx);
if (ret != EOK) {
DEBUG(0, ("Could not initialize SBUS methods.\n"));
return;
}
- ret = sbus_client_init(rctx, rctx->ev,
- sbus_address, sm_ctx,
- pvt, sss_dp_conn_destructor,
- &rctx->dp_ctx);
+ /* FIXME: remove this */
+ if (talloc_reference(rctx, rctx->sm_ctx) == NULL) {
+ DEBUG(0, ("Failed to take memory reference\n"));
+ return;
+ }
+
+ ret = sbus_client_init(rctx, rctx->ev, rctx->sm_ctx,
+ sbus_address, &rctx->conn_ctx,
+ sss_dp_conn_destructor, pvt);
if (ret != EOK) {
DEBUG(4, ("Failed to reconnect [%d(%s)]!\n", ret, strerror(ret)));
@@ -239,12 +243,12 @@ int nss_dp_send_acct_req(struct resp_ctx *rctx, TALLOC_CTX *memctx,
* in some pathological cases it may happen that nss starts up before
* dp connection code is actually able to establish a connection.
*/
- if (!rctx->dp_ctx) {
+ if (!rctx->conn_ctx) {
DEBUG(1, ("The Data Provider connection is not available yet!"
" This maybe a bug, it shouldn't happen!\n"));
return EIO;
}
- conn = sbus_get_connection(rctx->dp_ctx->scon_ctx);
+ conn = sbus_get_connection(rctx->conn_ctx);
/* create the message */
msg = dbus_message_new_method_call(NULL,
diff --git a/server/responder/nss/nsssrv.c b/server/responder/nss/nsssrv.c
index 9a3d3c45..419ed1de 100644
--- a/server/responder/nss/nsssrv.c
+++ b/server/responder/nss/nsssrv.c
@@ -258,8 +258,8 @@ static void nss_dp_reconnect_init(struct sbus_conn_ctx *sconn, int status, void
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
/* Add the methods back to the new connection */
- ret = sbus_conn_add_method_ctx(rctx->dp_ctx->scon_ctx,
- rctx->dp_ctx->sm_ctx);
+ ret = sbus_conn_add_method_ctx(rctx->conn_ctx,
+ rctx->sm_ctx);
if (ret != EOK) {
DEBUG(0, ("Could not re-add methods on reconnection.\n"));
nss_shutdown(rctx);
@@ -327,7 +327,7 @@ int nss_process_init(TALLOC_CTX *mem_ctx,
return ret;
}
- sbus_reconnect_init(nctx->rctx->dp_ctx->scon_ctx,
+ sbus_reconnect_init(nctx->rctx->conn_ctx,
max_retries,
nss_dp_reconnect_init, nctx->rctx);
diff --git a/server/responder/pam/pamsrv.c b/server/responder/pam/pamsrv.c
index ef01e972..05e3a12d 100644
--- a/server/responder/pam/pamsrv.c
+++ b/server/responder/pam/pamsrv.c
@@ -148,8 +148,8 @@ static void pam_dp_reconnect_init(struct sbus_conn_ctx *sconn, int status, void
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
/* Add the methods back to the new connection */
- ret = sbus_conn_add_method_ctx(rctx->dp_ctx->scon_ctx,
- rctx->dp_ctx->sm_ctx);
+ ret = sbus_conn_add_method_ctx(rctx->conn_ctx,
+ rctx->sm_ctx);
if (ret != EOK) {
DEBUG(0, ("Could not re-add methods on reconnection.\n"));
pam_shutdown(rctx);
@@ -190,7 +190,7 @@ static int pam_process_init(struct main_context *main_ctx,
return ret;
}
- sbus_reconnect_init(rctx->dp_ctx->scon_ctx, max_retries,
+ sbus_reconnect_init(rctx->conn_ctx, max_retries,
pam_dp_reconnect_init, rctx);
return EOK;
diff --git a/server/responder/pam/pamsrv_dp.c b/server/responder/pam/pamsrv_dp.c
index 1de43478..9703fdbb 100644
--- a/server/responder/pam/pamsrv_dp.c
+++ b/server/responder/pam/pamsrv_dp.c
@@ -92,12 +92,12 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout)
* in some pathological cases it may happen that nss starts up before
* dp connection code is actually able to establish a connection.
*/
- if (!preq->cctx->rctx->dp_ctx) {
+ if (!preq->cctx->rctx->conn_ctx) {
DEBUG(1, ("The Data Provider connection is not available yet!"
" This maybe a bug, it shouldn't happen!\n"));
return EIO;
}
- conn = sbus_get_connection(preq->cctx->rctx->dp_ctx->scon_ctx);
+ conn = sbus_get_connection(preq->cctx->rctx->conn_ctx);
msg = dbus_message_new_method_call(NULL,
DP_CLI_PATH,