chiark / gitweb /
Regression tests pass with new owner and flags stuff, not yet tested
[adns.git] / src / transmit.c
index ffab58b90628e550202d609745b572566cfe758c..11d774bb05d56e5c7c58312e19678eb81e757fbf 100644 (file)
@@ -4,7 +4,7 @@
  * - send queries
  */
 /*
- *  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
@@ -39,11 +39,10 @@ static adns_status mkquery_header(adns_state ads, vbuf *vb, int *id_r, int qdlen
   
   if (!adns__vbuf_ensure(vb,DNS_HDRSIZE+qdlen+4)) return adns_s_nomemory;
 
-  *id_r= id= (ads->nextid++) & 0x0ffff;
-  
   vb->used= 0;
   MKQUERY_START(vb);
   
+  *id_r= id= (ads->nextid++) & 0x0ffff;
   MKQUERY_ADDW(id);
   MKQUERY_ADDB(0x01); /* QR=Q(0), OPCODE=QUERY(0000), !AA, !TC, RD */
   MKQUERY_ADDB(0x00); /* !RA, Z=000, RCODE=NOERROR(0000) */
@@ -179,7 +178,9 @@ void adns__query_tcp(adns_query qu, struct timeval now) {
     iov[0].iov_len= 2;
     iov[1].iov_base= qu->query_dgram;
     iov[1].iov_len= qu->query_dglen;
+    adns__sigpipe_protect(qu->ads);
     wr= writev(qu->ads->tcpsocket,iov,2);
+    adns__sigpipe_unprotect(qu->ads);
     if (wr < 0) {
       if (!(errno == EAGAIN || errno == EINTR || errno == ENOSPC ||
            errno == ENOBUFS || errno == ENOMEM)) {