Changeset View
Changeset View
Standalone View
Standalone View
b/dirmngr/ldap-wrapper.c
| Context not available. | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* Cleanup a process with the given pid. If the pid is -1 it is ignored | |||||
| otherwise the process will be killed released and waited on. */ | |||||
| static void | |||||
| destroy_process (pid_t pid) | |||||
| { | |||||
| gpg_error_t err; | |||||
| int status; | |||||
| if (pid == (pid_t)(-1)) | |||||
| return; | |||||
| gnupg_kill_process (pid); | |||||
| gnupg_release_process (pid); | |||||
| err = gnupg_wait_process ("[dirmngr_ldap]", pid, 0, &status); | |||||
| if (!err) | |||||
| return; | |||||
| if (gpg_err_code (err) == GPG_ERR_TIMEOUT) | |||||
| log_debug ("ldap wrapper %d still running.", pid); | |||||
| else if (gpg_err_code (err) == GPG_ERR_GENERAL) | |||||
| log_debug ("ldap wrapper %d exited with error: %d", pid, status); | |||||
| else | |||||
| log_debug ("ldap wrapper %d wait returned error: %s", pid, | |||||
| gpg_strerror (err)); | |||||
| } | |||||
| /* Release the wrapper context and kill a running wrapper process. */ | /* Release the wrapper context and kill a running wrapper process. */ | ||||
| static void | static void | ||||
| destroy_wrapper (struct wrapper_context_s *ctx) | destroy_wrapper (struct wrapper_context_s *ctx) | ||||
| { | { | ||||
| if (ctx->pid != (pid_t)(-1)) | destroy_process (ctx->pid); | ||||
| { | |||||
| gnupg_kill_process (ctx->pid); | |||||
| gnupg_release_process (ctx->pid); | |||||
| } | |||||
| ksba_reader_release (ctx->reader); | ksba_reader_release (ctx->reader); | ||||
| SAFE_CLOSE (ctx->fd); | SAFE_CLOSE (ctx->fd); | ||||
| SAFE_CLOSE (ctx->log_fd); | SAFE_CLOSE (ctx->log_fd); | ||||
| Context not available. | |||||
| if (ctx->pid != (pid_t)(-1) | if (ctx->pid != (pid_t)(-1) | ||||
| && ctx->stamp != (time_t)(-1) && ctx->stamp < exptime) | && ctx->stamp != (time_t)(-1) && ctx->stamp < exptime) | ||||
| { | { | ||||
| gnupg_kill_process (ctx->pid); | destroy_process (ctx->pid); | ||||
| ctx->stamp = (time_t)(-1); | ctx->stamp = (time_t)(-1); | ||||
| log_info (_("ldap wrapper %d stalled - killing\n"), | log_info (_("ldap wrapper %d stalled - killing\n"), | ||||
| (int)ctx->pid); | (int)ctx->pid); | ||||
| Context not available. | |||||
| if (ctx->fd_error) | if (ctx->fd_error) | ||||
| log_info (_("reading from ldap wrapper %d failed: %s\n"), | log_info (_("reading from ldap wrapper %d failed: %s\n"), | ||||
| ctx->printable_pid, gpg_strerror (ctx->fd_error)); | ctx->printable_pid, gpg_strerror (ctx->fd_error)); | ||||
| destroy_process (ctx->pid); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| for (ctx=wrapper_list; ctx; ctx=ctx->next) | for (ctx=wrapper_list; ctx; ctx=ctx->next) | ||||
| if (ctx->ctrl && ctx->ctrl == ctrl) | if (ctx->ctrl && ctx->ctrl == ctrl) | ||||
| { | { | ||||
| destroy_process (ctx->pid); | |||||
| ctx->ctrl->refcount--; | ctx->ctrl->refcount--; | ||||
| ctx->ctrl = NULL; | ctx->ctrl = NULL; | ||||
| if (ctx->pid != (pid_t)(-1)) | |||||
| gnupg_kill_process (ctx->pid); | |||||
| if (ctx->fd_error) | if (ctx->fd_error) | ||||
| log_info (_("reading from ldap wrapper %d failed: %s\n"), | log_info (_("reading from ldap wrapper %d failed: %s\n"), | ||||
| ctx->printable_pid, gpg_strerror (ctx->fd_error)); | ctx->printable_pid, gpg_strerror (ctx->fd_error)); | ||||
| Context not available. | |||||
| log_error (_("error initializing reader object: %s\n"), | log_error (_("error initializing reader object: %s\n"), | ||||
| gpg_strerror (err)); | gpg_strerror (err)); | ||||
| destroy_wrapper (ctx); | destroy_wrapper (ctx); | ||||
| destroy_process (ctx->pid); | |||||
| ksba_reader_release (*reader); | ksba_reader_release (*reader); | ||||
| *reader = NULL; | *reader = NULL; | ||||
| return err; | return err; | ||||
| Context not available. | |||||