From 9089cfa3847490329ee69419a94bee0e5ea5e1d3 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 30 Oct 2011 12:40:56 +0100 Subject: [PATCH] Logging enhancement & SMTP client fixes - generate & log out the event requestid - once we successfully delivered a message, we don't care about problems in the further flow. --- citadel/event_client.c | 50 ++++++++--------- citadel/event_client.h | 4 ++ .../modules/eventclient/serv_eventclient.c | 33 +++++++----- citadel/modules/smtp/serv_smtpeventclient.c | 54 ++++++++++--------- citadel/modules/smtp/smtp_clienthandlers.c | 31 ++++++++--- 5 files changed, 102 insertions(+), 70 deletions(-) diff --git a/citadel/event_client.c b/citadel/event_client.c index 57a644010..e360a124a 100644 --- a/citadel/event_client.c +++ b/citadel/event_client.c @@ -69,9 +69,9 @@ static void IO_abort_shutdown_callback(struct ev_loop *loop, ev_cleanup *watcher, int revents) { - syslog(LOG_DEBUG, "EVENT Q: %s\n", __FUNCTION__); - AsyncIO *IO = watcher->data; + EV_syslog(LOG_DEBUG, "EVENT Q: %s\n", __FUNCTION__); + assert(IO->ShutdownAbort); IO->ShutdownAbort(IO); } @@ -101,13 +101,13 @@ eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB) ev_cleanup_start(event_db, &IO->db_abort_by_shutdown); pthread_mutex_lock(&DBEventQueueMutex); - syslog(LOG_DEBUG, "DBEVENT Q\n"); + EVM_syslog(LOG_DEBUG, "DBEVENT Q\n"); i = ++evdb_count ; Put(DBInboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&DBEventQueueMutex); ev_async_send (event_db, &DBAddJob); - syslog(LOG_DEBUG, "DBEVENT Q Done.\n"); + EVM_syslog(LOG_DEBUG, "DBEVENT Q Done.\n"); return eDBQuery; } @@ -116,7 +116,7 @@ void ShutDownDBCLient(AsyncIO *IO) CitContext *Ctx =IO->CitContext; become_session(Ctx); - syslog(LOG_DEBUG, "DBEVENT\n"); + EVM_syslog(LOG_DEBUG, "DBEVENT\n"); ev_cleanup_stop(event_db, &IO->db_abort_by_shutdown); assert(IO->Terminate); @@ -130,7 +130,7 @@ void DB_PerformNext(struct ev_loop *loop, ev_idle *watcher, int revents) { AsyncIO *IO = watcher->data; - syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); become_session(IO->CitContext); ev_idle_stop(event_db, &IO->db_unwind_stack); @@ -193,13 +193,13 @@ eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB) ev_cleanup_start(event_base, &IO->abort_by_shutdown); pthread_mutex_lock(&EventQueueMutex); - syslog(LOG_DEBUG, "EVENT Q\n"); + EVM_syslog(LOG_DEBUG, "EVENT Q\n"); i = ++evbase_count; Put(InboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&EventQueueMutex); ev_async_send (event_base, &AddJob); - syslog(LOG_DEBUG, "EVENT Q Done.\n"); + EVM_syslog(LOG_DEBUG, "EVENT Q Done.\n"); return eSendReply; } @@ -215,13 +215,13 @@ eNextState QueueCurlContext(AsyncIO *IO) h->EvAttch = evcurl_handle_start; pthread_mutex_lock(&EventQueueMutex); - syslog(LOG_DEBUG, "EVENT Q\n"); + EVM_syslog(LOG_DEBUG, "EVENT Q\n"); i = ++evbase_count; Put(InboundEventQueue, IKEY(i), h, NULL); pthread_mutex_unlock(&EventQueueMutex); ev_async_send (event_base, &AddJob); - syslog(LOG_DEBUG, "EVENT Q Done.\n"); + EVM_syslog(LOG_DEBUG, "EVENT Q Done.\n"); return eSendReply; } @@ -264,7 +264,7 @@ void ShutDownCLient(AsyncIO *IO) CitContext *Ctx =IO->CitContext; become_session(Ctx); - syslog(LOG_DEBUG, "EVENT x %d\n", IO->SendBuf.fd); + EVM_syslog(LOG_DEBUG, "EVENT Terminating \n"); ev_cleanup_stop(event_base, &IO->abort_by_shutdown); StopClientWatchers(IO); @@ -679,9 +679,9 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents) return; } else if (nbytes == -1) { /// TODO: FD is gone. kick it. sock_buff_invoke_free(sb, errno); - syslog(LOG_DEBUG, - "EVENT: Socket Invalid! %s \n", - strerror(errno)); + EV_syslog(LOG_DEBUG, + "EVENT: Socket Invalid! %s \n", + strerror(errno)); ShutDownCLient(IO); return; } @@ -691,7 +691,7 @@ void IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents) { AsyncIO *IO = watcher->data; - syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); become_session(IO->CitContext); assert(IO->DNSFail); assert(IO->DNSQuery->PostDNS); @@ -716,23 +716,23 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r IPPROTO_TCP); if (IO->SendBuf.fd < 0) { - syslog(LOG_ERR, "EVENT: socket() failed: %s\n", strerror(errno)); + EV_syslog(LOG_ERR, "EVENT: socket() failed: %s\n", strerror(errno)); StrBufPrintf(IO->ErrMsg, "Failed to create socket: %s", strerror(errno)); return eAbort; } fdflags = fcntl(IO->SendBuf.fd, F_GETFL); if (fdflags < 0) { - syslog(LOG_DEBUG, - "EVENT: unable to get socket flags! %s \n", - strerror(errno)); + EV_syslog(LOG_DEBUG, + "EVENT: unable to get socket flags! %s \n", + strerror(errno)); StrBufPrintf(IO->ErrMsg, "Failed to get socket flags: %s", strerror(errno)); return eAbort; } fdflags = fdflags | O_NONBLOCK; if (fcntl(IO->SendBuf.fd, F_SETFL, fdflags) < 0) { - syslog(LOG_DEBUG, - "EVENT: unable to set socket nonblocking flags! %s \n", - strerror(errno)); + EV_syslog(LOG_DEBUG, + "EVENT: unable to set socket nonblocking flags! %s \n", + strerror(errno)); StrBufPrintf(IO->ErrMsg, "Failed to set socket flags: %s", strerror(errno)); close(IO->SendBuf.fd); IO->SendBuf.fd = IO->RecvBuf.fd = -1; @@ -760,13 +760,13 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r rc = connect(IO->SendBuf.fd, (struct sockaddr_in *)&IO->ConnectMe->Addr, sizeof(struct sockaddr_in)); if (rc >= 0){ - syslog(LOG_DEBUG, "connect() immediate success.\n"); + EVM_syslog(LOG_DEBUG, "connect() immediate success.\n"); set_start_callback(event_base, IO, 0); ev_timer_start(event_base, &IO->rw_timeout); return IO->NextState; } else if (errno == EINPROGRESS) { - syslog(LOG_DEBUG, "connect() have to wait now.\n"); + EVM_syslog(LOG_DEBUG, "connect() have to wait now.\n"); ev_io_init(&IO->conn_event, IO_connestd_callback, IO->SendBuf.fd, EV_READ|EV_WRITE); IO->conn_event.data = IO; @@ -781,7 +781,7 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r IO->conn_fail_immediate.data = IO; ev_idle_start(event_base, &IO->conn_fail_immediate); - syslog(LOG_ERR, "connect() failed: %s\n", strerror(errno)); + EV_syslog(LOG_ERR, "connect() failed: %s\n", strerror(errno)); StrBufPrintf(IO->ErrMsg, "Failed to connect: %s", strerror(errno)); return IO->NextState; } diff --git a/citadel/event_client.h b/citadel/event_client.h index 828ee0cb5..9564e5ba1 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -78,6 +78,7 @@ typedef struct _evcurl_request_data } evcurl_request_data; struct AsyncIO { + long ID; eNextState NextState; /* connection related */ @@ -139,6 +140,9 @@ typedef struct _IOAddHandler { IO_CallBack EvAttch; }IOAddHandler; +#define EV_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID, __VA_ARGS__) +#define EVM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]" FORMAT, IO->ID) + void FreeAsyncIOContents(AsyncIO *IO); eNextState NextDBOperation(AsyncIO *IO, IO_CallBack CB); diff --git a/citadel/modules/eventclient/serv_eventclient.c b/citadel/modules/eventclient/serv_eventclient.c index aa42fe754..da79852d1 100644 --- a/citadel/modules/eventclient/serv_eventclient.c +++ b/citadel/modules/eventclient/serv_eventclient.c @@ -60,6 +60,7 @@ ev_loop *event_base; +long EvIDSource = 0; /***************************************************************************** * libevent / curl integration * *****************************************************************************/ @@ -115,19 +116,19 @@ gotstatus(int nnrun) sta = msg->data.result; if (sta) { - syslog(LOG_ERR, "EVCURL: error description: %s\n", IO->HttpReq.errdesc); - syslog(LOG_ERR, "EVCURL: error performing request: %s\n", curl_easy_strerror(sta)); + EV_syslog(LOG_ERR, "EVCURL: error description: %s\n", IO->HttpReq.errdesc); + EV_syslog(LOG_ERR, "EVCURL: error performing request: %s\n", curl_easy_strerror(sta)); } sta = curl_easy_getinfo(chnd, CURLINFO_RESPONSE_CODE, &IO->HttpReq.httpcode); if (sta) - syslog(LOG_ERR, "EVCURL: error asking curl for response code from request: %s\n", curl_easy_strerror(sta)); - syslog(LOG_ERR, "EVCURL: http response code was %ld\n", (long)IO->HttpReq.httpcode); + EV_syslog(LOG_ERR, "EVCURL: error asking curl for response code from request: %s\n", curl_easy_strerror(sta)); + EV_syslog(LOG_ERR, "EVCURL: http response code was %ld\n", (long)IO->HttpReq.httpcode); curl_slist_free_all(IO->HttpReq.headers); msta = curl_multi_remove_handle(mhnd, chnd); if (msta) - syslog(LOG_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta)); + EV_syslog(LOG_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta)); curl_easy_cleanup(IO->HttpReq.chnd); IO->HttpReq.chnd = NULL; @@ -207,11 +208,11 @@ gotwatchsock(CURL *easy, curl_socket_t fd, int action, void *cglobal, void *vIO) AsyncIO *IO = (AsyncIO*) vIO; CURLcode sta; - syslog(LOG_DEBUG, "EVCURL: gotwatchsock called fd=%d action=%d\n", (int)fd, action); + EV_syslog(LOG_DEBUG, "EVCURL: gotwatchsock called fd=%d action=%d\n", (int)fd, action); if (IO == NULL) { sta = curl_easy_getinfo(easy, CURLINFO_PRIVATE, &f); if (sta) { - syslog(LOG_ERR, "EVCURL: error asking curl for private cookie of curl handle: %s\n", curl_easy_strerror(sta)); + EV_syslog(LOG_ERR, "EVCURL: error asking curl for private cookie of curl handle: %s\n", curl_easy_strerror(sta)); return -1; } IO = (AsyncIO *) f; @@ -230,10 +231,10 @@ gotwatchsock(CURL *easy, curl_socket_t fd, int action, void *cglobal, void *vIO) switch (action) { case CURL_POLL_NONE: - syslog(LOG_ERR,"EVCURL: called first time to register this sockwatcker\n"); + EVM_syslog(LOG_ERR,"EVCURL: called first time to register this sockwatcker\n"); break; case CURL_POLL_REMOVE: - syslog(LOG_ERR,"EVCURL: called last time to unregister this sockwatcher\n"); + EVM_syslog(LOG_ERR,"EVCURL: called last time to unregister this sockwatcher\n"); ev_io_stop(event_base, &IO->recv_event); ev_io_stop(event_base, &IO->send_event); break; @@ -294,14 +295,14 @@ int evcurl_init(AsyncIO *IO, CURLcode sta; CURL *chnd; - syslog(LOG_DEBUG, "EVCURL: evcurl_init called ms\n"); + EVM_syslog(LOG_DEBUG, "EVCURL: evcurl_init called ms\n"); IO->HttpReq.attached = 0; IO->SendDone = CallBack; IO->Terminate = Terminate; chnd = IO->HttpReq.chnd = curl_easy_init(); if (!chnd) { - syslog(LOG_ERR, "EVCURL: error initializing curl handle\n"); + EVM_syslog(LOG_ERR, "EVCURL: error initializing curl handle\n"); return 1; } @@ -337,7 +338,7 @@ int evcurl_init(AsyncIO *IO, OPT(INTERFACE, config.c_ip_addr); } /* point to a structure that points back to the perl structure and stuff */ - syslog(LOG_DEBUG, "EVCURL: Loading URL: %s\n", IO->ConnectMe->PlainUrl); + EV_syslog(LOG_DEBUG, "EVCURL: Loading URL: %s\n", IO->ConnectMe->PlainUrl); OPT(URL, IO->ConnectMe->PlainUrl); if (StrLength(IO->ConnectMe->CurlCreds)) { @@ -371,10 +372,10 @@ evcurl_handle_start(AsyncIO *IO) { CURLMcode msta; IO->NextState = eConnect; - syslog(LOG_DEBUG, "EVCURL: attaching to curl multi handle\n"); + EVM_syslog(LOG_DEBUG, "EVCURL: attaching to curl multi handle\n"); msta = curl_multi_add_handle(global.mhnd, IO->HttpReq.chnd); if (msta) - syslog(LOG_ERR, "EVCURL: error attaching to curl multi handle: %s\n", curl_multi_strerror(msta)); + EV_syslog(LOG_ERR, "EVCURL: error attaching to curl multi handle: %s\n", curl_multi_strerror(msta)); IO->HttpReq.attached = 1; ev_async_send (event_base, &WakeupCurl); return eReadMessage; @@ -433,6 +434,8 @@ static void QueueEventAddCallback(EV_P_ ev_async *w, int revents) while (GetNextHashPos(q, It, &len, &Key, &v)) { IOAddHandler *h = v; + if (h->IO->ID == 0) + h->IO->ID = EvIDSource++; h->EvAttch(h->IO); } DeleteHashPos(&It); @@ -552,6 +555,8 @@ static void DBQueueEventAddCallback(EV_P_ ev_async *w, int revents) { IOAddHandler *h = v; eNextState rc; + if (h->IO->ID == 0) + h->IO->ID = EvIDSource++; rc = h->EvAttch(h->IO); switch (rc) { diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 498d94c88..8eaa22ff5 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -125,7 +125,8 @@ eNextState get_one_mx_host_ip(AsyncIO *IO); ******************************************************************************/ void FinalizeMessageSend(SmtpOutMsg *Msg) { - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + AsyncIO *IO = &Msg->IO; + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); if (DecreaseQReference(Msg->MyQItem)) { @@ -168,6 +169,10 @@ void FinalizeMessageSend(SmtpOutMsg *Msg) eNextState FailOneAttempt(AsyncIO *IO) { SmtpOutMsg *SendMsg = IO->Data; + + if (SendMsg->MyQEntry->Status == 2) + return eAbort; + /* * possible ways here: * - connection timeout @@ -213,12 +218,12 @@ void SetConnectStatus(AsyncIO *IO) if (SendMsg->mx_host == NULL) SendMsg->mx_host = ""; - syslog(LOG_DEBUG, - "SMTP client[%ld]: connecting to %s [%s]:%d ...\n", - SendMsg->n, - SendMsg->mx_host, - buf, - SendMsg->IO.ConnectMe->Port); + EV_syslog(LOG_DEBUG, + "SMTP client[%ld]: connecting to %s [%s]:%d ...\n", + SendMsg->n, + SendMsg->mx_host, + buf, + SendMsg->IO.ConnectMe->Port); SendMsg->MyQEntry->Status = 5; StrBufPrintf(SendMsg->MyQEntry->StatusMessage, @@ -236,7 +241,7 @@ eNextState mx_connect_ip(AsyncIO *IO) { SmtpOutMsg *SendMsg = IO->Data; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); IO->ConnectMe = SendMsg->pCurrRelay; /* Bypass the ns lookup result like this: IO->Addr.sin_addr.s_addr = inet_addr("127.0.0.1"); */ @@ -299,14 +304,14 @@ eNextState get_one_mx_host_ip(AsyncIO *IO) InitC_ares_dns(IO); - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); - syslog(LOG_DEBUG, - "SMTP client[%ld]: looking up %s-Record %s : %d ...\n", - SendMsg->n, - (SendMsg->pCurrRelay->IPv6)? "aaaa": "a", - SendMsg->pCurrRelay->Host, - SendMsg->pCurrRelay->Port); + EV_syslog(LOG_DEBUG, + "SMTP client[%ld]: looking up %s-Record %s : %d ...\n", + SendMsg->n, + (SendMsg->pCurrRelay->IPv6)? "aaaa": "a", + SendMsg->pCurrRelay->Host, + SendMsg->pCurrRelay->Port); if (!QueueQuery((SendMsg->pCurrRelay->IPv6)? ns_t_aaaa : ns_t_a, SendMsg->pCurrRelay->Host, @@ -335,7 +340,7 @@ eNextState smtp_resolve_mx_record_done(AsyncIO *IO) QueryCbDone(IO); - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); pp = &SendMsg->Relay; while ((pp != NULL) && (*pp != NULL) && ((*pp)->Next != NULL)) pp = &(*pp)->Next; @@ -392,7 +397,7 @@ eNextState resolve_mx_records(AsyncIO *IO) { SmtpOutMsg * SendMsg = IO->Data; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); /* start resolving MX records here. */ if (!QueueQuery(ns_t_mx, SendMsg->node, @@ -507,8 +512,9 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem, void SMTPSetTimeout(eNextState NextTCPState, SmtpOutMsg *pMsg) { double Timeout = 0.0; + AsyncIO *IO = &pMsg->IO; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); switch (NextTCPState) { case eSendFile: @@ -545,7 +551,7 @@ void SMTPSetTimeout(eNextState NextTCPState, SmtpOutMsg *pMsg) } eNextState SMTP_C_DispatchReadDone(AsyncIO *IO) { - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); SmtpOutMsg *pMsg = IO->Data; eNextState rc; @@ -556,7 +562,7 @@ eNextState SMTP_C_DispatchReadDone(AsyncIO *IO) } eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO) { - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); SmtpOutMsg *pMsg = IO->Data; eNextState rc; @@ -573,7 +579,7 @@ eNextState SMTP_C_Terminate(AsyncIO *IO) { SmtpOutMsg *pMsg = IO->Data; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); FinalizeMessageSend(pMsg); return eAbort; } @@ -581,7 +587,7 @@ eNextState SMTP_C_Timeout(AsyncIO *IO) { SmtpOutMsg *pMsg = IO->Data; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State])); return FailOneAttempt(IO); } @@ -597,13 +603,13 @@ eNextState SMTP_C_DNSFail(AsyncIO *IO) { SmtpOutMsg *pMsg = IO->Data; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_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__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); SmtpOutMsg *pMsg = IO->Data; pMsg->MyQEntry->Status = 3; diff --git a/citadel/modules/smtp/smtp_clienthandlers.c b/citadel/modules/smtp/smtp_clienthandlers.c index 5c2743529..f83dbdc02 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.c +++ b/citadel/modules/smtp/smtp_clienthandlers.c @@ -107,8 +107,8 @@ #define SMTP_IS_STATE(WHICH_STATE) (ChrPtr(SendMsg->IO.IOBuf)[0] == WHICH_STATE) -#define SMTP_DBG_SEND() syslog(LOG_DEBUG, "SMTP client[%ld]: > %s\n", SendMsg->n, ChrPtr(SendMsg->IO.SendBuf.Buf)) -#define SMTP_DBG_READ() syslog(LOG_DEBUG, "SMTP client[%ld]: < %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf)) +#define SMTP_DBG_SEND() EV_syslog(LOG_DEBUG, "SMTP client[%ld]: > %s\n", SendMsg->n, ChrPtr(SendMsg->IO.SendBuf.Buf)) +#define SMTP_DBG_READ() EV_syslog(LOG_DEBUG, "SMTP client[%ld]: < %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf)) /*****************************************************************************/ @@ -117,6 +117,7 @@ eNextState SMTPC_read_greeting(SmtpOutMsg *SendMsg) { /* Process the SMTP greeting from the server */ + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('2')) { @@ -130,6 +131,7 @@ eNextState SMTPC_read_greeting(SmtpOutMsg *SendMsg) eNextState SMTPC_send_EHLO(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; /* At this point we know we are talking to a real SMTP server */ /* Do a EHLO command. If it fails, try the HELO command. */ @@ -142,6 +144,7 @@ eNextState SMTPC_send_EHLO(SmtpOutMsg *SendMsg) eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (SMTP_IS_STATE('2')) { @@ -157,6 +160,7 @@ eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *SendMsg) eNextState STMPC_send_HELO(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; StrBufPrintf(SendMsg->IO.SendBuf.Buf, "HELO %s\r\n", config.c_fqdn); @@ -166,6 +170,7 @@ eNextState STMPC_send_HELO(SmtpOutMsg *SendMsg) eNextState SMTPC_read_HELO_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('2')) { @@ -182,6 +187,7 @@ eNextState SMTPC_read_HELO_reply(SmtpOutMsg *SendMsg) eNextState SMTPC_send_auth(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; char buf[SIZ]; char encoded[1024]; @@ -206,6 +212,7 @@ eNextState SMTPC_send_auth(SmtpOutMsg *SendMsg) eNextState SMTPC_read_auth_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; /* Do an AUTH command if necessary */ SMTP_DBG_READ(); @@ -221,6 +228,7 @@ eNextState SMTPC_read_auth_reply(SmtpOutMsg *SendMsg) eNextState SMTPC_send_FROM(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; /* previous command succeeded, now try the MAIL FROM: command */ StrBufPrintf(SendMsg->IO.SendBuf.Buf, "MAIL FROM:<%s>\r\n", @@ -232,6 +240,7 @@ eNextState SMTPC_send_FROM(SmtpOutMsg *SendMsg) eNextState SMTPC_read_FROM_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('2')) { @@ -246,6 +255,7 @@ eNextState SMTPC_read_FROM_reply(SmtpOutMsg *SendMsg) eNextState SMTPC_send_RCPT(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; /* MAIL succeeded, now try the RCPT To: command */ StrBufPrintf(SendMsg->IO.SendBuf.Buf, "RCPT TO:<%s@%s>\r\n", @@ -258,6 +268,7 @@ eNextState SMTPC_send_RCPT(SmtpOutMsg *SendMsg) eNextState SMTPC_read_RCPT_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('2')) { @@ -271,6 +282,7 @@ eNextState SMTPC_read_RCPT_reply(SmtpOutMsg *SendMsg) eNextState SMTPC_send_DATAcmd(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; /* RCPT succeeded, now try the DATA command */ StrBufPlain(SendMsg->IO.SendBuf.Buf, HKEY("DATA\r\n")); @@ -281,6 +293,7 @@ eNextState SMTPC_send_DATAcmd(SmtpOutMsg *SendMsg) eNextState SMTPC_read_DATAcmd_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('3')) { @@ -322,6 +335,7 @@ eNextState SMTPC_send_terminate_data_body(SmtpOutMsg *SendMsg) eNextState SMTPC_read_data_body_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); if (!SMTP_IS_STATE('2')) { @@ -341,6 +355,7 @@ eNextState SMTPC_read_data_body_reply(SmtpOutMsg *SendMsg) eNextState SMTPC_send_QUIT(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; StrBufPlain(SendMsg->IO.SendBuf.Buf, HKEY("QUIT\r\n")); @@ -350,10 +365,11 @@ eNextState SMTPC_send_QUIT(SmtpOutMsg *SendMsg) eNextState SMTPC_read_QUIT_reply(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; SMTP_DBG_READ(); - syslog(LOG_INFO, "SMTP client[%ld]: delivery to <%s> @ <%s> (%s) succeeded\n", - SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name); + EV_syslog(LOG_INFO, "SMTP client[%ld]: delivery to <%s> @ <%s> (%s) succeeded\n", + SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name); return eTerminateConnection; } @@ -440,13 +456,14 @@ const ConstStr ReadErrors[eMaxSMTPC] = { int smtp_resolve_recipients(SmtpOutMsg *SendMsg) { + AsyncIO *IO = &SendMsg->IO; const char *ptr; char buf[1024]; int scan_done; int lp, rp; int i; - syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); + EV_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__); if ((SendMsg==NULL) || (SendMsg->MyQEntry == NULL) || @@ -460,8 +477,8 @@ int smtp_resolve_recipients(SmtpOutMsg *SendMsg) SendMsg->node, SendMsg->name); - syslog(LOG_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n", - SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name); + EV_syslog(LOG_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n", + SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name); /* If no envelope_from is supplied, extract one from the message */ SendMsg->envelope_from = ChrPtr(SendMsg->MyQItem->EnvelopeFrom); if ( (SendMsg->envelope_from == NULL) || -- 2.30.2