View | Details | Raw Unified | Return to bug 11969
Collapse All | Expand All

(-)gnupg-2.0.10.orig/agent/command.c (+28 lines)
Lines 918-925 Link Here
918
  if (!strcmp (desc, "X"))
918
  if (!strcmp (desc, "X"))
919
    desc = NULL;
919
    desc = NULL;
920
920
921
retry:
921
  pw = cacheid ? agent_get_cache (cacheid, CACHE_MODE_NORMAL, &cache_marker)
922
  pw = cacheid ? agent_get_cache (cacheid, CACHE_MODE_NORMAL, &cache_marker)
922
               : NULL;
923
               : NULL;
924
  if (!pw)
925
        {
926
927
      /* If the pinentry is currently in use, we wait up to 60 seconds
928
         for it to close and check the cache again.  This solves a common
929
         situation where several requests for unprotecting a key have
930
         been made but the user is still entering the passphrase for
931
         the first request.  Because all requests to agent_askpin are
932
         serialized they would then pop up one after the other to
933
         request the passphrase - despite that the user has already
934
         entered it and is then available in the cache.  This
935
         implementation is not race free but in the worst case the
936
         user has to enter the passphrase only once more. */
937
      if (pinentry_active_p (ctrl, 0))
938
        {
939
          /* Active - wait */
940
          if (!pinentry_active_p (ctrl, 60))
941
            {
942
              /* We need to give the other thread a chance to actually put
943
                 it into the cache. */
944
              pth_sleep (1); 
945
              goto retry;
946
            }
947
          /* Timeout - better call pinentry now the plain way. */
948
        }
949
    }
950
923
  if (pw)
951
  if (pw)
924
    {
952
    {
925
      rc = send_back_passphrase (ctx, opt_data, pw);
953
      rc = send_back_passphrase (ctx, opt_data, pw);

Return to bug 11969