Fix nested scheduling with getdns_query -F and -I

+ add 1 millisecond delay between batched queries, just because...
This commit is contained in:
Willem Toorop 2019-01-23 11:41:00 +01:00
parent 0af9a629f4
commit 8980f5f5ee
1 changed files with 24 additions and 4 deletions

View File

@ -1181,7 +1181,7 @@ getdns_return_t do_the_call(void)
r = GETDNS_RETURN_GENERIC_ERROR;
break;
}
if (r == GETDNS_RETURN_GOOD && !batch_mode)
if (r == GETDNS_RETURN_GOOD && !batch_mode && !interactive)
getdns_context_run(context);
if (r != GETDNS_RETURN_GOOD)
fprintf(stderr, "An error occurred: %d '%s'\n", (int)r,
@ -1258,6 +1258,17 @@ static void incoming_request_handler(getdns_context *context,
void *userarg, getdns_transaction_t request_id);
void read_line_cb(void *userarg);
void read_line_tiny_delay_cb(void *userarg)
{
getdns_eventloop_event *read_line_ev = userarg;
loop->vmt->clear(loop, read_line_ev);
read_line_ev->timeout_cb = NULL;
read_line_ev->read_cb = read_line_cb;
loop->vmt->schedule(loop, fileno(fp), -1, read_line_ev);
}
void read_line_cb(void *userarg)
{
getdns_eventloop_event *read_line_ev = userarg;
@ -1312,11 +1323,20 @@ void read_line_cb(void *userarg)
(r != CONTINUE && r != CONTINUE_ERROR))
loop->vmt->clear(loop, read_line_ev);
else if (! query_file) {
else {
/* Tiny delay, to make sending queries less bursty with
* -F parameter.
*/
loop->vmt->clear(loop, read_line_ev);
read_line_ev->read_cb = NULL;
read_line_ev->timeout_cb = read_line_tiny_delay_cb;
loop->vmt->schedule(loop, fileno(fp), 1, read_line_ev);
if (! query_file) {
printf("> ");
fflush(stdout);
}
}
}
typedef struct dns_msg {
getdns_transaction_t request_id;