diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 08:20:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 08:20:01 +0000 |
commit | 30a97db21ef69a23348edf56fa0c93c5062b8868 (patch) | |
tree | f733e3bffa7c9f573272c243e39ee81d7a0aac5b /src/fs/fs_publish_ublock.c | |
parent | 807da33f44a415ddceda1feffd33b047557b0447 (diff) | |
download | gnunet-30a97db21ef69a23348edf56fa0c93c5062b8868.tar.gz gnunet-30a97db21ef69a23348edf56fa0c93c5062b8868.zip |
-fix SKS publishing in simulate-only mode
Diffstat (limited to 'src/fs/fs_publish_ublock.c')
-rw-r--r-- | src/fs/fs_publish_ublock.c | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/src/fs/fs_publish_ublock.c b/src/fs/fs_publish_ublock.c index 25213f2ca..4399b8c8e 100644 --- a/src/fs/fs_publish_ublock.c +++ b/src/fs/fs_publish_ublock.c | |||
@@ -108,11 +108,17 @@ struct GNUNET_FS_PublishUblockContext | |||
108 | * Handle for active datastore operation. | 108 | * Handle for active datastore operation. |
109 | */ | 109 | */ |
110 | struct GNUNET_DATASTORE_QueueEntry *qre; | 110 | struct GNUNET_DATASTORE_QueueEntry *qre; |
111 | |||
112 | /** | ||
113 | * Task to run continuation asynchronously. | ||
114 | */ | ||
115 | GNUNET_SCHEDULER_TaskIdentifier task; | ||
116 | |||
111 | }; | 117 | }; |
112 | 118 | ||
113 | 119 | ||
114 | /** | 120 | /** |
115 | * Continuation of "GNUNET_FS_publish_ublock_". | 121 | * Continuation of #GNUNET_FS_publish_ublock_(). |
116 | * | 122 | * |
117 | * @param cls closure of type "struct GNUNET_FS_PublishUblockContext*" | 123 | * @param cls closure of type "struct GNUNET_FS_PublishUblockContext*" |
118 | * @param success GNUNET_SYSERR on failure (including timeout/queue drop) | 124 | * @param success GNUNET_SYSERR on failure (including timeout/queue drop) |
@@ -138,6 +144,24 @@ ublock_put_cont (void *cls, | |||
138 | 144 | ||
139 | 145 | ||
140 | /** | 146 | /** |
147 | * Run the continuation. | ||
148 | * | ||
149 | * @param cls the `struct GNUNET_FS_PublishUblockContext *` | ||
150 | * @param tc scheduler context | ||
151 | */ | ||
152 | static void | ||
153 | run_cont (void *cls, | ||
154 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
155 | { | ||
156 | struct GNUNET_FS_PublishUblockContext *uc = cls; | ||
157 | |||
158 | uc->task = GNUNET_SCHEDULER_NO_TASK; | ||
159 | uc->cont (uc->cont_cls, NULL); | ||
160 | GNUNET_free (uc); | ||
161 | } | ||
162 | |||
163 | |||
164 | /** | ||
141 | * Publish a UBlock. | 165 | * Publish a UBlock. |
142 | * | 166 | * |
143 | * @param h handle to the file sharing subsystem | 167 | * @param h handle to the file sharing subsystem |
@@ -258,14 +282,26 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h, | |||
258 | uc = GNUNET_new (struct GNUNET_FS_PublishUblockContext); | 282 | uc = GNUNET_new (struct GNUNET_FS_PublishUblockContext); |
259 | uc->cont = cont; | 283 | uc->cont = cont; |
260 | uc->cont_cls = cont_cls; | 284 | uc->cont_cls = cont_cls; |
261 | uc->qre = | 285 | if (NULL != dsh) |
262 | GNUNET_DATASTORE_put (dsh, 0, &query, | 286 | { |
263 | ulen + slen + mdsize + sizeof (struct UBlock), | 287 | uc->qre = |
264 | ub_enc, GNUNET_BLOCK_TYPE_FS_UBLOCK, | 288 | GNUNET_DATASTORE_put (dsh, 0, &query, |
265 | bo->content_priority, bo->anonymity_level, | 289 | ulen + slen + mdsize + sizeof (struct UBlock), |
266 | bo->replication_level, bo->expiration_time, | 290 | ub_enc, |
267 | -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 291 | GNUNET_BLOCK_TYPE_FS_UBLOCK, |
268 | &ublock_put_cont, uc); | 292 | bo->content_priority, |
293 | bo->anonymity_level, | ||
294 | bo->replication_level, | ||
295 | bo->expiration_time, | ||
296 | -2, 1, | ||
297 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
298 | &ublock_put_cont, uc); | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | uc->task = GNUNET_SCHEDULER_add_now (&run_cont, | ||
303 | uc); | ||
304 | } | ||
269 | return uc; | 305 | return uc; |
270 | } | 306 | } |
271 | 307 | ||
@@ -278,6 +314,11 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h, | |||
278 | void | 314 | void |
279 | GNUNET_FS_publish_ublock_cancel_ (struct GNUNET_FS_PublishUblockContext *uc) | 315 | GNUNET_FS_publish_ublock_cancel_ (struct GNUNET_FS_PublishUblockContext *uc) |
280 | { | 316 | { |
281 | GNUNET_DATASTORE_cancel (uc->qre); | 317 | if (NULL != uc->qre) |
318 | GNUNET_DATASTORE_cancel (uc->qre); | ||
319 | if (GNUNET_SCHEDULER_NO_TASK != uc->task) | ||
320 | GNUNET_SCHEDULER_cancel (uc->task); | ||
282 | GNUNET_free (uc); | 321 | GNUNET_free (uc); |
283 | } | 322 | } |
323 | |||
324 | /* end of fs_publish_ublock.c */ | ||