chiark / gitweb /
SIGPIPE protection available.
[adns.git] / src / event.c
index d42afbd15df2e9be1e806759f94063ef662cb1b1..db3dad68e776168a2c645aa14e801413cf837dd7 100644 (file)
@@ -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; tries<ads->nservers; 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));