- we use the c-ares callback to parse the DNS reply and put the reply to our callback
- we then set a zero-timer with the call to continue our flow
- we return / unstack c-ares
- we then do the a/aaaa record lookup without having another ares lookup in our stack
this circumvents double dns lookups.
}
}
-
+void
+IO_postdns_callback(struct ev_loop *loop, ev_timer *watcher, int revents)
+{
+ AsyncIO *IO = watcher->data;
+ IO->PostDNS(IO);
+}
eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_rw_timeout)
{
eNextState NextState;
ev_timer conn_fail,
- rw_timeout;
+ rw_timeout,
+ unwind_stack_timeout;
ev_io recv_event,
send_event,
conn_event;
double conn_timeout,
double first_rw_timeout,
int ReadFirst);
+void IO_postdns_callback(struct ev_loop *loop, ev_timer *watcher, int revents);
int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);
+void QueryCbDone(AsyncIO *IO);
void StopClient(AsyncIO *IO);
IO->DNSStatus = status;
if (status == ARES_SUCCESS)
IO->DNS_CB(arg, abuf, alen);
+ else
+ IO->DNSStatus = status;
/// ev_io_stop(event_base, &IO->dns_io_event);
-
- IO->PostDNS(IO);
+
+ ev_timer_init(&IO->unwind_stack_timeout,
+ IO_postdns_callback, 0.0, 0);
+ IO->unwind_stack_timeout.data = IO;
+ ev_timer_start(event_base, &IO->unwind_stack_timeout);
+}
+
+void QueryCbDone(AsyncIO *IO)
+{
+ ev_timer_stop(event_base, &IO->unwind_stack_timeout);
}
{
SmtpOutMsg * SendMsg = IO->Data;
+ QueryCbDone(IO);
+
CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
SendMsg->IO.ErrMsg = SendMsg->MyQEntry->StatusMessage;
if ((StrLength(SendMsg) > 0) &&
ChrPtr(SendMsg)[StrLength(SendMsg) - 1] != '\n') {
CtdlLogPrintf(CTDL_WARNING,
- "SMTP client[%ld]: Possible problem: message did not "
+ "SMTP client[%d]: Possible problem: message did not "
"correctly terminate. (expecting 0x10, got 0x%02x)\n",
MsgCount, //yes uncool, but best choice here...
ChrPtr(SendMsg)[StrLength(SendMsg) - 1] );