Fixed reconnect
[oweals/gnunet.git] / src / fs / fs.c
index e26a01996d83cc830543b57c2b5523063ba2b96d..93971075abec31bc5b95e24226c2ee77278bf3ae 100644 (file)
@@ -72,8 +72,8 @@ stop_job (struct GNUNET_FS_QueueEntry *qe)
   qe->h->active_blocks -= qe->blocks;
   qe->run_time =
       GNUNET_TIME_relative_add (qe->run_time,
-                                GNUNET_TIME_absolute_get_duration (qe->
-                                                                   start_time));
+                                GNUNET_TIME_absolute_get_duration
+                                (qe->start_time));
   GNUNET_CONTAINER_DLL_remove (qe->h->running_head, qe->h->running_tail, qe);
   GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head, qe->h->pending_tail,
                                      qe->h->pending_tail, qe);
@@ -213,7 +213,7 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf,
 
 /**
  * Destroy a top-level activity entry.
- * 
+ *
  * @param h global fs handle
  * @param top top level activity entry
  */
@@ -250,7 +250,7 @@ struct FileInfo
  * @param offset offset to read from; it is possible
  *            that the caller might need to go backwards
  *            a bit at times
- * @param max maximum number of bytes that should be 
+ * @param max maximum number of bytes that should be
  *            copied to buf; readers are not allowed
  *            to provide less data unless there is an error;
  *            a value of "0" will be used at the end to allow
@@ -333,7 +333,7 @@ GNUNET_FS_make_file_reader_context_ (const char *filename)
  * @param offset offset to read from; it is possible
  *            that the caller might need to go backwards
  *            a bit at times
- * @param max maximum number of bytes that should be 
+ * @param max maximum number of bytes that should be
  *            copied to buf; readers are not allowed
  *            to provide less data unless there is an error;
  *            a value of "0" will be used at the end to allow
@@ -363,7 +363,7 @@ GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf,
  * (for serialization/deserialization).
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param ent entity identifier (or emtpy string for the directory)
  * @return NULL on error
  */
@@ -394,7 +394,7 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext,
  * parent operation.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param uni name of the parent operation
  * @param ent entity identifier (or emtpy string for the directory)
  * @return NULL on error
@@ -424,7 +424,7 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
  * Return a read handle for deserialization.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param ent entity identifier (or emtpy string for the directory)
  * @return NULL on error
  */
@@ -447,7 +447,7 @@ get_read_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
  * Return a write handle for serialization.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param ent entity identifier (or emtpy string for the directory)
  * @return NULL on error
  */
@@ -474,7 +474,7 @@ get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
  * Return a write handle for serialization.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param uni name of parent
  * @param ent entity identifier (or emtpy string for the directory)
  * @return NULL on error
@@ -499,8 +499,8 @@ get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
  * Remove serialization/deserialization file from disk.
  *
  * @param h master context
- * @param ext component of the path 
- * @param ent entity identifier 
+ * @param ext component of the path
+ * @param ent entity identifier
  */
 void
 GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
@@ -527,9 +527,9 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext,
  * Remove serialization/deserialization file from disk.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param uni parent name
- * @param ent entity identifier 
+ * @param ent entity identifier
  */
 static void
 remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
@@ -556,8 +556,8 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext,
  * Remove serialization/deserialization directory from disk.
  *
  * @param h master context
- * @param ext component of the path 
- * @param uni unique name of parent 
+ * @param ext component of the path
+ * @param uni unique name of parent
  */
 void
 GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext,
@@ -638,12 +638,8 @@ read_start_time (struct GNUNET_BIO_ReadHandle *rh,
  *        the infromation
  * @return NULL on error
  */
-static struct GNUNET_FS_FileInformation *deserialize_file_information (struct
-                                                                       GNUNET_FS_Handle
-                                                                       *h,
-                                                                       const
-                                                                       char
-                                                                       *filename);
+static struct GNUNET_FS_FileInformation *
+deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename);
 
 
 /**
@@ -895,7 +891,7 @@ deserialize_file_information (struct GNUNET_FS_Handle *h, const char *filename)
  * Given a serialization name (full absolute path), return the
  * basename of the file (without the path), which must only
  * consist of the 6 random characters.
- * 
+ *
  * @param fullname name to extract the basename from
  * @return copy of the basename, NULL on error
  */
@@ -930,7 +926,7 @@ get_serialization_short_name (const char *fullname)
  * is enabled and returns NULL if not.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @return NULL on errror
  */
 static char *
@@ -965,7 +961,7 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext)
  * is enabled and returns NULL if not.
  *
  * @param h master context
- * @param ext component of the path 
+ * @param ext component of the path
  * @param uni name of parent
  * @return NULL on errror
  */
@@ -1152,8 +1148,8 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
         (GNUNET_OK !=
          GNUNET_BIO_write_string (wh,
                                   (fi->data.dir.entries ==
-                                   NULL) ? NULL : fi->data.dir.entries->
-                                  serialization)))
+                                   NULL) ? NULL : fi->data.dir.
+                                  entries->serialization)))
     {
       GNUNET_break (0);
       goto cleanup;
@@ -1400,7 +1396,7 @@ cleanup:
  * on disk.  Note that all internal FS-operations that change
  * publishing structs should already call "sync" internally,
  * so this function is likely not useful for clients.
- * 
+ *
  * @param pc the struct to sync
  */
 void
@@ -1467,7 +1463,7 @@ cleanup:
  * on disk.  Note that all internal FS-operations that change
  * publishing structs should already call "sync" internally,
  * so this function is likely not useful for clients.
- * 
+ *
  * @param uc the struct to sync
  */
 void
@@ -1520,7 +1516,7 @@ cleanup:
 
 /**
  * Serialize a download request.
- * 
+ *
  * @param wh the 'struct GNUNET_BIO_WriteHandle*'
  * @param dr the 'struct DownloadRequest'
  * @return GNUNET_YES on success, GNUNET_NO on error
@@ -1549,7 +1545,7 @@ write_download_request (struct GNUNET_BIO_WriteHandle *wh,
 
 /**
  * Read a download request tree.
- * 
+ *
  * @param rh stream to read from
  * @return value the 'struct DownloadRequest', NULL on error
  */
@@ -1566,9 +1562,9 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh)
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) ||
       (dr->num_children > CHK_PER_INODE) ||
       (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((dr->depth == 0)
-                                                                && (dr->
-                                                                    num_children
-                                                                    > 0)) ||
+                                                                &&
+                                                                (dr->num_children
+                                                                 > 0)) ||
       ((dr->depth > 0) && (dr->num_children == 0)))
   {
     GNUNET_break (0);
@@ -1650,7 +1646,7 @@ get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc,
  * on disk.  Note that all internal FS-operations that change
  * publishing structs should already call "sync" internally,
  * so this function is likely not useful for clients.
- * 
+ *
  * @param dc the struct to sync
  */
 void
@@ -1752,7 +1748,7 @@ cleanup:
  * on disk.  Note that all internal FS-operations that change
  * publishing structs should already call "sync" internally,
  * so this function is likely not useful for clients.
- * 
+ *
  * @param sr the struct to sync
  */
 void
@@ -1829,7 +1825,7 @@ cleanup:
  * on disk.  Note that all internal FS-operations that change
  * publishing structs should already call "sync" internally,
  * so this function is likely not useful for clients.
- * 
+ *
  * @param sc the struct to sync
  */
 void
@@ -2017,31 +2013,27 @@ cleanup:
  * @param search associated search
  * @param serialization name under which the search was serialized
  */
-static void deserialize_download (struct GNUNET_FS_Handle *h,
-                                  struct GNUNET_BIO_ReadHandle *rh,
-                                  struct GNUNET_FS_DownloadContext *parent,
-                                  struct GNUNET_FS_SearchResult *search,
-                                  const char *serialization);
+static void
+deserialize_download (struct GNUNET_FS_Handle *h,
+                      struct GNUNET_BIO_ReadHandle *rh,
+                      struct GNUNET_FS_DownloadContext *parent,
+                      struct GNUNET_FS_SearchResult *search,
+                      const char *serialization);
 
 
 /**
- * Deserialize a search. 
+ * Deserialize a search.
  *
  * @param h overall context
  * @param rh file to deserialize from
  * @param psearch_result parent search result
  * @param serialization name under which the search was serialized
  */
-static struct GNUNET_FS_SearchContext *deserialize_search (struct
-                                                           GNUNET_FS_Handle *h,
-                                                           struct
-                                                           GNUNET_BIO_ReadHandle
-                                                           *rh,
-                                                           struct
-                                                           GNUNET_FS_SearchResult
-                                                           *psearch_result,
-                                                           const char
-                                                           *serialization);
+static struct GNUNET_FS_SearchContext *
+deserialize_search (struct GNUNET_FS_Handle *h,
+                    struct GNUNET_BIO_ReadHandle *rh,
+                    struct GNUNET_FS_SearchResult *psearch_result,
+                    const char *serialization);
 
 
 /**
@@ -2173,7 +2165,7 @@ cleanup:
  * resume the download (put it in the queue).  Does this
  * recursively for the top-level download and all child
  * downloads.
- * 
+ *
  * @param dc download to resume
  */
 static void
@@ -2203,7 +2195,8 @@ signal_download_resume (struct GNUNET_FS_DownloadContext *dc)
  *
  * @param sc search being resumed
  */
-static void signal_search_resume (struct GNUNET_FS_SearchContext *sc);
+static void
+signal_search_resume (struct GNUNET_FS_SearchContext *sc);
 
 
 /**
@@ -2255,7 +2248,8 @@ signal_result_resume (void *cls, const GNUNET_HashCode * key, void *value)
  *
  * @param sc search context to free
  */
-static void free_search_context (struct GNUNET_FS_SearchContext *sc);
+static void
+free_search_context (struct GNUNET_FS_SearchContext *sc);
 
 
 /**
@@ -2517,7 +2511,7 @@ signal_search_resume (struct GNUNET_FS_SearchContext *sc)
 
 
 /**
- * Deserialize a search. 
+ * Deserialize a search.
  *
  * @param h overall context
  * @param rh file to deserialize from
@@ -2706,7 +2700,7 @@ deserialization_master (const char *master_path, GNUNET_FileNameCallback proc,
  * Setup a connection to the file-sharing service.
  *
  * @param cfg configuration to use
- * @param client_name unique identifier for this client 
+ * @param client_name unique identifier for this client
  * @param upcb function to call to notify about FS actions
  * @param upcb_cls closure for upcb
  * @param flags specific attributes for fs-operations