-minor optimization
authorChristian Grothoff <christian@grothoff.org>
Wed, 13 Jun 2012 08:38:15 +0000 (08:38 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 13 Jun 2012 08:38:15 +0000 (08:38 +0000)
src/util/os_installation.c
src/util/os_priority.c

index e790ce10eec9b46a187431a5d0e1ccab86248ff2..2e1acac640fdac98c036a1d31adb4e94c184ee56 100644 (file)
@@ -520,16 +520,26 @@ GNUNET_OS_check_helper_binary (const char *binary)
   return GNUNET_NO;
 #else
   GNUNET_free (p);
-  rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
-  if (INVALID_SOCKET == rawsock)
   {
-    DWORD err = GetLastError ();
+    static int once; /* remember result from previous runs... */
 
-    LOG (GNUNET_ERROR_TYPE_INFO,
-         "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err);
-    return GNUNET_NO;           /* not running as administrator */
-  }
-  closesocket (rawsock);
+    if (0 == once)
+    {
+      rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
+      if (INVALID_SOCKET == rawsock)
+       {
+         DWORD err = GetLastError ();
+         
+         LOG (GNUNET_ERROR_TYPE_INFO,
+              "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) failed! GLE = %d\n", err);
+         once = -1;
+         return GNUNET_NO;           /* not running as administrator */
+       }
+      once = 1;
+      closesocket (rawsock);
+    }
+    if (-1 == once)
+      return GNUNET_NO;
   return GNUNET_YES;
 #endif
 }
index cafb1504c1fef5640c65c98772ccb189f46c13cc..e53dbfa2dd0aec6ffa2a57571bb45c92e02950c4 100644 (file)
@@ -795,6 +795,8 @@ start_process (int pipe_control,
   int fd_stdin_read;
   int fd_stdin_write;
 
+  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename))
+    return NULL; /* not executable */
   if ( (GNUNET_YES == pipe_control) &&
        (GNUNET_OK != npipe_setup (&childpipename)) )
     return NULL;  
@@ -952,6 +954,9 @@ start_process (int pipe_control,
   long lRet;
   HANDLE stdin_handle;
   HANDLE stdout_handle;
+
+  if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename))
+    return NULL; /* not executable */
  
   /* Search in prefix dir (hopefully - the directory from which
    * the current module was loaded), bindir and libdir, then in PATH