- we shouldn't close our FD if we want to continue using it later on after doing i.e. database io.
-void StopClientWatchers(AsyncIO *IO)
+void StopClientWatchers(AsyncIO *IO, int CloseFD)
{
ev_timer_stop (event_base, &IO->rw_timeout);
ev_timer_stop(event_base, &IO->conn_fail);
{
ev_timer_stop (event_base, &IO->rw_timeout);
ev_timer_stop(event_base, &IO->conn_fail);
ev_io_stop(event_base, &IO->send_event);
ev_io_stop(event_base, &IO->recv_event);
ev_io_stop(event_base, &IO->send_event);
ev_io_stop(event_base, &IO->recv_event);
- if (IO->SendBuf.fd != 0) {
+ if (CloseFD && (IO->SendBuf.fd > 0)) {
+ IO->SendBuf.fd = -1;
+ IO->RecvBuf.fd = -1;
- IO->SendBuf.fd = 0;
- IO->RecvBuf.fd = 0;
}
void StopCurlWatchers(AsyncIO *IO)
}
void StopCurlWatchers(AsyncIO *IO)
EVM_syslog(LOG_DEBUG, "EVENT Terminating \n");
EVM_syslog(LOG_DEBUG, "EVENT Terminating \n");
- StopClientWatchers(IO);
+ StopClientWatchers(IO, 1);
if (IO->DNS.Channel != NULL) {
ares_destroy(IO->DNS.Channel);
if (IO->DNS.Channel != NULL) {
ares_destroy(IO->DNS.Channel);
}
else if (rc < 0) {
if (errno != EAGAIN) {
}
else if (rc < 0) {
if (errno != EAGAIN) {
- StopClientWatchers(IO);
+ StopClientWatchers(IO, 1);
EV_syslog(LOG_DEBUG,
"EVENT: Socket Invalid! [%d] [%s] [%d]\n",
errno, strerror(errno), IO->SendBuf.fd);
EV_syslog(LOG_DEBUG,
"EVENT: Socket Invalid! [%d] [%s] [%d]\n",
errno, strerror(errno), IO->SendBuf.fd);
} else if (nbytes == -1) {
if (errno != EAGAIN) {
// FD is gone. kick it.
} else if (nbytes == -1) {
if (errno != EAGAIN) {
// FD is gone. kick it.
- StopClientWatchers(IO);
+ StopClientWatchers(IO, 1);
EV_syslog(LOG_DEBUG,
"EVENT: Socket Invalid! [%d] [%s] [%d]\n",
errno, strerror(errno), IO->SendBuf.fd);
EV_syslog(LOG_DEBUG,
"EVENT: Socket Invalid! [%d] [%s] [%d]\n",
errno, strerror(errno), IO->SendBuf.fd);
void StopClient(AsyncIO *IO);
void StopClient(AsyncIO *IO);
-void StopClientWatchers(AsyncIO *IO);
+void StopClientWatchers(AsyncIO *IO, int CloseFD);
void SetNextTimeout(AsyncIO *IO, double timeout);
void SetNextTimeout(AsyncIO *IO, double timeout);
EVP3CM_syslog(LOG_DEBUG, "Converting message...");
RecvMsg->CurrMsg->Msg =
convert_internet_message_buf(&RecvMsg->IO.ReadMsg->MsgBuf);
EVP3CM_syslog(LOG_DEBUG, "Converting message...");
RecvMsg->CurrMsg->Msg =
convert_internet_message_buf(&RecvMsg->IO.ReadMsg->MsgBuf);
- StopClientWatchers(IO);
+ StopClientWatchers(IO, 0);
return QueueDBOperation(&RecvMsg->IO, POP3C_SaveMsg);
}
return QueueDBOperation(&RecvMsg->IO, POP3C_SaveMsg);
}
* - connection timeout
* - dns lookup failed
*/
* - connection timeout
* - dns lookup failed
*/
- StopClientWatchers(IO);
+ StopClientWatchers(IO, 1);
if (Msg->pCurrRelay != NULL)
Msg->pCurrRelay = Msg->pCurrRelay->Next;
if (Msg->pCurrRelay != NULL)
Msg->pCurrRelay = Msg->pCurrRelay->Next;