diff options
Diffstat (limited to 'src/zonemaster/gnunet-service-zonemaster-monitor.c')
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster-monitor.c | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster-monitor.c b/src/zonemaster/gnunet-service-zonemaster-monitor.c index 3392a19d7..748a0f342 100644 --- a/src/zonemaster/gnunet-service-zonemaster-monitor.c +++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "gnunet_namestore_service.h" | 29 | #include "gnunet_namestore_service.h" |
30 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
31 | 31 | ||
32 | |||
33 | #define LOG_STRERROR_FILE(kind, syscall, \ | 32 | #define LOG_STRERROR_FILE(kind, syscall, \ |
34 | filename) GNUNET_log_from_strerror_file (kind, "util", \ | 33 | filename) GNUNET_log_from_strerror_file (kind, "util", \ |
35 | syscall, \ | 34 | syscall, \ |
@@ -58,7 +57,6 @@ | |||
58 | */ | 57 | */ |
59 | #define DHT_GNS_REPLICATION_LEVEL 5 | 58 | #define DHT_GNS_REPLICATION_LEVEL 5 |
60 | 59 | ||
61 | |||
62 | /** | 60 | /** |
63 | * Handle for DHT PUT activity triggered from the namestore monitor. | 61 | * Handle for DHT PUT activity triggered from the namestore monitor. |
64 | */ | 62 | */ |
@@ -197,39 +195,6 @@ dht_put_monitor_continuation (void *cls) | |||
197 | 195 | ||
198 | 196 | ||
199 | /** | 197 | /** |
200 | * Convert namestore records from the internal format to that | ||
201 | * suitable for publication (removes private records, converts | ||
202 | * to absolute expiration time). | ||
203 | * | ||
204 | * @param rd input records | ||
205 | * @param rd_count size of the @a rd and @a rd_public arrays | ||
206 | * @param rd_public where to write the converted records | ||
207 | * @return number of records written to @a rd_public | ||
208 | */ | ||
209 | static unsigned int | ||
210 | convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, | ||
211 | unsigned int rd_count, | ||
212 | struct GNUNET_GNSRECORD_Data *rd_public) | ||
213 | { | ||
214 | struct GNUNET_TIME_Absolute now; | ||
215 | unsigned int rd_public_count; | ||
216 | |||
217 | rd_public_count = 0; | ||
218 | now = GNUNET_TIME_absolute_get (); | ||
219 | for (unsigned int i = 0; i < rd_count; i++) | ||
220 | { | ||
221 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) | ||
222 | continue; | ||
223 | if ((0 == (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) && | ||
224 | (rd[i].expiration_time < now.abs_value_us)) | ||
225 | continue; /* record already expired, skip it */ | ||
226 | rd_public[rd_public_count++] = rd[i]; | ||
227 | } | ||
228 | return rd_public_count; | ||
229 | } | ||
230 | |||
231 | |||
232 | /** | ||
233 | * Store GNS records in the DHT. | 198 | * Store GNS records in the DHT. |
234 | * | 199 | * |
235 | * @param key key of the zone | 200 | * @param key key of the zone |
@@ -244,16 +209,14 @@ perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
244 | const char *label, | 209 | const char *label, |
245 | const struct GNUNET_GNSRECORD_Data *rd_public, | 210 | const struct GNUNET_GNSRECORD_Data *rd_public, |
246 | unsigned int rd_public_count, | 211 | unsigned int rd_public_count, |
212 | struct GNUNET_TIME_Absolute expire, | ||
247 | struct DhtPutActivity *ma) | 213 | struct DhtPutActivity *ma) |
248 | { | 214 | { |
249 | struct GNUNET_GNSRECORD_Block *block; | 215 | struct GNUNET_GNSRECORD_Block *block; |
250 | struct GNUNET_HashCode query; | 216 | struct GNUNET_HashCode query; |
251 | struct GNUNET_TIME_Absolute expire; | ||
252 | size_t block_size; | 217 | size_t block_size; |
253 | struct GNUNET_DHT_PutHandle *ret; | 218 | struct GNUNET_DHT_PutHandle *ret; |
254 | 219 | ||
255 | expire = GNUNET_GNSRECORD_record_get_expiration_time (rd_public_count, | ||
256 | rd_public); | ||
257 | if (cache_keys) | 220 | if (cache_keys) |
258 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_create2 (key, | 221 | GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_create2 (key, |
259 | expire, | 222 | expire, |
@@ -301,7 +264,6 @@ perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
301 | return ret; | 264 | return ret; |
302 | } | 265 | } |
303 | 266 | ||
304 | |||
305 | /** | 267 | /** |
306 | * Process a record that was stored in the namestore | 268 | * Process a record that was stored in the namestore |
307 | * (invoked by the monitor). | 269 | * (invoked by the monitor). |
@@ -322,6 +284,8 @@ handle_monitor_event (void *cls, | |||
322 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; | 284 | struct GNUNET_GNSRECORD_Data rd_public[rd_count]; |
323 | unsigned int rd_public_count; | 285 | unsigned int rd_public_count; |
324 | struct DhtPutActivity *ma; | 286 | struct DhtPutActivity *ma; |
287 | struct GNUNET_TIME_Absolute expire; | ||
288 | char *emsg; | ||
325 | 289 | ||
326 | (void) cls; | 290 | (void) cls; |
327 | GNUNET_STATISTICS_update (statistics, | 291 | GNUNET_STATISTICS_update (statistics, |
@@ -334,9 +298,21 @@ handle_monitor_event (void *cls, | |||
334 | label); | 298 | label); |
335 | /* filter out records that are not public, and convert to | 299 | /* filter out records that are not public, and convert to |
336 | absolute expiration time. */ | 300 | absolute expiration time. */ |
337 | rd_public_count = convert_records_for_export (rd, | 301 | if (GNUNET_OK != GNUNET_GNSRECORD_convert_records_for_export (label, |
338 | rd_count, | 302 | rd, |
339 | rd_public); | 303 | rd_count, |
304 | rd_public, | ||
305 | &rd_public_count, | ||
306 | &expire, | ||
307 | &emsg)) | ||
308 | { | ||
309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
310 | "Zonemaster-monitor failed: %s\n", emsg); | ||
311 | GNUNET_free (emsg); | ||
312 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | ||
313 | 1); | ||
314 | return; /* nothing to do */ | ||
315 | } | ||
340 | if (0 == rd_public_count) | 316 | if (0 == rd_public_count) |
341 | { | 317 | { |
342 | GNUNET_NAMESTORE_zone_monitor_next (zmon, | 318 | GNUNET_NAMESTORE_zone_monitor_next (zmon, |
@@ -347,8 +323,9 @@ handle_monitor_event (void *cls, | |||
347 | ma->start_date = GNUNET_TIME_absolute_get (); | 323 | ma->start_date = GNUNET_TIME_absolute_get (); |
348 | ma->ph = perform_dht_put (zone, | 324 | ma->ph = perform_dht_put (zone, |
349 | label, | 325 | label, |
350 | rd, | 326 | rd_public, |
351 | rd_count, | 327 | rd_public_count, |
328 | expire, | ||
352 | ma); | 329 | ma); |
353 | if (NULL == ma->ph) | 330 | if (NULL == ma->ph) |
354 | { | 331 | { |