gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r13918 - branches/gnunet/mantis_0001616/src/util


From: gnunet
Subject: [GNUnet-SVN] r13918 - branches/gnunet/mantis_0001616/src/util
Date: Wed, 15 Dec 2010 21:11:25 +0100

Author: durner
Date: 2010-12-15 21:11:25 +0100 (Wed, 15 Dec 2010)
New Revision: 13918

Modified:
   branches/gnunet/mantis_0001616/src/util/disk.c
Log:
0001-Parent-child-control-pipes-ndurner-s-IO-based.patch by LRN

Modified: branches/gnunet/mantis_0001616/src/util/disk.c
===================================================================
--- branches/gnunet/mantis_0001616/src/util/disk.c      2010-12-15 19:50:05 UTC 
(rev 13917)
+++ branches/gnunet/mantis_0001616/src/util/disk.c      2010-12-15 20:11:25 UTC 
(rev 13918)
@@ -34,6 +34,7 @@
 #include "gnunet_crypto_lib.h"
 #include "disk.h"
 
+#define DEBUG_NPIPE GNUNET_YES
 
 /**
  * Block size for IO for copying files.
@@ -1908,10 +1909,14 @@
 
   while (h == NULL)
     {
+      DWORD error_code;
       name = NULL;
       if (*fn != NULL)
         {
           GNUNET_asprintf(&name, "\\\\.\\pipe\\%.246s", fn);
+#if DEBUG_NPIPE
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to create an instance 
of named pipe `%s'\n", name);
+#endif
           h = CreateNamedPipe (name, openMode | FILE_FLAG_OVERLAPPED,
               PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0, NULL);
         }
@@ -1919,21 +1924,36 @@
         {
           GNUNET_asprintf(fn, "\\\\.\\pipe\\gnunet-%llu",
               GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 
UINT64_MAX));
-          h = CreateNamedPipe (*fn, openMode | FILE_FLAG_OVERLAPPED,
-              PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0, NULL);
+#if DEBUG_NPIPE
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to create unique named 
pipe `%s'\n", *fn);
+#endif
+          h = CreateNamedPipe (*fn, openMode | FILE_FLAG_OVERLAPPED | 
FILE_FLAG_FIRST_PIPE_INSTANCE,
         }
+      error_code = GetLastError ();
       if (name)
           GNUNET_free(name);
       /* don't re-set name to NULL yet */
       if (h == INVALID_HANDLE_VALUE)
         {
-          SetErrnoFromWinError(GetLastError());
+          SetErrnoFromWinError(error_code);
+#if DEBUG_NPIPE
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pipe creation have failed 
because of %d, errno is %d\n", error_code, errno);
+#endif
           if (name == NULL)
             {
+#if DEBUG_NPIPE
+              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pipe was to be unique, 
considering re-creation\n");
+#endif
               GNUNET_free (*fn);
               *fn = NULL;
-              if (errno != EEXIST)
+              if (error_code != ERROR_ACCESS_DENIED && error_code != 
ERROR_PIPE_BUSY)
+                {
                   return NULL;
+                }
+#if DEBUG_NPIPE
+              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pipe name was not unique, 
trying again\n");
+#endif
+              h = NULL;
             }
           else
               return NULL;




reply via email to

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