Add error handler for failing DNS requests; the Client should be able to take its...
authorWilfried Goesgens <dothebart@citadel.org>
Fri, 16 Sep 2011 18:39:36 +0000 (18:39 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Fri, 16 Sep 2011 18:39:36 +0000 (18:39 +0000)
citadel/event_client.c
citadel/event_client.h
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/smtp/serv_smtpeventclient.c

index a265f30..f1abcbe 100644 (file)
@@ -591,11 +591,11 @@ IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents)
        AsyncIO *IO = watcher->data;
        syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__);
        become_session(IO->CitContext);
-
+       assert(IO->DNSFail);
        switch (IO->DNSQuery->PostDNS(IO))
        {
        case eAbort:
-           ShutDownCLient(IO);
+               IO->DNSFail(IO);
        default:
            break;
        }
index de36f29..b2c368d 100644 (file)
@@ -102,6 +102,7 @@ struct AsyncIO {
                Terminate,    /* shutting down... */
                Timeout,      /* Timeout handler; may also be connection timeout */
                ConnFail,     /* What to do when one connection failed? */
+               DNSFail,      /* the dns lookup didn't work out. */
                ShutdownAbort,/* we're going down. make your piece. */ 
                NextDBOperation; /* Perform Database IO */
 
index ef811b7..18e4bdf 100644 (file)
@@ -145,6 +145,7 @@ typedef eNextState(*Pop3ClientHandler)(pop3aggr* RecvMsg);
 eNextState POP3_C_Shutdown(AsyncIO *IO);
 eNextState POP3_C_Timeout(AsyncIO *IO);
 eNextState POP3_C_ConnFail(AsyncIO *IO);
+eNextState POP3_C_DNSFail(AsyncIO *IO);
 eNextState POP3_C_DispatchReadDone(AsyncIO *IO);
 eNextState POP3_C_DispatchWriteDone(AsyncIO *IO);
 eNextState POP3_C_Terminate(AsyncIO *IO);
@@ -680,6 +681,14 @@ eNextState POP3_C_ConnFail(AsyncIO *IO)
        StrBufPlain(IO->ErrMsg, CKEY(POP3C_ReadErrors[pMsg->State]));
        return FailAggregationRun(IO);
 }
+eNextState POP3_C_DNSFail(AsyncIO *IO)
+{
+       pop3aggr *pMsg = (pop3aggr *)IO->Data;
+
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
+       StrBufPlain(IO->ErrMsg, CKEY(POP3C_ReadErrors[pMsg->State]));
+       return FailAggregationRun(IO);
+}
 eNextState POP3_C_Shutdown(AsyncIO *IO)
 {
        syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
@@ -836,6 +845,7 @@ int pop3_do_fetching(pop3aggr *cpptr)
        cpptr->IO.Terminate     = POP3_C_Terminate;
        cpptr->IO.LineReader    = POP3_C_ReadServerStatus;
        cpptr->IO.ConnFail      = POP3_C_ConnFail;
+       cpptr->IO.DNSFail       = POP3_C_DNSFail;
        cpptr->IO.Timeout       = POP3_C_Timeout;
        cpptr->IO.ShutdownAbort = POP3_C_Shutdown;
        
index 22c1862..0dbbf35 100644 (file)
@@ -110,6 +110,7 @@ eNextState SMTP_C_Timeout(AsyncIO *IO);
 eNextState SMTP_C_ConnFail(AsyncIO *IO);
 eNextState SMTP_C_DispatchReadDone(AsyncIO *IO);
 eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO);
+eNextState SMTP_C_DNSFail(AsyncIO *IO);
 eNextState SMTP_C_Terminate(AsyncIO *IO);
 eReadState SMTP_C_ReadServerStatus(AsyncIO *IO);
 
@@ -435,6 +436,7 @@ SmtpOutMsg *new_smtp_outmsg(OneQueItem *MyQItem,
        SendMsg->IO.Terminate     = SMTP_C_Terminate;
        SendMsg->IO.LineReader    = SMTP_C_ReadServerStatus;
        SendMsg->IO.ConnFail      = SMTP_C_ConnFail;
+       SendMsg->IO.DNSFail       = SMTP_C_DNSFail;
        SendMsg->IO.Timeout       = SMTP_C_Timeout;
        SendMsg->IO.ShutdownAbort = SMTP_C_Shutdown;
 
@@ -589,6 +591,14 @@ eNextState SMTP_C_ConnFail(AsyncIO *IO)
        StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
        return FailOneAttempt(IO);
 }
+eNextState SMTP_C_DNSFail(AsyncIO *IO)
+{
+       SmtpOutMsg *pMsg = IO->Data;
+
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
+       return FailOneAttempt(IO);
+}
 eNextState SMTP_C_Shutdown(AsyncIO *IO)
 {
        syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);