gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: trying again to fix test_se


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: trying again to fix test_service timeout on v6 failure
Date: Thu, 04 Jan 2018 17:05:07 +0100

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

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new f46c10727 trying again to fix test_service timeout on v6 failure
f46c10727 is described below

commit f46c107278b96264b2e5302b4ebb050f73abf869
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Jan 4 17:05:05 2018 +0100

    trying again to fix test_service timeout on v6 failure
---
 src/util/crypto_ecc.c       |  4 +-
 src/util/crypto_ecc_dlog.c  |  1 +
 src/util/crypto_ecc_setup.c | 98 ++++++++++++++++++++++++++++++++-------------
 src/util/crypto_hash_file.c | 16 +++++---
 src/util/test_service.c     | 12 +++++-
 5 files changed, 95 insertions(+), 36 deletions(-)

diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index 7845932ee..5d5e8a9ce 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -1242,7 +1242,7 @@ eddsa_d_to_a (gcry_mpi_t d)
   size_t rawmpilen;
   unsigned char digest[64]; /* 512-bit hash value */
   gcry_buffer_t hvec[2];
-  int b;
+  unsigned int b;
   gcry_mpi_t a;
 
   b = 256 / 8; /* number of bytes in `d` */
@@ -1257,7 +1257,7 @@ eddsa_d_to_a (gcry_mpi_t d)
                                  d));
   hvec[0].data = digest;
   hvec[0].off = 0;
-  hvec[0].len = b > rawmpilen? b - rawmpilen : 0;
+  hvec[0].len = b > rawmpilen ? (b - rawmpilen) : 0;
   hvec[1].data = rawmpi;
   hvec[1].off = 0;
   hvec[1].len = rawmpilen;
diff --git a/src/util/crypto_ecc_dlog.c b/src/util/crypto_ecc_dlog.c
index 38e2088cc..91411368f 100644
--- a/src/util/crypto_ecc_dlog.c
+++ b/src/util/crypto_ecc_dlog.c
@@ -130,6 +130,7 @@ GNUNET_CRYPTO_ecc_bin_to_point (struct 
GNUNET_CRYPTO_EccDlogContext *edc,
   gcry_ctx_t ctx;
   gcry_mpi_point_t q;
 
+  (void) edc;
   if (0 != gcry_sexp_build (&pub_sexpr, NULL,
                             "(public-key(ecc(curve " CURVE ")(q %b)))",
                             (int) sizeof (bin->q_y),
diff --git a/src/util/crypto_ecc_setup.c b/src/util/crypto_ecc_setup.c
index 64610ddd3..e7caf9ded 100644
--- a/src/util/crypto_ecc_setup.c
+++ b/src/util/crypto_ecc_setup.c
@@ -80,6 +80,7 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char 
*filename)
   unsigned int cnt;
   int ec;
   uint64_t fs;
+  ssize_t sret;
 
   if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
@@ -193,7 +194,8 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char 
*filename)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
              _("When trying to read key file `%s' I found %u bytes but I need 
at least %u.\n"),
-             filename, (unsigned int) fs,
+             filename,
+            (unsigned int) fs,
              (unsigned int) sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey));
         LOG (GNUNET_ERROR_TYPE_ERROR,
              _("This may be ok if someone is currently generating a key.\n"));
@@ -205,12 +207,20 @@ GNUNET_CRYPTO_eddsa_key_create_from_file (const char 
*filename)
   }
   fs = sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs));
+  sret = GNUNET_DISK_file_read (fd,
+                               priv,
+                               fs);
+  GNUNET_assert ( (sret >= 0) &&
+                 (fs == (size_t) sret) );
   if (GNUNET_YES !=
-      GNUNET_DISK_file_unlock (fd, 0,
+      GNUNET_DISK_file_unlock (fd,
+                              0,
                                sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                      "fcntl",
+                      filename);
+  GNUNET_assert (GNUNET_YES ==
+                GNUNET_DISK_file_close (fd));
   return priv;
 }
 
@@ -237,8 +247,10 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
   unsigned int cnt;
   int ec;
   uint64_t fs;
-
-  if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
+  ssize_t sret;
+  
+  if (GNUNET_SYSERR ==
+      GNUNET_DISK_directory_create_for_file (filename))
     return NULL;
   while (GNUNET_YES != GNUNET_DISK_file_test (filename))
   {
@@ -255,19 +267,24 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
         {
           /* must exist but not be accessible, fail for good! */
           if (0 != ACCESS (filename, R_OK))
-            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", filename);
+            LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                              "access",
+                              filename);
           else
             GNUNET_break (0);   /* what is going on!? */
           return NULL;
         }
         continue;
       }
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                        "open",
+                        filename);
       return NULL;
     }
     cnt = 0;
     while (GNUNET_YES !=
-           GNUNET_DISK_file_lock (fd, 0,
+           GNUNET_DISK_file_lock (fd,
+                                 0,
                                   sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey),
                                   GNUNET_YES))
     {
@@ -276,7 +293,8 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
       {
         ec = errno;
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _("Could not acquire lock on file `%s': %s...\n"), filename,
+             _("Could not acquire lock on file `%s': %s...\n"),
+            filename,
              STRERROR (ec));
       }
     }
@@ -285,21 +303,29 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
     priv = GNUNET_CRYPTO_ecdsa_key_create ();
     GNUNET_assert (NULL != priv);
     GNUNET_assert (sizeof (*priv) ==
-                   GNUNET_DISK_file_write (fd, priv, sizeof (*priv)));
+                   GNUNET_DISK_file_write (fd,
+                                          priv,
+                                          sizeof (*priv)));
     GNUNET_DISK_file_sync (fd);
     if (GNUNET_YES !=
         GNUNET_DISK_file_unlock (fd, 0,
                                  sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-    GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                        "fcntl",
+                        filename);
+    GNUNET_assert (GNUNET_YES ==
+                  GNUNET_DISK_file_close (fd));
     return priv;
   }
   /* key file exists already, read it! */
-  fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+  fd = GNUNET_DISK_file_open (filename,
+                             GNUNET_DISK_OPEN_READ,
                               GNUNET_DISK_PERM_NONE);
   if (NULL == fd)
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR,
+                      "open",
+                      filename);
     return NULL;
   }
   cnt = 0;
@@ -318,25 +344,34 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
             filename,
              STRERROR (ec));
         LOG (GNUNET_ERROR_TYPE_ERROR,
-             _
-             ("This may be ok if someone is currently generating a private 
key.\n"));
+             _("This may be ok if someone is currently generating a private 
key.\n"));
       }
       short_wait ();
       continue;
     }
-    if (GNUNET_YES != GNUNET_DISK_file_test (filename))
+    if (GNUNET_YES !=
+       GNUNET_DISK_file_test (filename))
     {
       /* eh, what!? File we opened is now gone!? */
-      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
+      LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                        "stat",
+                        filename);
       if (GNUNET_YES !=
           GNUNET_DISK_file_unlock (fd, 0,
                                    sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-      GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                          "fcntl",
+                          filename);
+      GNUNET_assert (GNUNET_OK ==
+                    GNUNET_DISK_file_close (fd));
 
       return NULL;
     }
-    if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, 
GNUNET_YES))
+    if (GNUNET_OK !=
+       GNUNET_DISK_file_size (filename,
+                              &fs,
+                              GNUNET_YES,
+                              GNUNET_YES))
       fs = 0;
     if (fs < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))
     {
@@ -345,7 +380,9 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
       if (GNUNET_YES !=
           GNUNET_DISK_file_unlock (fd, 0,
                                    sizeof (struct 
GNUNET_CRYPTO_EcdsaPrivateKey)))
-        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
+        LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                          "fcntl",
+                          filename);
       if (0 == ++cnt % 10)
       {
         LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -362,12 +399,19 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char 
*filename)
   }
   fs = sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey);
   priv = GNUNET_malloc (fs);
-  GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs));
+  sret = GNUNET_DISK_file_read (fd,
+                               priv,
+                               fs);
+  GNUNET_assert ( (sret >= 0) &&
+                 (fs == (size_t) sret) );
   if (GNUNET_YES !=
       GNUNET_DISK_file_unlock (fd, 0,
                                sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
-  GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
+                      "fcntl",
+                      filename);
+  GNUNET_assert (GNUNET_YES ==
+                GNUNET_DISK_file_close (fd));
   return priv;
 }
 
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c
index 3e5900200..cb632d02c 100644
--- a/src/util/crypto_hash_file.c
+++ b/src/util/crypto_hash_file.c
@@ -124,23 +124,29 @@ file_hash_task (void *cls)
   struct GNUNET_CRYPTO_FileHashContext *fhc = cls;
   struct GNUNET_HashCode *res;
   size_t delta;
+  ssize_t sret;
 
   fhc->task = NULL;
   GNUNET_assert (fhc->offset <= fhc->fsize);
   delta = fhc->bsize;
   if (fhc->fsize - fhc->offset < delta)
     delta = fhc->fsize - fhc->offset;
-  if (delta != GNUNET_DISK_file_read (fhc->fh,
-                                     fhc->buffer,
-                                     delta))
+  sret = GNUNET_DISK_file_read (fhc->fh,
+                               fhc->buffer,
+                               delta);
+  if ( (sret < 0) ||
+       (delta != (size_t) sret) )
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
                       "read",
                       fhc->filename);
-    file_hash_finish (fhc, NULL);
+    file_hash_finish (fhc,
+                     NULL);
     return;
   }
-  gcry_md_write (fhc->md, fhc->buffer, delta);
+  gcry_md_write (fhc->md,
+                fhc->buffer,
+                delta);
   fhc->offset += delta;
   if (fhc->offset == fhc->fsize)
   {
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 3ffacb0a9..424a445bb 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -52,8 +52,11 @@ handle_recv (void *cls,
              "Received client message...\n");
   GNUNET_SERVICE_client_continue (client);
   global_ret = 2;
-  GNUNET_MQ_destroy (mq);
-  mq = NULL;
+  if (NULL != mq)
+  {
+    GNUNET_MQ_destroy (mq);
+    mq = NULL;
+  }
 }
 
 
@@ -106,6 +109,11 @@ static void
 timeout_task (void *cls)
 {
   tt = NULL;
+  if (NULL != mq)
+  {
+    GNUNET_MQ_destroy (mq);
+    mq = NULL;
+  }
   global_ret = 33;
   GNUNET_SCHEDULER_shutdown ();
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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