diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-03-08 18:06:42 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-03-09 10:53:47 -0400 |
commit | 984070b03417b64dce968b8c9074a3cf187b3fa7 (patch) | |
tree | 4168a8bcba932e8a8a5d386a7d28dbad6e5826b4 /server/infopipe/infopipe_groups.c | |
parent | ea4f00deaa457f8d8262528cf628691ced497c2e (diff) | |
download | sssd-984070b03417b64dce968b8c9074a3cf187b3fa7.tar.gz sssd-984070b03417b64dce968b8c9074a3cf187b3fa7.tar.xz sssd-984070b03417b64dce968b8c9074a3cf187b3fa7.zip |
Improve error handling and replies in the InfoPipe
When detecting an internal error in the InfoPipe, make a best-
attempt at sending an error message back to the calling program,
instead of simply leaving the client to wait for the timeout.
Diffstat (limited to 'server/infopipe/infopipe_groups.c')
-rw-r--r-- | server/infopipe/infopipe_groups.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/server/infopipe/infopipe_groups.c b/server/infopipe/infopipe_groups.c index 9aaecf2f2..4b2c881c2 100644 --- a/server/infopipe/infopipe_groups.c +++ b/server/infopipe/infopipe_groups.c @@ -59,9 +59,12 @@ static void infp_do_group_create_callback(void *pvt, int status, reply = dbus_message_new_error(grcreate_req->infp_req->req_message, DBUS_ERROR_FILE_EXISTS, error_msg); + if (reply) + sbus_conn_send_reply(grcreate_req->infp_req->sconn, reply); + } + else { + infp_return_failure(grcreate_req->infp_req, NULL); } - if (reply) - sbus_conn_send_reply(grcreate_req->infp_req->sconn, reply); talloc_free(grcreate_req); return; } @@ -75,9 +78,8 @@ static void infp_do_group_create_callback(void *pvt, int status, /* We have no more usernames to add, so commit the transaction */ sysdb_transaction_done(grcreate_req->sysdb_req, status); - reply = - dbus_message_new_method_return(grcreate_req->infp_req->req_message); - if (reply) sbus_conn_send_reply(grcreate_req->infp_req->sconn, reply); + + infp_return_success(grcreate_req->infp_req); talloc_free(grcreate_req); return; } @@ -97,6 +99,7 @@ static void infp_do_group_create(struct sysdb_req *req, void *pvt) if (ret != EOK) { DEBUG(0, ("Could not invoke sysdb_add_group\n")); sysdb_transaction_done(grcreate_req->sysdb_req, ret); + infp_return_failure(grcreate_req->infp_req, NULL); talloc_free(grcreate_req); return; } @@ -221,6 +224,7 @@ einval: error: if (arg_grnames) dbus_free_string_array(arg_grnames); + if(grcreate_req) infp_return_failure(grcreate_req->infp_req, NULL); talloc_free(grcreate_req); return ret; } @@ -234,7 +238,6 @@ struct infp_deletegroup_ctx { static void infp_do_group_delete_callback(void *pvt, int status, struct ldb_result *res) { - DBusMessage *reply = NULL; struct infp_deletegroup_ctx *grdel_req = talloc_get_type(pvt, struct infp_deletegroup_ctx); @@ -244,15 +247,12 @@ static void infp_do_group_delete_callback(void *pvt, int status, if (status != EOK) { DEBUG(0, ("Failed to delete group from sysdb. Error code %d\n", status)); + infp_return_failure(grdel_req->infp_req, NULL); talloc_free(grdel_req); return; } - reply = dbus_message_new_method_return(grdel_req->infp_req->req_message); - if (reply) { - sbus_conn_send_reply(grdel_req->infp_req->sconn, reply); - dbus_message_unref(reply); - } + infp_return_success(grdel_req->infp_req); talloc_free(grdel_req); } @@ -270,6 +270,7 @@ static void infp_do_group_delete(struct sysdb_req *req, void *pvt) grdel_req); if (ret != EOK) { DEBUG(0, ("Could not delete group entry\n")); + infp_return_failure(grdel_req->infp_req, NULL); talloc_free(grdel_req); return; } @@ -381,6 +382,7 @@ einval: return EOK; error: + if (grdel_req) infp_return_failure(grdel_req->infp_req, NULL); talloc_free(grdel_req); return ret; } @@ -437,11 +439,7 @@ static void infp_do_member_callback(void *pvt, int status, fail: sysdb_transaction_done(grmod_req->sysdb_req, status); fail_msg = talloc_asprintf(grmod_req, "Could not modify group"); - reply = dbus_message_new_error(grmod_req->infp_req->req_message, - DBUS_ERROR_FAILED, - fail_msg); - sbus_conn_send_reply(grmod_req->infp_req->sconn, reply); - dbus_message_unref(reply); + infp_return_failure(grmod_req->infp_req, fail_msg); talloc_free(grmod_req); return; } @@ -492,6 +490,7 @@ static void infp_do_member(struct sysdb_req *req, void *pvt) return; error: + infp_return_failure(grmod_req->infp_req, NULL); talloc_free(grmod_req); return; } @@ -722,6 +721,7 @@ static void infp_do_gid(struct sysdb_req *req, void *pvt) error_msg); if (reply) sbus_conn_send_reply(grmod_req->infp_req->sconn, reply); } + infp_return_failure(grmod_req->infp_req, NULL); talloc_free(grmod_req); return; } @@ -831,8 +831,7 @@ einval: return EOK; error: + if(grmod_req) infp_return_failure(grmod_req->infp_req, NULL); talloc_free(grmod_req); return ret; - - } |