[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11169 - in gnunet: . src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11169 - in gnunet: . src/fs |
Date: |
Mon, 3 May 2010 22:42:18 +0200 |
Author: grothoff
Date: 2010-05-03 22:42:18 +0200 (Mon, 03 May 2010)
New Revision: 11169
Modified:
gnunet/TODO
gnunet/src/fs/fs.c
Log:
fixing start time serialization
Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-05-03 20:39:50 UTC (rev 11168)
+++ gnunet/TODO 2010-05-03 20:42:18 UTC (rev 11169)
@@ -1,5 +1,7 @@
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!
@@ -7,12 +9,9 @@
=> 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!
Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c 2010-05-03 20:39:50 UTC (rev 11168)
+++ gnunet/src/fs/fs.c 2010-05-03 20:42:18 UTC (rev 11169)
@@ -426,8 +426,8 @@
*/
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;
@@ -470,8 +470,60 @@
}
+/**
+ * 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
* the file-information tree associated with it.
*
@@ -537,7 +589,7 @@
(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 !=
@@ -648,7 +700,6 @@
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))
@@ -862,7 +913,7 @@
(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 !=
@@ -1217,7 +1268,7 @@
(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) &&
@@ -1376,7 +1427,7 @@
(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 !=
@@ -1512,7 +1563,7 @@
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 !=
@@ -1600,7 +1651,7 @@
(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;
@@ -2050,7 +2101,7 @@
(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 !=
@@ -2060,7 +2111,6 @@
(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;
@@ -2176,7 +2226,7 @@
( (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 !=
@@ -2186,7 +2236,6 @@
(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,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11169 - in gnunet: . src/fs,
gnunet <=