X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtpeventclient.c;h=5a4a51439eb3720da4df94f5a5dac0db6b8ca593;hb=a706083cbf719d326b15edd89ca01fc134492169;hp=2904e297f4eec92de60d42890e2da4dd89575957;hpb=03ca46c6f61467f62cb600d345383d70ca4fc953;p=citadel.git diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 2904e297f..5a4a51439 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -220,9 +220,12 @@ void DeleteSmtpOutMsg(void *v) free(Msg); } +eNextState SMTP_C_Timeout(void *Data); +eNextState SMTP_C_ConnFail(void *Data); eNextState SMTP_C_DispatchReadDone(void *Data); eNextState SMTP_C_DispatchWriteDone(void *Data); eNextState SMTP_C_Terminate(void *Data); +eNextState SMTP_C_MXLookup(void *Data); typedef eNextState (*SMTPReadHandler)(SmtpOutMsg *Msg); typedef eNextState (*SMTPSendHandler)(SmtpOutMsg *Msg); @@ -627,27 +630,20 @@ int connect_one_smtpsrv_xamine_result(void *Ctx) CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: connecting [%s:%s]!\n", SendMsg->n, SendMsg->mx_host, SendMsg->mx_port); + SendMsg->IO.SendBuf.Buf = NewStrBufPlain(NULL, 1024); + SendMsg->IO.RecvBuf.Buf = NewStrBufPlain(NULL, 1024); + SendMsg->IO.IOBuf = NewStrBuf(); + SendMsg->IO.ErrMsg = SendMsg->MyQEntry->StatusMessage; + + SendMsg->IO.SendBuf.fd = SendMsg->IO.RecvBuf.fd = SendMsg->IO.sock = sock_connect(SendMsg->mx_host, SendMsg->mx_port); StrBufPrintf(SendMsg->MyQEntry->StatusMessage, "Could not connect: %s", strerror(errno)); - if (SendMsg->IO.sock >= 0) - { - CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld:%ld]: connected!\n", SendMsg->n, SendMsg->IO.sock); - int fdflags; - fdflags = fcntl(SendMsg->IO.sock, F_GETFL); - if (fdflags < 0) - CtdlLogPrintf(CTDL_DEBUG, - "SMTP client[%ld]: unable to get socket flags! %s \n", - SendMsg->n, strerror(errno)); - fdflags = fdflags | O_NONBLOCK; - if (fcntl(SendMsg->IO.sock, F_SETFL, fdflags) < 0) - CtdlLogPrintf(CTDL_DEBUG, - "SMTP client[%ld]: unable to set socket nonblocking flags! %s \n", - SendMsg->n, strerror(errno)); - } + + if (SendMsg->IO.sock < 0) { if (errno > 0) { StrBufPlain(SendMsg->MyQEntry->StatusMessage, @@ -667,18 +663,19 @@ int connect_one_smtpsrv_xamine_result(void *Ctx) } - SendMsg->IO.SendBuf.Buf = NewStrBufPlain(NULL, 1024); - SendMsg->IO.RecvBuf.Buf = NewStrBufPlain(NULL, 1024); - SendMsg->IO.IOBuf = NewStrBuf(); InitEventIO(&SendMsg->IO, SendMsg, SMTP_C_DispatchReadDone, SMTP_C_DispatchWriteDone, SMTP_C_Terminate, + SMTP_C_Timeout, + SMTP_C_ConnFail, + SMTP_C_MXLookup, SMTP_C_ReadServerStatus, 1); return 0; } + eNextState SMTPC_read_greeting(SmtpOutMsg *SendMsg) { /* Process the SMTP greeting from the server */ @@ -1289,6 +1286,21 @@ eNextState SMTP_C_Terminate(void *Data) FinalizeMessageSend(pMsg); } + +eNextState SMTP_C_Timeout(void *Data) +{ + SmtpOutMsg *pMsg = Data; + FinalizeMessageSend(pMsg); + +} + +eNextState SMTP_C_ConnFail(void *Data) +{ + SmtpOutMsg *pMsg = Data; + FinalizeMessageSend(pMsg); + +} + eNextState SMTP_C_DispatchReadDone(void *Data) { SmtpOutMsg *pMsg = Data; @@ -1304,6 +1316,11 @@ eNextState SMTP_C_DispatchWriteDone(void *Data) } +eNextState SMTP_C_MXLookup(void *Data) +{ + +} + #endif CTDL_MODULE_INIT(smtp_eventclient)