[Pkg-gnupg-commit] [gnupg2] 221/292: common, w32: Simplify locking.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 7cbb0803847b8db618d39ff50ae6015e409ab1ae
Author: Justus Winter <justus at g10code.com>
Date:   Tue Nov 8 14:05:46 2016 +0100

    common,w32: Simplify locking.
    
    * common/asshelp.c (lock_spawning): Use the same code on Windows that
    we use on all other platforms.
    (unlock_spawning): Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 common/asshelp.c | 49 -------------------------------------------------
 1 file changed, 49 deletions(-)

diff --git a/common/asshelp.c b/common/asshelp.c
index f8c3237..2cab310 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -267,48 +267,7 @@ static gpg_error_t
 lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
                int verbose)
 {
-#ifdef HAVE_W32_SYSTEM
-  int waitrc;
-  int timeout = (!strcmp (name, "agent")
-                 ? SECS_TO_WAIT_FOR_AGENT
-                 : SECS_TO_WAIT_FOR_DIRMNGR);
-
-  (void)homedir; /* Not required. */
-
-  *lock = CreateMutexW
-    (NULL, FALSE,
-     !strcmp (name, "agent")?   L"spawn_"GNUPG_NAME"_agent_sentinel":
-     !strcmp (name, "dirmngr")? L"spawn_"GNUPG_NAME"_dirmngr_sentinel":
-     /*                    */   L"spawn_"GNUPG_NAME"_unknown_sentinel");
-  if (!*lock)
-    {
-      log_error ("failed to create the spawn_%s mutex: %s\n",
-                 name, w32_strerror (-1));
-      return gpg_error (GPG_ERR_GENERAL);
-    }
-
- retry:
-  waitrc = WaitForSingleObject (*lock, 1000);
-  if (waitrc == WAIT_OBJECT_0)
-    return 0;
-
-  if (waitrc == WAIT_TIMEOUT && timeout)
-    {
-      timeout--;
-      if (verbose)
-        log_info ("another process is trying to start the %s ... (%ds)\n",
-                  name, timeout);
-      goto retry;
-    }
-  if (waitrc == WAIT_TIMEOUT)
-    log_info ("error waiting for the spawn_%s mutex: timeout\n", name);
-  else
-    log_info ("error waiting for the spawn_%s mutex: (code=%d) %s\n",
-              name, waitrc, w32_strerror (-1));
-  return gpg_error (GPG_ERR_GENERAL);
-#else /*!HAVE_W32_SYSTEM*/
   char *fname;
-
   (void)verbose;
 
   *lock = NULL;
@@ -333,7 +292,6 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
     return gpg_error_from_syserror ();
 
   return 0;
-#endif /*!HAVE_W32_SYSTEM*/
 }
 
 
@@ -343,15 +301,8 @@ unlock_spawning (lock_spawn_t *lock, const char *name)
 {
   if (*lock)
     {
-#ifdef HAVE_W32_SYSTEM
-      if (!ReleaseMutex (*lock))
-        log_error ("failed to release the spawn_%s mutex: %s\n",
-                   name, w32_strerror (-1));
-      CloseHandle (*lock);
-#else /*!HAVE_W32_SYSTEM*/
       (void)name;
       dotlock_destroy (*lock);
-#endif /*!HAVE_W32_SYSTEM*/
       *lock = NULL;
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list