aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_list_indexed.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-24 21:45:44 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-24 21:45:44 +0000
commit47d7779091557516cda70ab9038dc2d460b0b3bb (patch)
tree2c8a334a40268d8b3717332a9d7278909830fab7 /src/fs/fs_list_indexed.c
parent267b8b5e0e264627f334a18ae1bf3f3a88ff2e32 (diff)
downloadgnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.tar.gz
gnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.zip
giving client API option for auto-retry, making more often use of transmit_and_get_response API and removing auto-retry code where enhanced client API can be used for it
Diffstat (limited to 'src/fs/fs_list_indexed.c')
-rw-r--r--src/fs/fs_list_indexed.c59
1 files changed, 10 insertions, 49 deletions
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index 1a404a078..9ef205ca0 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -155,50 +155,6 @@ handle_index_info (void *cls,
155 155
156 156
157/** 157/**
158 * Transmit the request to get a list of all
159 * indexed files to the "FS" service.
160 *
161 * @param cls closure (of type "struct GetIndexedContext*")
162 * @param size number of bytes availabe in buf
163 * @param buf where to write the message, NULL on error
164 * @return number of bytes written to buf
165 */
166static size_t
167transmit_get_indexed (void *cls,
168 size_t size,
169 void *buf)
170{
171 struct GetIndexedContext *gic = cls;
172 struct GNUNET_MessageHeader *hdr;
173
174 if (NULL == buf)
175 {
176 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
177 _("Failed to transmit `%s' request to `%s' service.\n"),
178 "GET_INDEXED",
179 "fs");
180 GNUNET_SCHEDULER_add_continuation (gic->h->sched,
181 GNUNET_NO,
182 gic->cont,
183 gic->cont_cls,
184 GNUNET_SCHEDULER_REASON_TIMEOUT);
185 GNUNET_CLIENT_disconnect (gic->client);
186 GNUNET_free (gic);
187 return 0;
188 }
189 GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
190 hdr = buf;
191 hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
192 hdr->type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET);
193 GNUNET_CLIENT_receive (gic->client,
194 &handle_index_info,
195 gic,
196 GNUNET_CONSTANTS_SERVICE_TIMEOUT);
197 return sizeof (struct GNUNET_MessageHeader);
198}
199
200
201/**
202 * Iterate over all indexed files. 158 * Iterate over all indexed files.
203 * 159 *
204 * @param h handle to the file sharing subsystem 160 * @param h handle to the file sharing subsystem
@@ -218,6 +174,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
218{ 174{
219 struct GNUNET_CLIENT_Connection *client; 175 struct GNUNET_CLIENT_Connection *client;
220 struct GetIndexedContext *gic; 176 struct GetIndexedContext *gic;
177 struct GNUNET_MessageHeader msg;
221 178
222 client = GNUNET_CLIENT_connect (h->sched, 179 client = GNUNET_CLIENT_connect (h->sched,
223 "fs", 180 "fs",
@@ -242,11 +199,15 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
242 gic->iterator_cls = iterator_cls; 199 gic->iterator_cls = iterator_cls;
243 gic->cont = cont; 200 gic->cont = cont;
244 gic->cont_cls = cont_cls; 201 gic->cont_cls = cont_cls;
245 GNUNET_CLIENT_notify_transmit_ready (client, 202 msg.size = htons (sizeof (struct GNUNET_MessageHeader));
246 sizeof (struct GNUNET_MessageHeader), 203 msg.type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET);
247 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 204 GNUNET_assert (GNUNET_OK ==
248 &transmit_get_indexed, 205 GNUNET_CLIENT_transmit_and_get_response (client,
249 gic); 206 &msg,
207 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
208 GNUNET_YES,
209 &handle_index_info,
210 gic));
250} 211}
251 212
252/* end of fs_list_indexed.c */ 213/* end of fs_list_indexed.c */