]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.c
Switch handling to have a pointer to the target address
[citadel.git] / citadel / event_client.c
index 960ca4d55ab2610556236afc06d8afe71aa06330..dd0fa7c976bf9fbe2fd0f77a277dff8c1297b20f 100644 (file)
@@ -73,6 +73,14 @@ extern struct ev_loop *event_base;
 extern ev_async AddJob;   
 extern ev_async ExitEventLoop;
 
+static void
+IO_abort_shutdown_callback(struct ev_loop *loop, ev_cleanup *watcher, int revents)
+{
+       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q: %s\n", __FUNCTION__);
+
+       AsyncIO *IO = watcher->data;
+       IO->ShutdownAbort(IO);
+}
        
 int QueueEventContext(AsyncIO *IO, IO_CallBack CB)
 {
@@ -82,6 +90,10 @@ int QueueEventContext(AsyncIO *IO, IO_CallBack CB)
        h = (IOAddHandler*)malloc(sizeof(IOAddHandler));
        h->IO = IO;
        h->EvAttch = CB;
+       ev_cleanup_init(&IO->abort_by_shutdown, 
+                       IO_abort_shutdown_callback);
+       IO->abort_by_shutdown.data = IO;
+       ev_cleanup_start(event_base, &IO->abort_by_shutdown);
 
        citthread_mutex_lock(&EventQueueMutex);
        CtdlLogPrintf(CTDL_DEBUG, "EVENT Q\n");
@@ -115,6 +127,8 @@ void ShutDownCLient(AsyncIO *IO)
 {
        CtdlLogPrintf(CTDL_DEBUG, "EVENT x %d\n", IO->sock);
 
+       ev_cleanup_stop(event_base, &IO->abort_by_shutdown);
+
        if (IO->sock != 0)
        {
                ev_io_stop(event_base, &IO->send_event);
@@ -326,12 +340,12 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
 }
 
 void
-IO_postdns_callback(struct ev_loop *loop, ev_timer *watcher, int revents)
+IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents)
 {
        AsyncIO *IO = watcher->data;
        CtdlLogPrintf(CTDL_DEBUG, "event: %s\n", __FUNCTION__);
 
-       IO->PostDNS(IO);
+       IO->DNSQuery->PostDNS(IO);
 }
 
 eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_rw_timeout)
@@ -382,9 +396,9 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r
        IO->rw_timeout.data = IO;
 
        if (IO->IP6)
-               rc = connect(IO->sock, &IO->Addr, sizeof(struct sockaddr_in6));
+               rc = connect(IO->sock, IO->Addr, sizeof(struct sockaddr_in6));
        else
-               rc = connect(IO->sock, (struct sockaddr_in *)&IO->Addr, sizeof(struct sockaddr_in));
+               rc = connect(IO->sock, (struct sockaddr_in *)IO->Addr, sizeof(struct sockaddr_in));
 
        if (rc >= 0){
 ////           freeaddrinfo(res);