aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-18 12:53:33 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-18 12:53:33 +0000
commitd444bbf5a3388a1d7fd0eb433a89d96107bd4b1b (patch)
tree0e6f96e5b8b275ae7b8c4a4987c2ca7be379b762 /src
parent692f2f397846dcd90309ca94ad982187f03d8e70 (diff)
downloadgnunet-d444bbf5a3388a1d7fd0eb433a89d96107bd4b1b.tar.gz
gnunet-d444bbf5a3388a1d7fd0eb433a89d96107bd4b1b.zip
fix leak
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs_publish.c82
1 files changed, 22 insertions, 60 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 777450ec2..e60960b95 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -38,33 +38,6 @@
38 38
39 39
40/** 40/**
41 * Context for "ds_put_cont".
42 */
43struct PutContCtx
44{
45 /**
46 * Current publishing context.
47 */
48 struct GNUNET_FS_PublishContext *pc;
49
50 /**
51 * Specific file with the block.
52 */
53 struct GNUNET_FS_FileInformation *p;
54
55 /**
56 * Function to run next, if any (can be NULL).
57 */
58 GNUNET_SCHEDULER_Task cont;
59
60 /**
61 * Closure for cont.
62 */
63 void *cont_cls;
64};
65
66
67/**
68 * Fill in all of the generic fields for 41 * Fill in all of the generic fields for
69 * a publish event and call the callback. 42 * a publish event and call the callback.
70 * 43 *
@@ -150,7 +123,7 @@ publish_cleanup (void *cls,
150 * Function called by the datastore API with 123 * Function called by the datastore API with
151 * the result from the PUT request. 124 * the result from the PUT request.
152 * 125 *
153 * @param cls our closure 126 * @param cls the 'struct GNUNET_FS_PublishContext'
154 * @param success GNUNET_OK on success 127 * @param success GNUNET_OK on success
155 * @param msg error message (or NULL) 128 * @param msg error message (or NULL)
156 */ 129 */
@@ -159,49 +132,44 @@ ds_put_cont (void *cls,
159 int success, 132 int success,
160 const char *msg) 133 const char *msg)
161{ 134{
162 struct PutContCtx *pcc = cls; 135 struct GNUNET_FS_PublishContext *pc = cls;
163 struct GNUNET_FS_ProgressInfo pi; 136 struct GNUNET_FS_ProgressInfo pi;
164 137
165 pcc->pc->qre = NULL; 138 pc->qre = NULL;
166 if (GNUNET_SYSERR == pcc->pc->in_network_wait) 139 if (GNUNET_SYSERR == pc->in_network_wait)
167 { 140 {
168 /* we were aborted in the meantime, finish shutdown! */ 141 /* we were aborted in the meantime, finish shutdown! */
169 GNUNET_SCHEDULER_add_continuation (&publish_cleanup, 142 GNUNET_SCHEDULER_add_continuation (&publish_cleanup,
170 pcc->pc, 143 pc,
171 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 144 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
172 GNUNET_free (pcc);
173 return; 145 return;
174 } 146 }
175 GNUNET_assert (GNUNET_YES == pcc->pc->in_network_wait); 147 GNUNET_assert (GNUNET_YES == pc->in_network_wait);
176 pcc->pc->in_network_wait = GNUNET_NO; 148 pc->in_network_wait = GNUNET_NO;
177 if (GNUNET_SYSERR == success) 149 if (GNUNET_SYSERR == success)
178 { 150 {
179 GNUNET_asprintf (&pcc->p->emsg, 151 GNUNET_asprintf (&pc->fi_pos->emsg,
180 _("Publishing failed: %s"), 152 _("Publishing failed: %s"),
181 msg); 153 msg);
182 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; 154 pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
183 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; 155 pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
184 pi.value.publish.specifics.error.message = pcc->p->emsg; 156 pi.value.publish.specifics.error.message = pc->fi_pos->emsg;
185 pcc->p->client_info = GNUNET_FS_publish_make_status_ (&pi, pcc->pc, pcc->p, 0); 157 pc->fi_pos->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0);
186 if ( (pcc->p->is_directory == GNUNET_NO) && 158 if ( (pc->fi_pos->is_directory == GNUNET_NO) &&
187 (pcc->p->filename != NULL) && 159 (pc->fi_pos->filename != NULL) &&
188 (pcc->p->data.file.do_index == GNUNET_YES) ) 160 (pc->fi_pos->data.file.do_index == GNUNET_YES) )
189 { 161 {
190 /* run unindex to clean up */ 162 /* run unindex to clean up */
191 GNUNET_FS_unindex_start (pcc->pc->h, 163 GNUNET_FS_unindex_start (pc->h,
192 pcc->p->filename, 164 pc->fi_pos->filename,
193 NULL); 165 NULL);
194 } 166 }
195 } 167 }
196 if (NULL != pcc->cont) 168 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task);
197 { 169 pc->upload_task
198 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pcc->pc->upload_task); 170 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
199 pcc->pc->upload_task 171 &GNUNET_FS_publish_main_,
200 = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, 172 pc);
201 pcc->cont,
202 pcc->cont_cls);
203 }
204 GNUNET_free (pcc);
205} 173}
206 174
207 175
@@ -546,7 +514,6 @@ block_proc (void *cls,
546{ 514{
547 struct GNUNET_FS_PublishContext *pc = cls; 515 struct GNUNET_FS_PublishContext *pc = cls;
548 struct GNUNET_FS_FileInformation *p; 516 struct GNUNET_FS_FileInformation *p;
549 struct PutContCtx * dpc_cls;
550 struct OnDemandBlock odb; 517 struct OnDemandBlock odb;
551 518
552 p = pc->fi_pos; 519 p = pc->fi_pos;
@@ -566,11 +533,6 @@ block_proc (void *cls,
566 533
567 GNUNET_assert (GNUNET_NO == pc->in_network_wait); 534 GNUNET_assert (GNUNET_NO == pc->in_network_wait);
568 pc->in_network_wait = GNUNET_YES; 535 pc->in_network_wait = GNUNET_YES;
569 dpc_cls = GNUNET_malloc(sizeof(struct PutContCtx));
570 dpc_cls->cont = &GNUNET_FS_publish_main_;
571 dpc_cls->cont_cls = pc;
572 dpc_cls->pc = pc;
573 dpc_cls->p = p;
574 if ( (! p->is_directory) && 536 if ( (! p->is_directory) &&
575 (GNUNET_YES == p->data.file.do_index) && 537 (GNUNET_YES == p->data.file.do_index) &&
576 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK) ) 538 (type == GNUNET_BLOCK_TYPE_FS_DBLOCK) )
@@ -598,7 +560,7 @@ block_proc (void *cls,
598 -2, 1, 560 -2, 1,
599 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 561 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
600 &ds_put_cont, 562 &ds_put_cont,
601 dpc_cls); 563 pc);
602 return; 564 return;
603 } 565 }
604#if DEBUG_PUBLISH 566#if DEBUG_PUBLISH
@@ -622,7 +584,7 @@ block_proc (void *cls,
622 -2, 1, 584 -2, 1,
623 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 585 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
624 &ds_put_cont, 586 &ds_put_cont,
625 dpc_cls); 587 pc);
626} 588}
627 589
628 590