diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-02-01 08:48:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-02-01 08:48:47 +0000 |
commit | 309276a88d1e57dffbea0014dc0708726c2e9376 (patch) | |
tree | 285ffccfe3cf9f69c7f3f537d80e473e8f087cc9 /src/fs/test_gnunet_service_fs_migration.c | |
parent | 4785f9c53cad18c14a20e9341b86b97f1021a574 (diff) | |
download | gnunet-309276a88d1e57dffbea0014dc0708726c2e9376.tar.gz gnunet-309276a88d1e57dffbea0014dc0708726c2e9376.zip |
-fix non-terminating index test --- do not remove file early
Diffstat (limited to 'src/fs/test_gnunet_service_fs_migration.c')
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 7ffa94a98..2bc53540c 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c | |||
@@ -55,6 +55,14 @@ static struct GNUNET_TIME_Absolute start_time; | |||
55 | static struct GNUNET_TESTBED_Operation *op; | 55 | static struct GNUNET_TESTBED_Operation *op; |
56 | 56 | ||
57 | 57 | ||
58 | struct DownloadContext | ||
59 | { | ||
60 | char *fn; | ||
61 | |||
62 | struct GNUNET_FS_Uri *uri; | ||
63 | }; | ||
64 | |||
65 | |||
58 | static void | 66 | static void |
59 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 67 | do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
60 | { | 68 | { |
@@ -88,10 +96,17 @@ static void | |||
88 | do_download (void *cls, | 96 | do_download (void *cls, |
89 | const char *emsg) | 97 | const char *emsg) |
90 | { | 98 | { |
91 | struct GNUNET_FS_Uri *uri = cls; | 99 | struct DownloadContext *dc = cls; |
100 | struct GNUNET_FS_Uri *uri = dc->uri; | ||
92 | 101 | ||
93 | GNUNET_TESTBED_operation_done (op); | 102 | GNUNET_TESTBED_operation_done (op); |
94 | op = NULL; | 103 | op = NULL; |
104 | if (NULL != dc->fn) | ||
105 | { | ||
106 | GNUNET_DISK_directory_remove (dc->fn); | ||
107 | GNUNET_free (dc->fn); | ||
108 | } | ||
109 | GNUNET_free (dc); | ||
95 | if (NULL != emsg) | 110 | if (NULL != emsg) |
96 | { | 111 | { |
97 | GNUNET_SCHEDULER_shutdown (); | 112 | GNUNET_SCHEDULER_shutdown (); |
@@ -113,18 +128,19 @@ do_download (void *cls, | |||
113 | static void | 128 | static void |
114 | stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 129 | stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
115 | { | 130 | { |
116 | struct GNUNET_FS_Uri *uri = cls; | 131 | struct DownloadContext *dc = cls; |
117 | 132 | ||
118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n"); | 133 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n"); |
119 | op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, uri); | 134 | op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, dc); |
120 | GNUNET_assert (NULL != op); | 135 | GNUNET_assert (NULL != op); |
121 | } | 136 | } |
122 | 137 | ||
123 | 138 | ||
124 | static void | 139 | static void |
125 | do_wait (void *cls, const struct GNUNET_FS_Uri *uri) | 140 | do_wait (void *cls, const struct GNUNET_FS_Uri *uri, |
141 | const char *fn) | ||
126 | { | 142 | { |
127 | struct GNUNET_FS_Uri *d; | 143 | struct DownloadContext *dc; |
128 | 144 | ||
129 | if (NULL == uri) | 145 | if (NULL == uri) |
130 | { | 146 | { |
@@ -135,8 +151,11 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri) | |||
135 | return; | 151 | return; |
136 | } | 152 | } |
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); |
138 | d = GNUNET_FS_uri_dup (uri); | 154 | dc = GNUNET_malloc (sizeof (struct DownloadContext)); |
139 | (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, d); | 155 | dc->uri = GNUNET_FS_uri_dup (uri); |
156 | if (NULL != fn) | ||
157 | dc->fn = GNUNET_strdup (fn); | ||
158 | (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, dc); | ||
140 | } | 159 | } |
141 | 160 | ||
142 | 161 | ||