aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-18 13:39:38 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-18 13:39:38 +0000
commit126599828d31d47e1914bc2f26fb60fb2998e42c (patch)
tree91a3f8c5c011f5e22e980ce296d11c8b34fbfc22 /src
parent13884089ce15342e60c1fb009018dde016b786a5 (diff)
downloadgnunet-126599828d31d47e1914bc2f26fb60fb2998e42c.tar.gz
gnunet-126599828d31d47e1914bc2f26fb60fb2998e42c.zip
fixing leak, reducing amount of allocation
Diffstat (limited to 'src')
-rw-r--r--src/datastore/datastore_api.c238
1 files changed, 118 insertions, 120 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 12ec8bf05..c91884aa0 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -30,6 +30,57 @@
30#include "gnunet_datastore_service.h" 30#include "gnunet_datastore_service.h"
31#include "datastore.h" 31#include "datastore.h"
32 32
33
34/**
35 * Context for processing status messages.
36 */
37struct StatusContext
38{
39 /**
40 * Continuation to call with the status.
41 */
42 GNUNET_DATASTORE_ContinuationWithStatus cont;
43
44 /**
45 * Closure for cont.
46 */
47 void *cont_cls;
48
49};
50
51
52/**
53 * Context for processing result messages.
54 */
55struct ResultContext
56{
57 /**
58 * Iterator to call with the result.
59 */
60 GNUNET_DATASTORE_Iterator iter;
61
62 /**
63 * Closure for iter.
64 */
65 void *iter_cls;
66
67};
68
69
70/**
71 * Context for a queue operation.
72 */
73union QueueContext
74{
75
76 struct StatusContext sc;
77
78 struct ResultContext rc;
79
80};
81
82
83
33/** 84/**
34 * Entry in our priority queue. 85 * Entry in our priority queue.
35 */ 86 */
@@ -54,15 +105,9 @@ struct GNUNET_DATASTORE_QueueEntry
54 /** 105 /**
55 * Response processor (NULL if we are not waiting for a response). 106 * Response processor (NULL if we are not waiting for a response).
56 * This struct should be used for the closure, function-specific 107 * This struct should be used for the closure, function-specific
57 * arguments can be passed via 'client_ctx'. 108 * arguments can be passed via 'qc'.
58 */ 109 */
59 GNUNET_CLIENT_MessageHandler response_proc; 110 GNUNET_CLIENT_MessageHandler response_proc;
60
61 /**
62 * Specific context (variable argument that
63 * can be used by the response processor).
64 */
65 void *client_ctx;
66 111
67 /** 112 /**
68 * Function to call after transmission of the request. 113 * Function to call after transmission of the request.
@@ -75,6 +120,11 @@ struct GNUNET_DATASTORE_QueueEntry
75 void *cont_cls; 120 void *cont_cls;
76 121
77 /** 122 /**
123 * Context for the operation.
124 */
125 union QueueContext qc;
126
127 /**
78 * Task for timeout signalling. 128 * Task for timeout signalling.
79 */ 129 */
80 GNUNET_SCHEDULER_TaskIdentifier task; 130 GNUNET_SCHEDULER_TaskIdentifier task;
@@ -308,7 +358,7 @@ timeout_queue_entry (void *cls,
308 * (if other requests of higher priority are in the queue) 358 * (if other requests of higher priority are in the queue)
309 * @param timeout timeout for the operation 359 * @param timeout timeout for the operation
310 * @param response_proc function to call with replies (can be NULL) 360 * @param response_proc function to call with replies (can be NULL)
311 * @param client_ctx client context (NOT a closure for response_proc) 361 * @param qc client context (NOT a closure for response_proc)
312 * @return NULL if the queue is full (and this entry was dropped) 362 * @return NULL if the queue is full (and this entry was dropped)
313 */ 363 */
314static struct GNUNET_DATASTORE_QueueEntry * 364static struct GNUNET_DATASTORE_QueueEntry *
@@ -318,7 +368,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
318 unsigned int max_queue_size, 368 unsigned int max_queue_size,
319 struct GNUNET_TIME_Relative timeout, 369 struct GNUNET_TIME_Relative timeout,
320 GNUNET_CLIENT_MessageHandler response_proc, 370 GNUNET_CLIENT_MessageHandler response_proc,
321 void *client_ctx) 371 const union QueueContext *qc)
322{ 372{
323 struct GNUNET_DATASTORE_QueueEntry *ret; 373 struct GNUNET_DATASTORE_QueueEntry *ret;
324 struct GNUNET_DATASTORE_QueueEntry *pos; 374 struct GNUNET_DATASTORE_QueueEntry *pos;
@@ -336,7 +386,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
336 ret = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_QueueEntry) + msize); 386 ret = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_QueueEntry) + msize);
337 ret->h = h; 387 ret->h = h;
338 ret->response_proc = response_proc; 388 ret->response_proc = response_proc;
339 ret->client_ctx = client_ctx; 389 ret->qc = *qc;
340 ret->timeout = GNUNET_TIME_relative_to_absolute (timeout); 390 ret->timeout = GNUNET_TIME_relative_to_absolute (timeout);
341 ret->priority = queue_priority; 391 ret->priority = queue_priority;
342 ret->max_queue = max_queue_size; 392 ret->max_queue = max_queue_size;
@@ -516,26 +566,6 @@ process_queue (struct GNUNET_DATASTORE_Handle *h)
516} 566}
517 567
518 568
519
520
521/**
522 * Context for processing status messages.
523 */
524struct StatusContext
525{
526 /**
527 * Continuation to call with the status.
528 */
529 GNUNET_DATASTORE_ContinuationWithStatus cont;
530
531 /**
532 * Closure for cont.
533 */
534 void *cont_cls;
535
536};
537
538
539/** 569/**
540 * Dummy continuation used to do nothing (but be non-zero). 570 * Dummy continuation used to do nothing (but be non-zero).
541 * 571 *
@@ -582,7 +612,7 @@ process_status_message (void *cls,
582{ 612{
583 struct GNUNET_DATASTORE_QueueEntry *qe = cls; 613 struct GNUNET_DATASTORE_QueueEntry *qe = cls;
584 struct GNUNET_DATASTORE_Handle *h = qe->h; 614 struct GNUNET_DATASTORE_Handle *h = qe->h;
585 struct StatusContext *rc = qe->client_ctx; 615 struct StatusContext rc = qe->qc.sc;
586 const struct StatusMessage *sm; 616 const struct StatusMessage *sm;
587 const char *emsg; 617 const char *emsg;
588 int32_t status; 618 int32_t status;
@@ -604,10 +634,9 @@ process_status_message (void *cls,
604 GNUNET_break (0); 634 GNUNET_break (0);
605 h->retry_time = GNUNET_TIME_UNIT_ZERO; 635 h->retry_time = GNUNET_TIME_UNIT_ZERO;
606 do_disconnect (h); 636 do_disconnect (h);
607 rc->cont (rc->cont_cls, 637 rc.cont (rc.cont_cls,
608 GNUNET_SYSERR, 638 GNUNET_SYSERR,
609 _("Error reading response from datastore service")); 639 _("Error reading response from datastore service"));
610 GNUNET_free (rc);
611 return; 640 return;
612 } 641 }
613 sm = (const struct StatusMessage*) msg; 642 sm = (const struct StatusMessage*) msg;
@@ -634,10 +663,9 @@ process_status_message (void *cls,
634 (int) status, 663 (int) status,
635 emsg); 664 emsg);
636#endif 665#endif
637 rc->cont (rc->cont_cls, 666 rc.cont (rc.cont_cls,
638 status, 667 status,
639 emsg); 668 emsg);
640 GNUNET_free (rc);
641 process_queue (h); 669 process_queue (h);
642} 670}
643 671
@@ -683,10 +711,10 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
683 GNUNET_DATASTORE_ContinuationWithStatus cont, 711 GNUNET_DATASTORE_ContinuationWithStatus cont,
684 void *cont_cls) 712 void *cont_cls)
685{ 713{
686 struct StatusContext *scont;
687 struct GNUNET_DATASTORE_QueueEntry *qe; 714 struct GNUNET_DATASTORE_QueueEntry *qe;
688 struct DataMessage *dm; 715 struct DataMessage *dm;
689 size_t msize; 716 size_t msize;
717 union QueueContext qc;
690 718
691#if DEBUG_DATASTORE 719#if DEBUG_DATASTORE
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -696,12 +724,11 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
696#endif 724#endif
697 msize = sizeof(struct DataMessage) + size; 725 msize = sizeof(struct DataMessage) + size;
698 GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE); 726 GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE);
699 scont = GNUNET_malloc (sizeof (struct StatusContext)); 727 qc.sc.cont = cont;
700 scont->cont = cont; 728 qc.sc.cont_cls = cont_cls;
701 scont->cont_cls = cont_cls;
702 qe = make_queue_entry (h, msize, 729 qe = make_queue_entry (h, msize,
703 queue_priority, max_queue_size, timeout, 730 queue_priority, max_queue_size, timeout,
704 &process_status_message, scont); 731 &process_status_message, &qc);
705 if (qe == NULL) 732 if (qe == NULL)
706 return NULL; 733 return NULL;
707 dm = (struct DataMessage* ) &qe[1]; 734 dm = (struct DataMessage* ) &qe[1];
@@ -752,7 +779,7 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h,
752{ 779{
753 struct GNUNET_DATASTORE_QueueEntry *qe; 780 struct GNUNET_DATASTORE_QueueEntry *qe;
754 struct ReserveMessage *rm; 781 struct ReserveMessage *rm;
755 struct StatusContext *scont; 782 union QueueContext qc;
756 783
757 if (cont == NULL) 784 if (cont == NULL)
758 cont = &drop_status_cont; 785 cont = &drop_status_cont;
@@ -762,12 +789,11 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h,
762 (unsigned long long) amount, 789 (unsigned long long) amount,
763 (unsigned int) entries); 790 (unsigned int) entries);
764#endif 791#endif
765 scont = GNUNET_malloc (sizeof (struct StatusContext)); 792 qc.sc.cont = cont;
766 scont->cont = cont; 793 qc.sc.cont_cls = cont_cls;
767 scont->cont_cls = cont_cls;
768 qe = make_queue_entry (h, sizeof(struct ReserveMessage), 794 qe = make_queue_entry (h, sizeof(struct ReserveMessage),
769 queue_priority, max_queue_size, timeout, 795 queue_priority, max_queue_size, timeout,
770 &process_status_message, scont); 796 &process_status_message, &qc);
771 if (qe == NULL) 797 if (qe == NULL)
772 return NULL; 798 return NULL;
773 rm = (struct ReserveMessage*) &qe[1]; 799 rm = (struct ReserveMessage*) &qe[1];
@@ -812,7 +838,7 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h,
812{ 838{
813 struct GNUNET_DATASTORE_QueueEntry *qe; 839 struct GNUNET_DATASTORE_QueueEntry *qe;
814 struct ReleaseReserveMessage *rrm; 840 struct ReleaseReserveMessage *rrm;
815 struct StatusContext *scont; 841 union QueueContext qc;
816 842
817 if (cont == NULL) 843 if (cont == NULL)
818 cont = &drop_status_cont; 844 cont = &drop_status_cont;
@@ -821,12 +847,11 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h,
821 "Asked to release reserve %d\n", 847 "Asked to release reserve %d\n",
822 rid); 848 rid);
823#endif 849#endif
824 scont = GNUNET_malloc (sizeof (struct StatusContext)); 850 qc.sc.cont = cont;
825 scont->cont = cont; 851 qc.sc.cont_cls = cont_cls;
826 scont->cont_cls = cont_cls;
827 qe = make_queue_entry (h, sizeof(struct ReleaseReserveMessage), 852 qe = make_queue_entry (h, sizeof(struct ReleaseReserveMessage),
828 queue_priority, max_queue_size, timeout, 853 queue_priority, max_queue_size, timeout,
829 &process_status_message, scont); 854 &process_status_message, &qc);
830 if (qe == NULL) 855 if (qe == NULL)
831 return NULL; 856 return NULL;
832 rrm = (struct ReleaseReserveMessage*) &qe[1]; 857 rrm = (struct ReleaseReserveMessage*) &qe[1];
@@ -868,7 +893,7 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h,
868{ 893{
869 struct GNUNET_DATASTORE_QueueEntry *qe; 894 struct GNUNET_DATASTORE_QueueEntry *qe;
870 struct UpdateMessage *um; 895 struct UpdateMessage *um;
871 struct StatusContext *scont; 896 union QueueContext qc;
872 897
873 if (cont == NULL) 898 if (cont == NULL)
874 cont = &drop_status_cont; 899 cont = &drop_status_cont;
@@ -879,12 +904,11 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h,
879 (unsigned int) priority, 904 (unsigned int) priority,
880 (unsigned long long) expiration.value); 905 (unsigned long long) expiration.value);
881#endif 906#endif
882 scont = GNUNET_malloc (sizeof (struct StatusContext)); 907 qc.sc.cont = cont;
883 scont->cont = cont; 908 qc.sc.cont_cls = cont_cls;
884 scont->cont_cls = cont_cls;
885 qe = make_queue_entry (h, sizeof(struct UpdateMessage), 909 qe = make_queue_entry (h, sizeof(struct UpdateMessage),
886 queue_priority, max_queue_size, timeout, 910 queue_priority, max_queue_size, timeout,
887 &process_status_message, scont); 911 &process_status_message, &qc);
888 if (qe == NULL) 912 if (qe == NULL)
889 return NULL; 913 return NULL;
890 um = (struct UpdateMessage*) &qe[1]; 914 um = (struct UpdateMessage*) &qe[1];
@@ -933,7 +957,7 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
933 struct GNUNET_DATASTORE_QueueEntry *qe; 957 struct GNUNET_DATASTORE_QueueEntry *qe;
934 struct DataMessage *dm; 958 struct DataMessage *dm;
935 size_t msize; 959 size_t msize;
936 struct StatusContext *scont; 960 union QueueContext qc;
937 961
938 if (cont == NULL) 962 if (cont == NULL)
939 cont = &drop_status_cont; 963 cont = &drop_status_cont;
@@ -943,14 +967,13 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
943 size, 967 size,
944 GNUNET_h2s (key)); 968 GNUNET_h2s (key));
945#endif 969#endif
946 scont = GNUNET_malloc (sizeof (struct StatusContext)); 970 qc.sc.cont = cont;
947 scont->cont = cont; 971 qc.sc.cont_cls = cont_cls;
948 scont->cont_cls = cont_cls;
949 msize = sizeof(struct DataMessage) + size; 972 msize = sizeof(struct DataMessage) + size;
950 GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE); 973 GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE);
951 qe = make_queue_entry (h, msize, 974 qe = make_queue_entry (h, msize,
952 queue_priority, max_queue_size, timeout, 975 queue_priority, max_queue_size, timeout,
953 &process_status_message, scont); 976 &process_status_message, &qc);
954 if (qe == NULL) 977 if (qe == NULL)
955 return NULL; 978 return NULL;
956 dm = (struct DataMessage*) &qe[1]; 979 dm = (struct DataMessage*) &qe[1];
@@ -970,25 +993,6 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
970} 993}
971 994
972 995
973
974/**
975 * Context for processing result messages.
976 */
977struct ResultContext
978{
979 /**
980 * Iterator to call with the result.
981 */
982 GNUNET_DATASTORE_Iterator iter;
983
984 /**
985 * Closure for iter.
986 */
987 void *iter_cls;
988
989};
990
991
992/** 996/**
993 * Type of a function to call when we receive a message 997 * Type of a function to call when we receive a message
994 * from the service. 998 * from the service.
@@ -1002,7 +1006,7 @@ process_result_message (void *cls,
1002{ 1006{
1003 struct GNUNET_DATASTORE_QueueEntry *qe = cls; 1007 struct GNUNET_DATASTORE_QueueEntry *qe = cls;
1004 struct GNUNET_DATASTORE_Handle *h = qe->h; 1008 struct GNUNET_DATASTORE_Handle *h = qe->h;
1005 struct ResultContext *rc = qe->client_ctx; 1009 struct ResultContext rc = qe->qc.rc;
1006 const struct DataMessage *dm; 1010 const struct DataMessage *dm;
1007 1011
1008 GNUNET_assert (h->queue_head == qe); 1012 GNUNET_assert (h->queue_head == qe);
@@ -1014,10 +1018,9 @@ process_result_message (void *cls,
1014#endif 1018#endif
1015 free_queue_entry (qe); 1019 free_queue_entry (qe);
1016 do_disconnect (h); 1020 do_disconnect (h);
1017 rc->iter (rc->iter_cls, 1021 rc.iter (rc.iter_cls,
1018 NULL, 0, NULL, 0, 0, 0, 1022 NULL, 0, NULL, 0, 0, 0,
1019 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1023 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1020 GNUNET_free (rc);
1021 return; 1024 return;
1022 } 1025 }
1023 if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) 1026 if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END)
@@ -1028,10 +1031,9 @@ process_result_message (void *cls,
1028 "Received end of result set\n"); 1031 "Received end of result set\n");
1029#endif 1032#endif
1030 free_queue_entry (qe); 1033 free_queue_entry (qe);
1031 rc->iter (rc->iter_cls, 1034 rc.iter (rc.iter_cls,
1032 NULL, 0, NULL, 0, 0, 0, 1035 NULL, 0, NULL, 0, 0, 0,
1033 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1036 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1034 GNUNET_free (rc);
1035 process_queue (h); 1037 process_queue (h);
1036 return; 1038 return;
1037 } 1039 }
@@ -1043,10 +1045,9 @@ process_result_message (void *cls,
1043 free_queue_entry (qe); 1045 free_queue_entry (qe);
1044 h->retry_time = GNUNET_TIME_UNIT_ZERO; 1046 h->retry_time = GNUNET_TIME_UNIT_ZERO;
1045 do_disconnect (h); 1047 do_disconnect (h);
1046 rc->iter (rc->iter_cls, 1048 rc.iter (rc.iter_cls,
1047 NULL, 0, NULL, 0, 0, 0, 1049 NULL, 0, NULL, 0, 0, 0,
1048 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1050 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1049 GNUNET_free (rc);
1050 return; 1051 return;
1051 } 1052 }
1052 dm = (const struct DataMessage*) msg; 1053 dm = (const struct DataMessage*) msg;
@@ -1058,15 +1059,15 @@ process_result_message (void *cls,
1058 ntohl(dm->size), 1059 ntohl(dm->size),
1059 GNUNET_h2s(&dm->key)); 1060 GNUNET_h2s(&dm->key));
1060#endif 1061#endif
1061 rc->iter (rc->iter_cls, 1062 rc.iter (rc.iter_cls,
1062 &dm->key, 1063 &dm->key,
1063 ntohl(dm->size), 1064 ntohl(dm->size),
1064 &dm[1], 1065 &dm[1],
1065 ntohl(dm->type), 1066 ntohl(dm->type),
1066 ntohl(dm->priority), 1067 ntohl(dm->priority),
1067 ntohl(dm->anonymity), 1068 ntohl(dm->anonymity),
1068 GNUNET_TIME_absolute_ntoh(dm->expiration), 1069 GNUNET_TIME_absolute_ntoh(dm->expiration),
1069 GNUNET_ntohll(dm->uid)); 1070 GNUNET_ntohll(dm->uid));
1070} 1071}
1071 1072
1072 1073
@@ -1096,19 +1097,18 @@ GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
1096{ 1097{
1097 struct GNUNET_DATASTORE_QueueEntry *qe; 1098 struct GNUNET_DATASTORE_QueueEntry *qe;
1098 struct GNUNET_MessageHeader *m; 1099 struct GNUNET_MessageHeader *m;
1099 struct ResultContext *rcont; 1100 union QueueContext qc;
1100 1101
1101#if DEBUG_DATASTORE 1102#if DEBUG_DATASTORE
1102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1103 "Asked to get random entry in %llu ms\n", 1104 "Asked to get random entry in %llu ms\n",
1104 (unsigned long long) timeout.value); 1105 (unsigned long long) timeout.value);
1105#endif 1106#endif
1106 rcont = GNUNET_malloc (sizeof (struct ResultContext)); 1107 qc.rc.iter = iter;
1107 rcont->iter = iter; 1108 qc.rc.iter_cls = iter_cls;
1108 rcont->iter_cls = iter_cls;
1109 qe = make_queue_entry (h, sizeof(struct GNUNET_MessageHeader), 1109 qe = make_queue_entry (h, sizeof(struct GNUNET_MessageHeader),
1110 queue_priority, max_queue_size, timeout, 1110 queue_priority, max_queue_size, timeout,
1111 &process_result_message, rcont); 1111 &process_result_message, &qc);
1112 if (qe == NULL) 1112 if (qe == NULL)
1113 return NULL; 1113 return NULL;
1114 m = (struct GNUNET_MessageHeader*) &qe[1]; 1114 m = (struct GNUNET_MessageHeader*) &qe[1];
@@ -1153,7 +1153,7 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
1153{ 1153{
1154 struct GNUNET_DATASTORE_QueueEntry *qe; 1154 struct GNUNET_DATASTORE_QueueEntry *qe;
1155 struct GetMessage *gm; 1155 struct GetMessage *gm;
1156 struct ResultContext *rcont; 1156 union QueueContext qc;
1157 1157
1158#if DEBUG_DATASTORE 1158#if DEBUG_DATASTORE
1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1161,12 +1161,11 @@ GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
1161 (unsigned int) type, 1161 (unsigned int) type,
1162 GNUNET_h2s (key)); 1162 GNUNET_h2s (key));
1163#endif 1163#endif
1164 rcont = GNUNET_malloc (sizeof (struct ResultContext)); 1164 qc.rc.iter = iter;
1165 rcont->iter = iter; 1165 qc.rc.iter_cls = iter_cls;
1166 rcont->iter_cls = iter_cls;
1167 qe = make_queue_entry (h, sizeof(struct GetMessage), 1166 qe = make_queue_entry (h, sizeof(struct GetMessage),
1168 queue_priority, max_queue_size, timeout, 1167 queue_priority, max_queue_size, timeout,
1169 &process_result_message, rcont); 1168 &process_result_message, &qc);
1170 if (qe == NULL) 1169 if (qe == NULL)
1171 return NULL; 1170 return NULL;
1172 gm = (struct GetMessage*) &qe[1]; 1171 gm = (struct GetMessage*) &qe[1];
@@ -1199,7 +1198,7 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
1199 int more) 1198 int more)
1200{ 1199{
1201 struct GNUNET_DATASTORE_QueueEntry *qe = h->queue_head; 1200 struct GNUNET_DATASTORE_QueueEntry *qe = h->queue_head;
1202 struct ResultContext *rc = qe->client_ctx; 1201 struct ResultContext rc = qe->qc.rc;
1203 1202
1204 GNUNET_assert (NULL != qe); 1203 GNUNET_assert (NULL != qe);
1205 GNUNET_assert (&process_result_message == qe->response_proc); 1204 GNUNET_assert (&process_result_message == qe->response_proc);
@@ -1214,10 +1213,9 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
1214 free_queue_entry (qe); 1213 free_queue_entry (qe);
1215 h->retry_time = GNUNET_TIME_UNIT_ZERO; 1214 h->retry_time = GNUNET_TIME_UNIT_ZERO;
1216 do_disconnect (h); 1215 do_disconnect (h);
1217 rc->iter (rc->iter_cls, 1216 rc.iter (rc.iter_cls,
1218 NULL, 0, NULL, 0, 0, 0, 1217 NULL, 0, NULL, 0, 0, 0,
1219 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1218 GNUNET_TIME_UNIT_ZERO_ABS, 0);
1220 GNUNET_free (rc);
1221} 1219}
1222 1220
1223 1221