summaryrefslogtreecommitdiffstats
path: root/server/providers/krb5
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2009-11-10 11:31:29 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-11-10 09:33:57 -0500
commit64a2f4205f6ebac24429cef730ef2a636636b0ff (patch)
tree97018fdc18b06d4fbda6e977bd8baa91a3b8d835 /server/providers/krb5
parent64351061595d3b954121d59bc394350ec6cf8ab4 (diff)
downloadsssd-64a2f4205f6ebac24429cef730ef2a636636b0ff.tar.gz
sssd-64a2f4205f6ebac24429cef730ef2a636636b0ff.tar.xz
sssd-64a2f4205f6ebac24429cef730ef2a636636b0ff.zip
Simplify krb5 child handler
Currently the Kerberos child handler evaluates the siginfo_t structure to wait for a specific child. This scheme is prone to error, especially when there are more than one child process active, and can produce missleading debug message. This patch simplifies the scheme as it waits for any child.
Diffstat (limited to 'server/providers/krb5')
-rw-r--r--server/providers/krb5/krb5_auth.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/server/providers/krb5/krb5_auth.c b/server/providers/krb5/krb5_auth.c
index cc5bc20d7..a02147e45 100644
--- a/server/providers/krb5/krb5_auth.c
+++ b/server/providers/krb5/krb5_auth.c
@@ -307,26 +307,27 @@ void krb5_child_sig_handler(struct tevent_context *ev,
{
int ret;
int child_status;
- siginfo_t *siginfo = (siginfo_t *)__siginfo;
- errno = 0;
+ DEBUG(7, ("Waiting for [%d] childeren.\n", count));
do {
- ret = waitpid(siginfo->si_pid, &child_status, WNOHANG);
- } while (ret == -1 && errno == EINTR);
- if (ret == siginfo->si_pid) {
- DEBUG(4, ("child status [%d].\n", child_status));
- if (WEXITSTATUS(child_status) != 0) {
- DEBUG(1, ("child failed.\n"));
+ errno = 0;
+ ret = waitpid(-1, &child_status, WNOHANG);
+
+ if (ret == -1) {
+ DEBUG(1, ("waitpid failed [%d][%s].\n", errno, strerror(errno)));
+ } else if (ret == 0) {
+ DEBUG(1, ("waitpid did not found a child with changed status.\n"));
+ } else {
+ if (WEXITSTATUS(child_status) != 0) {
+ DEBUG(1, ("child [%d] failed with status [%d].\n", ret,
+ child_status));
+ } else {
+ DEBUG(4, ("child [%d] finished successful.\n", ret));
+ }
}
- } else if (ret == 0) {
- DEBUG(1, ("waitpid did not found a child with changed status.\n", ret));
- } else if (ret >= 0 && ret != siginfo->si_pid) {
- DEBUG(1, ("waitpid returned wrong child pid [%d], continue waiting.\n", ret));
- } else if (ret == -1 && errno == ECHILD) {
- DEBUG(1, ("no child with pid [%d].\n", siginfo->si_pid));
- } else {
- DEBUG(1, ("waitpid failed [%s].\n", strerror(errno)));
- }
+
+ --count;
+ } while (count < 0);
return;
}