~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to agent/call-scd.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2009-03-08 22:46:47 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090308224647-gq17gatcl71lrc2k
Tags: 2.0.11-1
* New upstream release. (Closes: #496663)
* debian/control: Make the description a little more distinctive than
  gnupg v1's. Thanks Jari Aalto. (Closes: #496323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
static void
192
192
atfork_cb (void *opaque, int where)
193
193
{
 
194
  (void)opaque;
 
195
 
194
196
  if (!where)
195
197
    gcry_control (GCRYCTL_TERM_SECMEM);
196
198
}
343
345
  if (opt.verbose)
344
346
    log_debug ("first connection to SCdaemon established\n");
345
347
 
 
348
  if (DBG_ASSUAN)
 
349
    assuan_set_log_stream (ctx, log_get_stream ());
 
350
 
346
351
  /* Get the name of the additional socket opened by scdaemon. */
347
352
  {
348
353
    membuf_t data;
404
409
}
405
410
 
406
411
 
 
412
/* Check whether the SCdaemon is active.  This is a fast check without
 
413
   any locking and might give a wrong result if another thread is about
 
414
   to start the daemon or the daemon is about to be stopped.. */
 
415
int
 
416
agent_scd_check_running (void)
 
417
{
 
418
  return !!primary_scd_ctx;
 
419
}
 
420
 
 
421
 
407
422
/* Check whether the Scdaemon is still alive and clean it up if not. */
408
423
void
409
424
agent_scd_check_aliveness (void)
410
425
{
411
426
  pth_event_t evt;
412
427
  pid_t pid;
 
428
#ifdef HAVE_W32_SYSTEM
 
429
  DWORD rc;
 
430
#else
413
431
  int rc;
414
 
#ifdef HAVE_W32_SYSTEM
415
 
  DWORD dummyec;
416
432
#endif
417
433
 
418
434
  if (!primary_scd_ctx)
441
457
    {
442
458
      pid = assuan_get_pid (primary_scd_ctx);
443
459
#ifdef HAVE_W32_SYSTEM
 
460
      /* If we have a PID we disconnect if either GetExitProcessCode
 
461
         fails or if ir returns the exit code of the scdaemon.  259 is
 
462
         the error code for STILL_ALIVE.  */
444
463
      if (pid != (pid_t)(void*)(-1) && pid
445
 
          && !GetExitCodeProcess ((HANDLE)pid, &dummyec))
 
464
          && (!GetExitCodeProcess ((HANDLE)pid, &rc) || rc != 259))
446
465
#else
447
466
      if (pid != (pid_t)(-1) && pid
448
467
          && ((rc=waitpid (pid, NULL, WNOHANG))==-1 || (rc == pid)) )
701
720
 
702
721
 
703
722
 
704
 
static int
 
723
static assuan_error_t
705
724
membuf_data_cb (void *opaque, const void *buffer, size_t length)
706
725
{
707
726
  membuf_t *data = opaque;