X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fevent_client.c;h=4a2f481a9cafc2412cc7c8fd2ed3b6d8e2a7e2aa;hb=cf7cb2463d47a4a9ed36c8d1c13f188418389437;hp=f2c44f11bfac520956fb6655b6dad65698563c6f;hpb=383e0142f8ba53c761df684268c845a5d4b13953;p=citadel.git diff --git a/citadel/event_client.c b/citadel/event_client.c index f2c44f11b..4a2f481a9 100644 --- a/citadel/event_client.c +++ b/citadel/event_client.c @@ -2,7 +2,7 @@ * * Copyright (c) 1998-2009 by the citadel.org team * - * This program is free software; you can redistribute it and/or modify + * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. @@ -227,18 +227,6 @@ eNextState QueueCurlContext(AsyncIO *IO) return eSendReply; } -int ShutDownEventQueue(void) -{ - pthread_mutex_lock(&DBEventQueueMutex); - ev_async_send (event_db, &DBExitEventLoop); - pthread_mutex_unlock(&DBEventQueueMutex); - - pthread_mutex_lock(&EventQueueMutex); - ev_async_send (EV_DEFAULT_ &ExitEventLoop); - pthread_mutex_unlock(&EventQueueMutex); - return 0; -} - void FreeAsyncIOContents(AsyncIO *IO) { FreeStrBuf(&IO->IOBuf); @@ -271,11 +259,11 @@ void ShutDownCLient(AsyncIO *IO) ev_cleanup_stop(event_base, &IO->abort_by_shutdown); StopClientWatchers(IO); - if (IO->DNSChannel != NULL) { - ares_destroy(IO->DNSChannel); - ev_io_stop(event_base, &IO->dns_recv_event); - ev_io_stop(event_base, &IO->dns_send_event); - IO->DNSChannel = NULL; + if (IO->DNS.Channel != NULL) { + ares_destroy(IO->DNS.Channel); + ev_io_stop(event_base, &IO->DNS.recv_event); + ev_io_stop(event_base, &IO->DNS.send_event); + IO->DNS.Channel = NULL; } assert(IO->Terminate); IO->Terminate(IO); @@ -695,12 +683,12 @@ IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents) AsyncIO *IO = watcher->data; EV_syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); become_session(IO->CitContext); - assert(IO->DNSFail); - assert(IO->DNSQuery->PostDNS); - switch (IO->DNSQuery->PostDNS(IO)) + assert(IO->DNS.Fail); + assert(IO->DNS.Query->PostDNS); + switch (IO->DNS.Query->PostDNS(IO)) { case eAbort: - switch (IO->DNSFail(IO)) { + switch (IO->DNS.Fail(IO)) { case eAbort: ShutDownCLient(IO); default: @@ -712,11 +700,26 @@ IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents) } } -eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_rw_timeout) + +eNextState EvConnectSock(AsyncIO *IO, + void *pData, + double conn_timeout, + double first_rw_timeout, + int ReadFirst) { int fdflags; int rc = -1; + IO->Data = pData; + become_session(IO->CitContext); + + if (ReadFirst) { + IO->NextState = eReadMessage; + } + else { + IO->NextState = eSendReply; + } + IO->SendBuf.fd = IO->RecvBuf.fd = socket( (IO->ConnectMe->IPv6)?PF_INET6:PF_INET, @@ -802,23 +805,6 @@ void SetNextTimeout(AsyncIO *IO, double timeout) ev_timer_again (event_base, &IO->rw_timeout); } -eNextState InitEventIO(AsyncIO *IO, - void *pData, - double conn_timeout, - double first_rw_timeout, - int ReadFirst) -{ - IO->Data = pData; - become_session(IO->CitContext); - - if (ReadFirst) { - IO->NextState = eReadMessage; - } - else { - IO->NextState = eSendReply; - } - return event_connect_socket(IO, conn_timeout, first_rw_timeout); -} eNextState ReAttachIO(AsyncIO *IO, void *pData,