[SSSD] [PATCH 2/5] Fix ipa_subdomain_id names and tevent_req style

Simo Sorce simo at redhat.com
Wed Nov 7 20:59:05 UTC 2012


---
 src/providers/ipa/ipa_id.c            |    5 +-
 src/providers/ipa/ipa_id.h            |   10 ++--
 src/providers/ipa/ipa_subdomains_id.c |   73 +++++++++++++--------------------
 3 files changed, 36 insertions(+), 52 deletions(-)

diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c
index 5f5286321dad3f98e619d8abb4f5fab6f0775de4..f61236b965b77ca1058a14cb7e425ac2ff65723e 100644
--- a/src/providers/ipa/ipa_id.c
+++ b/src/providers/ipa/ipa_id.c
@@ -84,8 +84,7 @@ void ipa_account_info_handler(struct be_req *breq)
                                      "Invalid sub-domain request type");
         }
 
-        req = ipa_get_subdomain_account_info_send(breq, breq->be_ctx->ev, ctx,
-                                                  ar);
+        req = ipa_get_subdom_acct_send(breq, breq->be_ctx->ev, ctx, ar);
         if (!req) {
             return sdap_handler_done(breq, DP_ERR_FATAL, ENOMEM, "Out of memory");
         }
@@ -154,7 +153,7 @@ static void ipa_account_info_users_done(struct tevent_req *req)
     struct be_req *breq = tevent_req_callback_data(req, struct be_req);
     int ret, dp_error;
 
-    ret = ipa_user_get_recv(req, &dp_error);
+    ret = ipa_get_subdom_acct_recv(req, &dp_error);
     talloc_zfree(req);
 
     ipa_account_info_complete(breq, dp_error, ret, "User lookup failed");
diff --git a/src/providers/ipa/ipa_id.h b/src/providers/ipa/ipa_id.h
index c264286f07dd940c280c12ed00625db611caaf2c..82f2f489d0dc29235018cfee1f9488f3f25d9b74 100644
--- a/src/providers/ipa/ipa_id.h
+++ b/src/providers/ipa/ipa_id.h
@@ -60,9 +60,9 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx,
                                               uid_t uid);
 int ipa_s2n_get_acct_info_recv(struct tevent_req *req);
 
-struct tevent_req *ipa_get_subdomain_account_info_send(TALLOC_CTX *memctx,
-                                                      struct tevent_context *ev,
-                                                      struct sdap_id_ctx *ctx,
-                                                      struct be_acct_req *ar);
-int ipa_user_get_recv(struct tevent_req *req, int *dp_error_out);
+struct tevent_req *ipa_get_subdom_acct_send(TALLOC_CTX *memctx,
+                                            struct tevent_context *ev,
+                                            struct sdap_id_ctx *ctx,
+                                            struct be_acct_req *ar);
+int ipa_get_subdom_acct_recv(struct tevent_req *req, int *dp_error_out);
 #endif
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
index 5a4ab40b214efaf9a538cd0fd1c4a263eff6eb41..cf0d994d948912358bd9df1039332e2c78827158 100644
--- a/src/providers/ipa/ipa_subdomains_id.c
+++ b/src/providers/ipa/ipa_subdomains_id.c
@@ -32,7 +32,7 @@
 #include "providers/ipa/ipa_id.h"
 #include "providers/ipa/ipa_subdomains.h"
 
-struct ipa_user_get_state {
+struct ipa_get_subdom_acct {
     struct tevent_context *ev;
     struct sdap_id_ctx *ctx;
     struct sdap_id_op *op;
@@ -48,19 +48,20 @@ struct ipa_user_get_state {
     int dp_error;
 };
 
-static int ipa_get_subdomain_account_info_retry(struct tevent_req *req);
-static void ipa_get_subdomain_account_info_connect_done(struct tevent_req *subreq);
-static void ipa_get_subdomain_account_info_done(struct tevent_req *subreq);
-struct tevent_req *ipa_get_subdomain_account_info_send(TALLOC_CTX *memctx,
-                                                      struct tevent_context *ev,
-                                                      struct sdap_id_ctx *ctx,
-                                                      struct be_acct_req *ar)
+static void ipa_get_subdom_acct_connected(struct tevent_req *subreq);
+static void ipa_get_subdom_acct_done(struct tevent_req *subreq);
+
+struct tevent_req *ipa_get_subdom_acct_send(TALLOC_CTX *memctx,
+                                            struct tevent_context *ev,
+                                            struct sdap_id_ctx *ctx,
+                                            struct be_acct_req *ar)
 {
     struct tevent_req *req;
-    struct ipa_user_get_state *state;
+    struct ipa_get_subdom_acct *state;
+    struct tevent_req *subreq;
     int ret;
 
-    req = tevent_req_create(memctx, &state, struct ipa_user_get_state);
+    req = tevent_req_create(memctx, &state, struct ipa_get_subdom_acct);
     if (!req) return NULL;
 
     state->ev = ev;
@@ -105,10 +106,11 @@ struct tevent_req *ipa_get_subdomain_account_info_send(TALLOC_CTX *memctx,
     }
     if (ret != EOK) goto fail;
 
-    ret = ipa_get_subdomain_account_info_retry(req);
-    if (ret != EOK) {
+    subreq = sdap_id_op_connect_send(state->op, state, &ret);
+    if (!subreq) {
         goto fail;
     }
+    tevent_req_set_callback(subreq, ipa_get_subdom_acct_connected, req);
 
     return req;
 
@@ -118,29 +120,12 @@ fail:
     return req;
 }
 
-static int ipa_get_subdomain_account_info_retry(struct tevent_req *req)
-{
-    struct ipa_user_get_state *state = tevent_req_data(req,
-                                                    struct ipa_user_get_state);
-    struct tevent_req *subreq;
-    int ret = EOK;
-
-    subreq = sdap_id_op_connect_send(state->op, state, &ret);
-    if (!subreq) {
-        return ret;
-    }
-
-    tevent_req_set_callback(subreq, ipa_get_subdomain_account_info_connect_done,
-                            req);
-    return EOK;
-}
-
-static void ipa_get_subdomain_account_info_connect_done(struct tevent_req *subreq)
+static void ipa_get_subdom_acct_connected(struct tevent_req *subreq)
 {
     struct tevent_req *req = tevent_req_callback_data(subreq,
-                                                      struct tevent_req);
-    struct ipa_user_get_state *state = tevent_req_data(req,
-                                                     struct ipa_user_get_state);
+                                                struct tevent_req);
+    struct ipa_get_subdom_acct *state = tevent_req_data(req,
+                                                struct ipa_get_subdom_acct);
     int dp_error = DP_ERR_FATAL;
     int ret;
     const char *name;
@@ -187,17 +172,17 @@ static void ipa_get_subdomain_account_info_connect_done(struct tevent_req *subre
         tevent_req_error(req, ENOMEM);
         return;
     }
-    tevent_req_set_callback(subreq, ipa_get_subdomain_account_info_done, req);
+    tevent_req_set_callback(subreq, ipa_get_subdom_acct_done, req);
 
     return;
 }
 
-static void ipa_get_subdomain_account_info_done(struct tevent_req *subreq)
+static void ipa_get_subdom_acct_done(struct tevent_req *subreq)
 {
     struct tevent_req *req = tevent_req_callback_data(subreq,
-                                                      struct tevent_req);
-    struct ipa_user_get_state *state = tevent_req_data(req,
-                                                     struct ipa_user_get_state);
+                                                struct tevent_req);
+    struct ipa_get_subdom_acct *state = tevent_req_data(req,
+                                                struct ipa_get_subdom_acct);
     int dp_error = DP_ERR_FATAL;
     int ret;
 
@@ -207,12 +192,12 @@ static void ipa_get_subdomain_account_info_done(struct tevent_req *subreq)
     ret = sdap_id_op_done(state->op, ret, &dp_error);
     if (dp_error == DP_ERR_OK && ret != EOK) {
         /* retry */
-        ret = ipa_get_subdomain_account_info_retry(req);
-        if (ret != EOK) {
+        subreq = sdap_id_op_connect_send(state->op, state, &ret);
+        if (!subreq) {
             tevent_req_error(req, ret);
             return;
         }
-
+        tevent_req_set_callback(subreq, ipa_get_subdom_acct_connected, req);
         return;
     }
 
@@ -228,10 +213,10 @@ static void ipa_get_subdomain_account_info_done(struct tevent_req *subreq)
     tevent_req_done(req);
 }
 
-int ipa_user_get_recv(struct tevent_req *req, int *dp_error_out)
+int ipa_get_subdom_acct_recv(struct tevent_req *req, int *dp_error_out)
 {
-    struct ipa_user_get_state *state = tevent_req_data(req,
-                                                    struct ipa_user_get_state);
+    struct ipa_get_subdom_acct *state = tevent_req_data(req,
+                                                struct ipa_get_subdom_acct);
 
     if (dp_error_out) {
         *dp_error_out = state->dp_error;
-- 
1.7.1




More information about the sssd-devel mailing list