gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8632 - in gnunet/src: include statistics util


From: gnunet
Subject: [GNUnet-SVN] r8632 - in gnunet/src: include statistics util
Date: Tue, 7 Jul 2009 14:05:38 -0600

Author: grothoff
Date: 2009-07-07 14:05:38 -0600 (Tue, 07 Jul 2009)
New Revision: 8632

Modified:
   gnunet/src/include/gnunet_disk_lib.h
   gnunet/src/statistics/gnunet-service-statistics.c
   gnunet/src/util/container_bloomfilter.c
   gnunet/src/util/crypto_hash.c
   gnunet/src/util/disk.c
   gnunet/src/util/pseudonym.c
Log:
cleaning up disk api

Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h        2009-07-07 18:42:02 UTC (rev 
8631)
+++ gnunet/src/include/gnunet_disk_lib.h        2009-07-07 20:05:38 UTC (rev 
8632)
@@ -74,7 +74,7 @@
 
 enum GNUNET_DISK_Seek {GNUNET_SEEK_SET, GNUNET_SEEK_CUR, GNUNET_SEEK_END};
 
-struct GNUNET_IO_Handle;
+struct GNUNET_DISK_FileHandle;
 
 /**
  * Get the number of blocks that are left on the partition that
@@ -91,7 +91,7 @@
  * @param h handle to check
  * @return GNUNET_YES if invalid, GNUNET_NO if valid
  */
-int GNUNET_DISK_handle_invalid (const struct GNUNET_IO_Handle *h);
+int GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h);
 
 
 /**
@@ -112,7 +112,7 @@
  * @return the new position on success, GNUNET_SYSERR otherwise
  */
 off_t
-GNUNET_DISK_file_seek (const struct GNUNET_IO_Handle *h, off_t offset,
+GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset,
     enum GNUNET_DISK_Seek whence);
 
 
@@ -136,15 +136,16 @@
  * @param perm permissions for the newly created file
  * @return IO handle on success, NULL on error
  */
-struct GNUNET_IO_Handle *GNUNET_DISK_file_open (const char *fn, int flags, 
...);
+struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn, int 
flags, ...);
 
 
 /**
- * Close an open file
+ * Close an open file.
+ *
  * @param h file handle
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
-int GNUNET_DISK_file_close (struct GNUNET_IO_Handle **h);
+int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
 
 
 /**
@@ -154,7 +155,8 @@
  * @param len the maximum number of bytes to read
  * @return the number of bytes read on success, GNUNET_SYSERR on failure
  */
-int GNUNET_DISK_file_read (const struct GNUNET_IO_Handle *h, void *result, int 
len);
+ssize_t GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void 
*result, 
+                              size_t len);
 
 
 /**
@@ -164,29 +166,36 @@
  * @param len the maximum number of bytes to read
  * @return number of bytes read, GNUNET_SYSERR on failure
  */
-int GNUNET_DISK_fn_read (const char * const fn, void *result, int len);
+ssize_t GNUNET_DISK_fn_read (const char * const fn, void *result, 
+                            size_t len);
 
 
 /**
  * Write a buffer to a file.
+ *
  * @param h handle to open file
  * @param buffer the data to write
  * @param n number of bytes to write
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int GNUNET_DISK_file_write (const struct GNUNET_IO_Handle *h, const void 
*buffer,
-    unsigned int n);
+ssize_t GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, 
+                               const void *buffer,
+                               size_t n);
 
 
 /**
- * Write a buffer to a file.
+ * Write a buffer to a file.  If the file is longer than
+ * the given buffer size, it will be truncated.
+ *
  * @param fn file name
  * @param buffer the data to write
  * @param n number of bytes to write
  * @return number of bytes written on success, GNUNET_SYSERR on error
  */
-int GNUNET_DISK_fn_write (const char * const fn, const void *buffer,
-    unsigned int n, int mode);
+ssize_t GNUNET_DISK_fn_write (const char * fn, 
+                             const void *buffer,
+                             size_t n, 
+                             int mode);
 
 
 /**
@@ -317,7 +326,7 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-GNUNET_DISK_file_lock(struct GNUNET_IO_Handle *fh, off_t lockStart,
+GNUNET_DISK_file_lock(struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
     off_t lockEnd);
 
 
@@ -353,32 +362,38 @@
 char *GNUNET_DISK_get_home_filename (struct GNUNET_CONFIGURATION_Handle *cfg,
                                      const char *serviceName, ...);
 
+
 /**
+ * Opaque handle for a memory-mapping operation.
+ */
+struct GNUNET_DISK_MapHandle;
+
+/**
  * Map a file into memory
  * @param h open file handle
- * @param m handle to the new mapping
+ * @param m handle to the new mapping (will be set)
  * @param access access specification, GNUNET_DISK_MAP_xxx
  * @param len size of the mapping
  * @return pointer to the mapped memory region, NULL on failure
  */
-void *GNUNET_DISK_file_map (const struct GNUNET_IO_Handle *h, struct 
GNUNET_IO_Handle **m,
-    int access, size_t len);
+void *GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, 
+                           struct GNUNET_DISK_MapHandle **m,
+                           int access, size_t len);
 
 /**
  * Unmap a file
+ *
  * @param h mapping handle
- * @param addr pointer to the mapped memory region
- * @param len size of the mapping
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
-int GNUNET_DISK_file_unmap (struct GNUNET_IO_Handle **h, void *addr, size_t 
len);
+int GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h);
 
 /**
  * Write file changes to disk
  * @param h handle to an open file
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
-int GNUNET_DISK_file_sync (const struct GNUNET_IO_Handle *h);
+int GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: gnunet/src/statistics/gnunet-service-statistics.c
===================================================================
--- gnunet/src/statistics/gnunet-service-statistics.c   2009-07-07 18:42:02 UTC 
(rev 8631)
+++ gnunet/src/statistics/gnunet-service-statistics.c   2009-07-07 20:05:38 UTC 
(rev 8632)
@@ -99,7 +99,8 @@
       struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *fn;
-  struct GNUNET_IO_Handle *fh, *mh;
+  struct GNUNET_DISK_FileHandle *fh;
+  struct GNUNET_DISK_MapHandle *mh;
   struct stat sb;
   char *buf;
   size_t off;
@@ -124,7 +125,7 @@
   if (NULL == buf)
     {
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "mmap", fn);
-      GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (&fh));
+      GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
       GNUNET_free (fn);
       return;
     }
@@ -143,8 +144,8 @@
         }
       off += ntohs (msg->size);
     }
-  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (&mh, buf, sb.st_size));
-  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (&fh));
+  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (mh));
+  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
   GNUNET_free (fn);
 }
 
@@ -160,10 +161,11 @@
 {
   struct StatsEntry *pos;
   char *fn;
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
   uint16_t size;
   unsigned long long total;
 
+  fh = NULL;
   fn = GNUNET_DISK_get_home_filename (cfg,
                                       "statistics", "statistics.data", NULL);
   if (fn != NULL)
@@ -174,23 +176,24 @@
   while (NULL != (pos = start))
     {
       start = pos->next;
-      if ((pos->persistent) && fh)
+      if ((pos->persistent) && (NULL != fh))
         {
           size = htons (pos->msg->header.size);
           if (size != GNUNET_DISK_file_write (fh, pos->msg, size))
             {
               GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
                                         "write", fn);
-              GNUNET_DISK_file_close (&fh);
+              GNUNET_DISK_file_close (fh);
+             fh = NULL;
             }
           else
             total += size;
         }
       GNUNET_free (pos);
     }
-  if (fh)
+  if (NULL != fh)
     {
-      GNUNET_DISK_file_close (&fh);
+      GNUNET_DISK_file_close (fh);
       if (total == 0)
         GNUNET_break (0 == UNLINK (fn));
       else

Modified: gnunet/src/util/container_bloomfilter.c
===================================================================
--- gnunet/src/util/container_bloomfilter.c     2009-07-07 18:42:02 UTC (rev 
8631)
+++ gnunet/src/util/container_bloomfilter.c     2009-07-07 20:05:38 UTC (rev 
8632)
@@ -60,7 +60,7 @@
   /**
    * The bit counter file on disk
    */
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
 
   /**
    * How many bits we set for each stored element
@@ -142,7 +142,7 @@
  * @param fh A file to keep the 4 bit address usage counters in
  */
 static void
-incrementBit (char *bitArray, unsigned int bitIdx, const struct 
GNUNET_IO_Handle *fh)
+incrementBit (char *bitArray, unsigned int bitIdx, const struct 
GNUNET_DISK_FileHandle *fh)
 {
   unsigned int fileSlot;
   unsigned char value;
@@ -187,7 +187,7 @@
  * @param fh A file to keep the 4bit address usage counters in
  */
 static void
-decrementBit (char *bitArray, unsigned int bitIdx, const struct 
GNUNET_IO_Handle *fh)
+decrementBit (char *bitArray, unsigned int bitIdx, const struct 
GNUNET_DISK_FileHandle *fh)
 {
   unsigned int fileSlot;
   unsigned char value;
@@ -240,7 +240,7 @@
  * @return GNUNET_OK if created ok, GNUNET_SYSERR otherwise
  */
 static int
-makeEmptyFile (const struct GNUNET_IO_Handle *fh, unsigned int size)
+makeEmptyFile (const struct GNUNET_DISK_FileHandle *fh, unsigned int size)
 {
   char *buffer;
   unsigned int bytesleft = size;
@@ -541,7 +541,7 @@
     return;
   if (bf->filename != NULL)
     {
-      GNUNET_DISK_file_close (&bf->fh);
+      GNUNET_DISK_file_close (bf->fh);
       GNUNET_free (bf->filename);
     }
   GNUNET_free (bf->bitArray);

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2009-07-07 18:42:02 UTC (rev 8631)
+++ gnunet/src/util/crypto_hash.c       2009-07-07 20:05:38 UTC (rev 8632)
@@ -429,7 +429,7 @@
   /**
    * File descriptor.
    */
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
 
 };
 
@@ -444,7 +444,7 @@
   fhc->callback (fhc->callback_cls, res);
   GNUNET_free (fhc->filename);
   if (!GNUNET_DISK_handle_invalid (fhc->fh))
-    GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (&fhc->fh));
+    GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh));
   GNUNET_free (fhc);            /* also frees fhc->buffer */
 }
 

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2009-07-07 18:42:02 UTC (rev 8631)
+++ gnunet/src/util/disk.c      2009-07-07 20:05:38 UTC (rev 8632)
@@ -74,7 +74,7 @@
   int include_sym_links;
 } GetFileSizeData;
 
-struct GNUNET_IO_Handle
+struct GNUNET_DISK_FileHandle
 {
 #if MINGW
   HANDLE h;
@@ -124,7 +124,7 @@
  * @return GNUNET_YES if invalid, GNUNET_NO if valid
  */
 int
-GNUNET_DISK_handle_invalid (const struct GNUNET_IO_Handle *h)
+GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
 {
 #ifdef MINGW
   return !h || h->h == INVALID_HANDLE_VALUE ? GNUNET_YES : GNUNET_NO;
@@ -133,19 +133,6 @@
 #endif
 }
 
-/**
- * Mark a handle as invalid
- * @param h file handle
- */
-static void
-GNUNET_DISK_handle_invalidate (struct GNUNET_IO_Handle *h)
-{
-#ifdef MINGW
-  h->h = INVALID_HANDLE_VALUE;
-#else
-  h->fd = -1;
-#endif
-}
 
 /**
  * Move the read/write pointer in a file
@@ -155,7 +142,7 @@
  * @return the new position on success, GNUNET_SYSERR otherwise
  */
 off_t
-GNUNET_DISK_file_seek (const struct GNUNET_IO_Handle *h, off_t offset,
+GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset,
     enum GNUNET_DISK_Seek whence)
 {
   if (h == NULL)
@@ -441,8 +428,9 @@
  * @param len the maximum number of bytes to read
  * @return the number of bytes read on success, GNUNET_SYSERR on failure
  */
-int
-GNUNET_DISK_file_read (const struct GNUNET_IO_Handle *h, void *result, int len)
+ssize_t
+GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result, 
+                      size_t len)
 {
   if (h == NULL)
     {
@@ -467,22 +455,25 @@
 
 /**
  * Read the contents of a binary file into a buffer.
+ *
  * @param fn file name
  * @param result the buffer to write the result to
  * @param len the maximum number of bytes to read
  * @return number of bytes read, GNUNET_SYSERR on failure
  */
-int
-GNUNET_DISK_fn_read (const char * const fn, void *result, int len)
+ssize_t
+GNUNET_DISK_fn_read (const char * const fn, 
+                    void *result,
+                    size_t len)
 {
-  struct GNUNET_IO_Handle *fh;
-  int ret;
+  struct GNUNET_DISK_FileHandle *fh;
+  ssize_t ret;
 
   fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ);
   if (!fh)
     return GNUNET_SYSERR;
   ret = GNUNET_DISK_file_read (fh, result, len);
-  GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(&fh));
+  GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fh));
 
   return ret;
 }
@@ -495,9 +486,9 @@
  * @param n number of bytes to write
  * @return number of bytes written on success, GNUNET_SYSERR on error
  */
-int
-GNUNET_DISK_file_write (const struct GNUNET_IO_Handle *h, const void *buffer,
-    unsigned int n)
+ssize_t
+GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, const void 
*buffer,
+                       size_t n)
 {
   if (h == NULL)
     {
@@ -520,17 +511,19 @@
 }
 
 /**
- * Write a buffer to a file.
+ * Write a buffer to a file.  If the file is longer than the
+ * number of bytes that will be written, iit will be truncated.
+ *
  * @param fn file name
  * @param buffer the data to write
  * @param n number of bytes to write
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int
+ssize_t
 GNUNET_DISK_fn_write (const char * const fn, const void *buffer,
-    unsigned int n, int mode)
+    size_t n, int mode)
 {
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
   int ret;
 
   fh = GNUNET_DISK_file_open (fn, 
@@ -540,7 +533,7 @@
   if (!fh)
     return GNUNET_SYSERR;
   ret = (n == GNUNET_DISK_file_write (fh, buffer, n)) ? GNUNET_OK : 
GNUNET_SYSERR;
-  GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(&fh));
+  GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fh));
 
   return ret;
 }
@@ -837,7 +830,7 @@
   unsigned long long pos;
   unsigned long long size;
   unsigned long long len;
-  struct GNUNET_IO_Handle *in, *out;
+  struct GNUNET_DISK_FileHandle *in, *out;
 
   if (GNUNET_OK != GNUNET_DISK_file_size (src, &size, GNUNET_YES))
     return GNUNET_SYSERR;
@@ -851,7 +844,7 @@
                               | GNUNET_DISK_PERM_GROUP_READ | 
GNUNET_DISK_PERM_GROUP_WRITE);
   if (!out)
     {
-      GNUNET_DISK_file_close (&in);
+      GNUNET_DISK_file_close (in);
       return GNUNET_SYSERR;
     }
   buf = GNUNET_malloc (COPY_BLK_SIZE);
@@ -867,13 +860,13 @@
       pos += len;
     }
   GNUNET_free (buf);
-  GNUNET_DISK_file_close (&in);
-  GNUNET_DISK_file_close (&out);
+  GNUNET_DISK_file_close (in);
+  GNUNET_DISK_file_close (out);
   return GNUNET_OK;
 FAIL:
   GNUNET_free (buf);
-  GNUNET_DISK_file_close (&in);
-  GNUNET_DISK_file_close (&out);
+  GNUNET_DISK_file_close (in);
+  GNUNET_DISK_file_close (out);
   return GNUNET_SYSERR;
 }
 
@@ -937,7 +930,7 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-GNUNET_DISK_file_lock(struct GNUNET_IO_Handle *fh, off_t lockStart,
+GNUNET_DISK_file_lock(struct GNUNET_DISK_FileHandle *fh, off_t lockStart,
     off_t lockEnd)
 {
   if (fh == NULL)
@@ -975,11 +968,11 @@
  * @param perm permissions for the newly created file
  * @return IO handle on success, NULL on error
  */
-struct GNUNET_IO_Handle *
+struct GNUNET_DISK_FileHandle *
 GNUNET_DISK_file_open (const char *fn, int flags, ...)
 {
   char *expfn;
-  struct GNUNET_IO_Handle *ret;
+  struct GNUNET_DISK_FileHandle *ret;
 #ifdef MINGW
   DWORD access;
   DWORD disp;
@@ -1085,7 +1078,7 @@
     }
 #endif
 
-  ret = GNUNET_malloc(sizeof(struct GNUNET_IO_Handle));
+  ret = GNUNET_malloc(sizeof(struct GNUNET_DISK_FileHandle));
 #ifdef MINGW
   ret->h = h;
 #else
@@ -1101,33 +1094,31 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 int
-GNUNET_DISK_file_close (struct GNUNET_IO_Handle **h)
+GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h)
 {
-  if (*h == NULL)
+  if (h == NULL)
     {
       errno = EINVAL;
       return GNUNET_SYSERR;
     }
 
 #if MINGW
-  if (!CloseHandle ((*h)->h))
+  if (!CloseHandle (h->h))
   {
     SetErrnoFromWinError (GetLastError ());
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "close");
+    GNUNET_free (h);
     return GNUNET_SYSERR;
   }
 #else
-  if (close ((*h)->fd) != 0)
+  if (close (h->fd) != 0)
   {
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "close");
+    GNUNET_free (h);
     return GNUNET_SYSERR;
   }
 #endif
-
-  GNUNET_DISK_handle_invalidate (*h);
-  free(*h);
-  *h = NULL;
-
+  GNUNET_free (h);
   return GNUNET_OK;
 }
 
@@ -1200,6 +1191,17 @@
   return ret;
 }
 
+struct GNUNET_DISK_MapHandle
+{
+#ifdef MINGW
+  HANDLE h;
+#else
+  void *addr;
+  size_t len;
+#endif
+};
+
+
 /**
  * Map a file into memory
  * @param h open file handle
@@ -1209,7 +1211,7 @@
  * @return pointer to the mapped memory region, NULL on failure
  */
 void *
-GNUNET_DISK_file_map (const struct GNUNET_IO_Handle *h, struct 
GNUNET_IO_Handle **m,
+GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, struct 
GNUNET_DISK_MapHandle **m,
     int access, size_t len)
 {
   if (h == NULL)
@@ -1243,7 +1245,7 @@
       return NULL;
     }
 
-  *m = GNUNET_malloc (sizeof (struct GNUNET_IO_Handle));
+  *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle));
   (*m)->h = CreateFileMapping (h->h, NULL, protect, 0, 0, NULL);
   if ((*m)->h == INVALID_HANDLE_VALUE)
     {
@@ -1269,56 +1271,52 @@
     prot = PROT_READ;
   if (access & GNUNET_DISK_MAP_WRITE)
     prot |= PROT_WRITE;
-  *m = NULL;
-  return mmap (NULL, len, prot, MAP_SHARED, h->fd, 0);
+  *m = GNUNET_malloc (sizeof (struct GNUNET_DISK_MapHandle));
+  (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, h->fd, 0);
+  (*m)->len = len;
+  return (*m)->addr;
 #endif
 }
 
 /**
  * Unmap a file
  * @param h mapping handle
- * @param addr pointer to the mapped memory region
- * @param len size of the mapping
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 int
-GNUNET_DISK_file_unmap (struct GNUNET_IO_Handle **h, void *addr, size_t len)
+GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h)
 {
-#ifdef MINGW
   int ret;
-
-  if  ( (h == NULL) || (*h == NULL) )
+  if (h == NULL)
     {
       errno = EINVAL;
       return GNUNET_SYSERR;
     }
 
+#ifdef MINGW
   ret = UnmapViewOfFile (addr) ? GNUNET_OK : GNUNET_SYSERR;
   if (ret != GNUNET_OK)
     SetErrnoFromWinError (GetLastError ());
-  if (!CloseHandle ((*h)->h) && ret == GNUNET_OK)
+  if (!CloseHandle (h->h) && (ret == GNUNET_OK))
     {
       ret = GNUNET_SYSERR;
       SetErrnoFromWinError (GetLastError ());
     }
-
-  GNUNET_DISK_handle_invalidate (*h);
-  GNUNET_free (*h);
-  h = NULL;
-
-  return ret;
 #else
-  return munmap (addr, len) != -1 ? GNUNET_OK : GNUNET_SYSERR;
+  ret = munmap (h->addr, h->len) != -1 ? GNUNET_OK : GNUNET_SYSERR;
 #endif
+  GNUNET_free (h);
+  return ret;
 }
 
+
 /**
  * Write file changes to disk
  * @param h handle to an open file
  * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 int
-GNUNET_DISK_file_sync (const struct GNUNET_IO_Handle *h)
+GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h)
 {
   if (h == NULL)
     {

Modified: gnunet/src/util/pseudonym.c
===================================================================
--- gnunet/src/util/pseudonym.c 2009-07-07 18:42:02 UTC (rev 8631)
+++ gnunet/src/util/pseudonym.c 2009-07-07 20:05:38 UTC (rev 8632)
@@ -281,7 +281,7 @@
   GNUNET_HashCode nh;
   char *fn;
   unsigned long long len;
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
   unsigned int i;
   unsigned int idx;
   char *ret;
@@ -342,7 +342,7 @@
           GNUNET_DISK_file_write (fh, nsid, sizeof (GNUNET_HashCode)))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
     }
-  GNUNET_DISK_file_close (&fh);
+  GNUNET_DISK_file_close (fh);
   ret = GNUNET_malloc (strlen (name) + 32);
   GNUNET_snprintf (ret, strlen (name) + 32, "%s-%u", name, idx);
   GNUNET_free (name);
@@ -365,7 +365,7 @@
   char *name;
   GNUNET_HashCode nh;
   char *fn;
-  struct GNUNET_IO_Handle *fh;
+  struct GNUNET_DISK_FileHandle *fh;
 
   idx = -1;
   slen = strlen (ns_uname);
@@ -394,10 +394,10 @@
   GNUNET_DISK_file_seek (fh, idx * sizeof (GNUNET_HashCode), GNUNET_SEEK_SET);
   if (sizeof (GNUNET_HashCode) != GNUNET_DISK_file_read (fh, nsid, sizeof 
(GNUNET_HashCode)))
     {
-      GNUNET_DISK_file_close (&fh);
+      GNUNET_DISK_file_close (fh);
       return GNUNET_SYSERR;
     }
-  GNUNET_DISK_file_close (&fh);
+  GNUNET_DISK_file_close (fh);
   return GNUNET_OK;
 }
 





reply via email to

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