gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21947 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r21947 - gnunet/src/util
Date: Wed, 13 Jun 2012 10:38:15 +0200

Author: grothoff
Date: 2012-06-13 10:38:15 +0200 (Wed, 13 Jun 2012)
New Revision: 21947

Modified:
   gnunet/src/util/os_installation.c
   gnunet/src/util/os_priority.c
Log:
-minor optimization

Modified: gnunet/src/util/os_installation.c
===================================================================
--- gnunet/src/util/os_installation.c   2012-06-13 08:35:01 UTC (rev 21946)
+++ gnunet/src/util/os_installation.c   2012-06-13 08:38:15 UTC (rev 21947)
@@ -520,16 +520,26 @@
   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
 }

Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c       2012-06-13 08:35:01 UTC (rev 21946)
+++ gnunet/src/util/os_priority.c       2012-06-13 08:38:15 UTC (rev 21947)
@@ -795,6 +795,8 @@
   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 @@
   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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]