- char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
- struct GNUNET_SERVER_TransmitContext *tc;
-
- tc = GNUNET_SERVER_transmit_context_create (client);
- pos = hosts;
- while (pos != NULL)
- {
- if ((only == NULL) ||
- (0 ==
- memcmp (only, &pos->identity,
- sizeof (struct GNUNET_PeerIdentity))))
- {
- change_host_trust (&pos->identity, trust_change);
- hs = 0;
- im = (struct InfoMessage *) buf;
- if (pos->hello != NULL)
- {
- hs = GNUNET_HELLO_size (pos->hello);
- GNUNET_assert (hs <
- GNUNET_SERVER_MAX_MESSAGE_SIZE -
- sizeof (struct InfoMessage));
- memcpy (&im[1], pos->hello, hs);
- }
- im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
- im->header.size = htons (sizeof (struct InfoMessage) + hs);
- im->trust = htonl (pos->trust);
- im->peer = pos->identity;
- GNUNET_SERVER_transmit_context_append_message (tc,
- &im->header);
- }
- pos = pos->next;
- }
- GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
- GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
- GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
-}
-
-
-/**
- * Write host-trust information to a file - flush the buffer entry!
- * Assumes synchronized access.
- */
-static void
-flush_trust (struct HostEntry *host)
-{
- char *fn;
- uint32_t trust;
-
- if (host->trust == host->disk_trust)
- return; /* unchanged */
- fn = get_trust_filename (&host->identity);
- if (host->trust == 0)
- {
- if ((0 != UNLINK (fn)) && (errno != ENOENT))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
- GNUNET_ERROR_TYPE_BULK, "unlink", fn);
- }
- else
- {
- trust = htonl (host->trust);
- if (sizeof(uint32_t) == GNUNET_DISK_fn_write (fn, &trust,
- sizeof(uint32_t),
- GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE
- | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ))
- host->disk_trust = host->trust;
- }
- GNUNET_free (fn);
-}
-
-/**
- * Call this method periodically to scan data/hosts for new hosts.
- */
-static void
-cron_flush_trust (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct HostEntry *pos;
-
- pos = hosts;
- while (pos != NULL)
- {
- flush_trust (pos);
- pos = pos->next;
- }
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
- GNUNET_SCHEDULER_add_delayed (tc->sched,
- TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
+ char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
+
+ hs = 0;
+ im = (struct InfoMessage *) buf;
+ if (pos->hello != NULL)
+ {
+ hs = GNUNET_HELLO_size (pos->hello);
+ GNUNET_assert (hs <
+ GNUNET_SERVER_MAX_MESSAGE_SIZE -
+ sizeof (struct InfoMessage));
+ memcpy (&im[1], pos->hello, hs);
+ }
+ im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
+ im->header.size = htons (sizeof (struct InfoMessage) + hs);
+ im->reserved = htonl (0);
+ im->peer = pos->identity;
+ GNUNET_SERVER_transmit_context_append_message (tc, &im->header);
+ return GNUNET_YES;