0.9.0pre1:
* FS: [CG]
+ - generate SUSPEND events (publish, unindex, search, download) AND free memory!
+ - actually call 'sync' functions (publish, unindex, search, download)
- linking of downloads to searches (expose opaque struct SearchResult;
allow starting download based on search result (new API):
=> have meta data for instant completion!
=> linking of download to search
=> expose link to search result in download events (including search result's
client-info pointer!)
- - generate SUSPEND events (publish, unindex, search, download)
- - fix 'start_time' time stamps (search, publish, unindex, download)
- - actually call 'sync' functions (publish, unindex, search, download)
- code review:
=> refactor fs.c to join common code segments!
- => document directory structure
+ => document directory structure (and use #define's for the directory names!)
=> ensure all files & dirs are cleaned up! (at least during 'clean' runs)
- persistence testing (publish, unindex, search, download):
=> need driver!
*/
static struct GNUNET_BIO_WriteHandle *
get_write_handle (struct GNUNET_FS_Handle *h,
- const char *ext,
- const char *ent)
+ const char *ext,
+ const char *ent)
{
char *fn;
struct GNUNET_BIO_WriteHandle *ret;
}
+/**
+ * Serialize a 'start_time'. Since we use start-times to
+ * calculate the duration of some operation, we actually
+ * do not serialize the absolute time but the (relative)
+ * duration since the start time. When we then
+ * deserialize the start time, we take the current time and
+ * subtract that duration so that we get again an absolute
+ * time stamp that will result in correct performance
+ * calculations.
+ *
+ * @param wh handle for writing
+ * @param timestamp time to serialize
+ * @return GNUNET_OK on success
+ */
+static int
+write_start_time (struct GNUNET_BIO_WriteHandle *wh,
+ struct GNUNET_TIME_Absolute timestamp)
+{
+ struct GNUNET_TIME_Relative dur;
+
+ dur = GNUNET_TIME_absolute_get_duration (timestamp);
+ return GNUNET_BIO_write_int64 (wh, dur.value);
+}
+
+
+/**
+ * Serialize a 'start_time'. Since we use start-times to
+ * calculate the duration of some operation, we actually
+ * do not serialize the absolute time but the (relative)
+ * duration since the start time. When we then
+ * deserialize the start time, we take the current time and
+ * subtract that duration so that we get again an absolute
+ * time stamp that will result in correct performance
+ * calculations.
+ *
+ * @param rh handle for reading
+ * @param timestamp where to write the deserialized timestamp
+ * @return GNUNET_OK on success
+ */
+static int
+read_start_time (struct GNUNET_BIO_ReadHandle *rh,
+ struct GNUNET_TIME_Absolute *timestamp)
+{
+ struct GNUNET_TIME_Relative dur;
+ if (GNUNET_OK !=
+ GNUNET_BIO_read_int64 (rh, &dur.value))
+ return GNUNET_SYSERR;
+ *timestamp = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (),
+ dur);
+ return GNUNET_OK;
+}
+
/**
* Using the given serialization filename, try to deserialize
(GNUNET_OK !=
GNUNET_BIO_read_int64 (rh, &ret->expirationTime.value)) ||
(GNUNET_OK !=
- GNUNET_BIO_read_int64 (rh, &ret->start_time.value)) ||
+ read_start_time (rh, &ret->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16*1024)) ||
(GNUNET_OK !=
GNUNET_break (0);
goto cleanup;
}
- /* FIXME: adjust ret->start_time! */
ret->serialization = GNUNET_strdup (fn);
if (GNUNET_OK !=
GNUNET_BIO_read_string (rh, "nxt-filename", &filename, 16*1024))
(GNUNET_OK !=
GNUNET_BIO_write_int64 (wh, fi->expirationTime.value)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, fi->start_time.value)) ||
+ write_start_time (wh, fi->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_write_string (wh, fi->emsg)) ||
(GNUNET_OK !=
(GNUNET_OK !=
GNUNET_BIO_write_int64 (wh, uc->file_size)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, uc->start_time.value)) ||
+ write_start_time (wh, uc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) ||
( (uc->state == UNINDEX_STATE_FS_NOTIFY) &&
(GNUNET_OK !=
GNUNET_BIO_write_int64 (wh, dc->completed)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, dc->start_time.value)) ||
+ write_start_time (wh, dc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_write_int32 (wh, dc->anonymity)) ||
(GNUNET_OK !=
if ( (GNUNET_OK !=
GNUNET_BIO_write_string (wh, uris)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, sc->start_time.value)) ||
+ write_start_time (wh, sc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_write_string (wh, sc->emsg)) ||
(GNUNET_OK !=
(GNUNET_OK !=
GNUNET_BIO_read_int64 (rh, &uc->file_size)) ||
(GNUNET_OK !=
- GNUNET_BIO_read_int64 (rh, &uc->start_time.value)) ||
+ read_start_time (rh, &uc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_read_int32 (rh, &state)) )
goto cleanup;
(GNUNET_OK !=
GNUNET_BIO_read_int64 (rh, &dc->completed)) ||
(GNUNET_OK !=
- GNUNET_BIO_read_int64 (rh, &dc->start_time.value)) ||
+ read_start_time (rh, &dc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_read_int32 (rh, &dc->anonymity)) ||
(GNUNET_OK !=
(GNUNET_OK !=
GNUNET_BIO_read_int32 (rh, &num_pending)) )
goto cleanup;
- /* FIXME: adjust start_time.value */
dc->options = (enum GNUNET_FS_DownloadOptions) options;
dc->active = GNUNET_CONTAINER_multihashmap_create (16);
dc->has_finished = (int) status;
( (GNUNET_YES != GNUNET_FS_uri_test_ksk (sc->uri)) &&
(GNUNET_YES != GNUNET_FS_uri_test_sks (sc->uri)) ) ||
(GNUNET_OK !=
- GNUNET_BIO_read_int64 (rh, &sc->start_time.value)) ||
+ read_start_time (rh, &sc->start_time)) ||
(GNUNET_OK !=
GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10*1024)) ||
(GNUNET_OK !=
(GNUNET_OK !=
GNUNET_BIO_read_int32 (rh, &sc->anonymity)) )
goto cleanup;
- /* FIXME: adjust start_time.value */
sc->options = (enum GNUNET_FS_SearchOptions) options;
sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16);
GNUNET_snprintf (pbuf,