GNUNET_CRYPTO_hash (&block->derived_key,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
&query);
- fprintf (stderr,
- "Caching new version of block %s (expires %llu)\n",
- GNUNET_h2s (&query),
- (unsigned long long) expiration.abs_value_us);
+ fprintf (stderr, // GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Caching new version of block %s (expires %s)\n",
+ GNUNET_h2s (&query),
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
expiration = GNUNET_TIME_absolute_ntoh (block->expiration_time);
if (block_size > 64 * 65536)
{
/**
* Maximum number of queries pending at the same time.
*/
-#define THRESH 20
+#define THRESH 100
/**
* TIME_THRESH is in usecs. How quickly do we submit fresh queries.
*/
static unsigned int records;
+/**
+ * #GNUNET_YES if we have more work to be read from `stdin`.
+ */
+static int stdin_waiting;
+
/**
* Heap of all requests to perform, sorted by
* the time we should next do the request (i.e. by expires).
int32_t success,
const char *emsg)
{
+ static unsigned int pdot;
struct Request *req = cls;
req->qe = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Stored records under `%s'\n",
req->label);
+ pdot++;
+ if (0 == pdot % 1000)
+ fprintf (stderr, ".");
}
}
GNUNET_SCHEDULER_cancel (t);
t = NULL;
}
- if (NULL != ns)
- {
- GNUNET_NAMESTORE_disconnect (ns);
- ns = NULL;
- }
- if (NULL != ctx)
- {
- GNUNET_DNSSTUB_stop (ctx);
- ctx = NULL;
- }
while (NULL != (req = req_head))
{
GNUNET_CONTAINER_DLL_remove (req_head,
req_tail,
req);
+ if (NULL != req->qe)
+ GNUNET_NAMESTORE_cancel (req->qe);
free_request (req);
}
while (NULL != (req = GNUNET_CONTAINER_heap_remove_root (req_heap)))
{
req->hn = NULL;
+ if (NULL != req->qe)
+ GNUNET_NAMESTORE_cancel (req->qe);
free_request (req);
}
+ if (NULL != ns)
+ {
+ GNUNET_NAMESTORE_disconnect (ns);
+ ns = NULL;
+ }
+ if (NULL != ctx)
+ {
+ GNUNET_DNSSTUB_stop (ctx);
+ ctx = NULL;
+ }
if (NULL != req_heap)
{
GNUNET_CONTAINER_heap_destroy (req_heap);
}
+/**
+ * Begin processing hostnames from stdin.
+ *
+ * @param cls NULL
+ */
+static void
+process_stdin (void *cls);
+
+
+/**
+ * If applicable, continue processing from stdin.
+ */
+static void
+continue_stdin ()
+{
+ if ( (pending < THRESH) &&
+ (stdin_waiting) )
+ {
+ if (NULL != t)
+ GNUNET_SCHEDULER_cancel (t);
+ t = GNUNET_SCHEDULER_add_now (&process_stdin,
+ NULL);
+ }
+}
+
+
/**
* Function called if #GNUNET_NAMESTORE_records_lookup() failed.
* Continues resolution based on assumption namestore has no data.
"Failed to load data from namestore for `%s'\n",
req->label);
insert_sorted (req);
+ pending--;
+ continue_stdin ();
}
struct Request *req = cls;
req->qe = NULL;
+ pending--;
GNUNET_break (0 == memcmp (zone,
&req->zone->key,
sizeof (*zone)));
req->hostname,
GNUNET_STRINGS_absolute_time_to_string (req->expires));
insert_sorted (req);
+ continue_stdin ();
}
"Refusing invalid hostname `%s'\n",
hostname);
rejects++;
+ continue_stdin ();
return;
}
dot = strchr (hostname,
"Refusing invalid hostname `%s' (lacks '.')\n",
hostname);
rejects++;
+ continue_stdin ();
return;
}
for (zone = zone_head; NULL != zone; zone = zone->next)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Domain name `%s' not in ego list!\n",
dot + 1);
+ continue_stdin ();
return;
}
q.name = (char *) hostname;
"Failed to pack query for hostname `%s'\n",
hostname);
rejects++;
+ continue_stdin ();
return;
}
+ pending++;
req = GNUNET_new (struct Request);
req->zone = zone;
req->hostname = GNUNET_strdup (hostname);
static void
process_stdin (void *cls)
{
+ static unsigned int pdot;
char hn[256];
(void) cls;
t = NULL;
- GNUNET_IDENTITY_disconnect (id);
- id = NULL;
- while (NULL !=
- fgets (hn,
- sizeof (hn),
- stdin))
+ if (NULL != id)
+ {
+ GNUNET_IDENTITY_disconnect (id);
+ id = NULL;
+ }
+ if (NULL !=
+ fgets (hn,
+ sizeof (hn),
+ stdin))
{
if (strlen(hn) > 0)
hn[strlen(hn)-1] = '\0'; /* eat newline */
+ pdot++;
+ if (0 == pdot % 1000)
+ fprintf (stderr, ".");
queue (hn);
+ return;
}
+ stdin_waiting = GNUNET_NO;
+ fprintf (stderr, "\n");
+ t = GNUNET_SCHEDULER_add_now (&process_queue,
+ NULL);
}
{
if (NULL != zone_head)
{
+ stdin_waiting = GNUNET_YES;
t = GNUNET_SCHEDULER_add_now (&process_stdin,
NULL);
}