X-Git-Url: https://git.distorted.org.uk/~mdw/adns/blobdiff_plain/e062dcae8f9acfc112459cf7b2d8c925cda08249..ac868fa87da18cdebb86103b35ce250bd171f700:/src/event.c diff --git a/src/event.c b/src/event.c index a61b8dd..db3dad6 100644 --- a/src/event.c +++ b/src/event.c @@ -5,7 +5,7 @@ * - user-visible check/wait and event-loop-related functions */ /* - * This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson + * This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +76,6 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) { int r, fd, tries; struct sockaddr_in addr; struct protoent *proto; - /* fixme: single TCP timeout, not once per server */ for (tries=0; triesnservers; tries++) { if (ads->tcpstate == server_connecting || ads->tcpstate == server_ok) return; @@ -285,7 +284,9 @@ static int internal_callback(adns_state ads, int maxfd, } else if (callb_checkfd(maxfd,exceptfds,ads->tcpsocket)) { adns__tcp_broken(ads,"select","exceptional condition detected"); } else if (ads->tcpsend.used && callb_checkfd(maxfd,writefds,ads->tcpsocket)) { + adns__sigpipe_protect(ads); r= write(ads->tcpsocket,ads->tcpsend.buf,ads->tcpsend.used); + adns__sigpipe_unprotect(ads); if (r<0) { if (errno!=EAGAIN && errno!=EWOULDBLOCK && errno!=ENOMEM && errno!=EINTR) { adns__tcp_broken(ads,"write",strerror(errno)); @@ -374,7 +375,7 @@ static int internal_check(adns_state ads, } LIST_UNLINK(ads->output,qu); *answer= qu->answer; - if (context_r) *context_r= qu->context.ext; + if (context_r) *context_r= qu->ctx.ext; free(qu); return 0; } @@ -394,7 +395,10 @@ int adns_wait(adns_state ads, FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); adns_interest(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf); rsel= select(maxfd,&readfds,&writefds,&exceptfds,tvp); - if (rsel==-1) return r; + if (rsel==-1) { + if (errno == EINTR && !(ads->iflags & adns_if_eintr)) continue; + return errno; + } rcb= adns_callback(ads,maxfd,&readfds,&writefds,&exceptfds); assert(rcb==rsel); }