- Merge aicom-network-fixes up to r37326

svn path=/trunk/; revision=37328
This commit is contained in:
Cameron Gutman
2008-11-13 01:07:17 +00:00
parent 84ecb53001
commit 19656e1fd2
16 changed files with 149 additions and 115 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ DnsQuery_A(LPCSTR Name,
switch(Type)
{
case DNS_TYPE_A:
adns_error = adns_init(&astate, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn | (Servers ? adns_if_noserver : 0), 0);
adns_error = adns_init(&astate, adns_if_noenv | adns_if_noerrprint | adns_if_noserverwarn, 0);
if(adns_error != adns_s_ok)
return DnsIntTranslateAdnsToDNS_STATUS(adns_error);
@@ -188,6 +188,8 @@ VOID NTAPI DispCancelRequest(
TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address file.\n"));
break;
}
DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
break;
case TDI_RECEIVE_DATAGRAM:
@@ -767,7 +769,7 @@ NTSTATUS DispTdiReceive(
PTDI_REQUEST_KERNEL_RECEIVE ReceiveInfo;
PTRANSPORT_CONTEXT TranContext;
NTSTATUS Status;
ULONG BytesReceived;
ULONG BytesReceived = 0;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -839,7 +841,7 @@ NTSTATUS DispTdiReceiveDatagram(
PTRANSPORT_CONTEXT TranContext;
TDI_REQUEST Request;
NTSTATUS Status;
ULONG BytesReceived;
ULONG BytesReceived = 0;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -916,7 +918,7 @@ NTSTATUS DispTdiSend(
PTDI_REQUEST_KERNEL_SEND SendInfo;
PTRANSPORT_CONTEXT TranContext;
NTSTATUS Status;
ULONG BytesSent;
ULONG BytesSent = 0;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
+31 -2
View File
@@ -5,9 +5,9 @@ ADNS is not officially suppoted for Windows, but this
port provides a 100% native Windows DLL and linker
library for the DLL - suitable for traditional compilers
and linkers under Windows. The library itself is ported to
Microsot Visual C++ 6.0 SP 2.
Microsot Visual C++ 6.0.
The library is tested under Windows 2000, but should work
The library is tested under Windows 2000 and XP, but should work
with all versions from Windows NT 4 and up, and Windows98
and up. Windows95 is not supported.
@@ -37,3 +37,32 @@ reasons for this:
For more information about this port, see http://adns.jgaa.com
///////////////////////////////////////////////////////
October 13th 2005 jgaa: adns-1.0-win32-05
- Fixed a problem with the return-value from adns_inet_aton()
Thanks to Gerald Combs for reporting the problem.
October 7th 2004 jgaa: adns-1.0-win32-03
- Fixed a problem with error-messages when the program
works off-line.
Thanks to Ulf Lamping for pointing ourt and solving the problem.
April 4th 2004 jgaa: adns-1.0-win32-03
- Fixed broken gettimeofday() function.
- Fixed problem with TCP connections, where the librarry
failed to connect to DNS servers with TCP, and flooded
the servers with TCP connection attempts.
- Made sure that errno was handled corrcetly after all network
(winsock) calls.
- Fixed a few places where noblocking calls were not handled
EAGAIN and EWOULDBLOCK is not the same under Windows.
+40 -31
View File
@@ -1,3 +1,4 @@
/*
* adns_unix_calls.c
* - Simple implementation of requiered UNIX system calls and
@@ -29,20 +30,20 @@
#include "adns.h"
int adns_writev(SOCKET FileDescriptor, const struct iovec * iov, int iovCount)
int adns_writev(int FileDescriptor, const struct iovec * iov, int iovCount)
{
int total_len = 0;
size_t total_len = 0;
int i = 0, r = 0;
char *buf = NULL, *p = NULL;
for(; i < iovCount; i++)
total_len += iov[i].iov_len;
p = buf = (char *)alloca( (size_t) total_len);
p = buf = (char *)alloca(total_len);
for(; i < iovCount; i++)
{
memcpy(p, iov[i].iov_base, (size_t) iov[i].iov_len);
memcpy(p, iov[i].iov_base, iov[i].iov_len);
p += iov[i].iov_len;
}
@@ -54,8 +55,21 @@ int adns_writev(SOCKET FileDescriptor, const struct iovec * iov, int iovCount)
int adns_inet_aton(const char *cp, struct in_addr *inp)
{
if (!cp || !*cp || !inp)
{
errno = EINVAL;
return -1;
}
if (!strcmp(cp, "255.255.255.255"))
{
// Special case
inp->s_addr = INADDR_NONE;
return 0;
}
inp->s_addr = inet_addr(cp);
return inp->s_addr != INADDR_ANY;
return (inp->s_addr == INADDR_NONE) ? -1 : 0;
}
int adns_getpid()
@@ -63,35 +77,30 @@ int adns_getpid()
return GetCurrentProcessId();
}
/* ReactOS: Fixed gettimeofday implementation. Was wrong by a factor of
* 10 */
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
static __int64 Adjustment;
__int64 Now = 0;
static __int64 Adjustment;
__int64 now = 0;
if (!Adjustment)
{
SYSTEMTIME st = {1970,1,0,1,0,0,0};
SystemTimeToFileTime(&st, (LPFILETIME)&Adjustment);
}
if (tz)
{
errno = EINVAL;
return -1;
}
GetSystemTimeAsFileTime((LPFILETIME)&now);
now -= Adjustment;
tv->tv_sec = (long)(now / 10000000);
tv->tv_usec = (long)((now % 10000000) / 10);
if (!Adjustment)
{
SYSTEMTIME st = {1970,1,3,0,0,0,0};
SystemTimeToFileTime(&st, ((LPFILETIME)(VOID *)&Adjustment));
}
if (tz)
{
return -1;
}
GetSystemTimeAsFileTime(((LPFILETIME)(VOID *)&Now));
Now -= Adjustment;
/* 100 ns
.1 us
10 * 1000000 */
tv->tv_sec = (long)(Now / 10000000);
tv->tv_usec = (long)((Now / 10) % 1000000);
return 0;
return 0;
}
/* Memory allocated in the DLL must be freed in the dll, so
+4 -4
View File
@@ -105,6 +105,8 @@ extern "C"
#define EINPROGRESS WSAEINPROGRESS
#define EMSGSIZE WSAEMSGSIZE
#define ENOPROTOOPT WSAENOPROTOOPT
#define ECONNRESET WSAECONNRESET
//#define NONRETURNING
//#define NONRETURNPRINTFFORMAT(si,tc)
@@ -129,9 +131,9 @@ struct timezone; /* XXX arty */
* Undef ADNS_MAP_UNIXAPI in the calling code to use natve calls
*/
ADNS_API int adns_gettimeofday(struct timeval *tv, struct timezone *tz);
ADNS_API int adns_writev (SOCKET FileDescriptor, const struct iovec * iov, int iovCount);
ADNS_API int adns_writev (int FileDescriptor, const struct iovec * iov, int iovCount);
ADNS_API int adns_inet_aton(const char *cp, struct in_addr *inp);
ADNS_API int adns_getpid(void);
ADNS_API int adns_getpid();
#ifdef ADNS_DLL
ADNS_API void *adns_malloc(const size_t bytes);
@@ -155,7 +157,5 @@ ADNS_API int adns_getpid(void);
}
#endif /* __cplusplus */
#include "timercmp.h" /* arty added: mingw headers don't seem to have it */
#endif /* ADNS_WIN32_H_INCLUDED */
+1 -2
View File
@@ -240,7 +240,7 @@ int main(int argc, const char *const *argv) {
for (;;) {
qu= ov_asynch ? 0 : outstanding.head ? outstanding.head->qu : 0;
r= adns_check(ads,&qu,&answer,&qun_v);
if (r == EAGAIN) break;
if ((r == EAGAIN) || (r == EWOULDBLOCK)) break;
if (r == ESRCH) { if (!ov_pipe) goto x_quit; else break; }
assert(!r);
query_done(qun_v,answer);
@@ -259,7 +259,6 @@ int main(int argc, const char *const *argv) {
r= select(maxfd, &readfds,&writefds,&exceptfds, tv);
ADNS_CAPTURE_ERRNO;
if (r == -1) {
ADNS_CAPTURE_ERRNO;
if (errno == EINTR) continue;
sysfail("select",errno);
}
+1 -4
View File
@@ -30,9 +30,6 @@
* subsequently.
*/
static const char * const cvsid =
"$Id$";
#ifdef ADNS_JGAA_WIN32
# include "adns_win32.h"
# include "getopt.h"
@@ -202,7 +199,7 @@ static void proclog(FILE *inf, FILE *outf, int maxpending, int opts) {
} else {
err= adns_check(adns, &head->query, &answer, NULL);
}
if (err == EAGAIN) break;
if ((err == EAGAIN) || (EWOULDBLOCK == err)) break;
if (err) {
fprintf(stderr, "%s: adns_wait/check: %s", progname, strerror(err));
exit(1);
-3
View File
@@ -29,9 +29,6 @@
* modified by Ian Jackson as it was incorporated into adns.
*/
static const char * const cvsid =
"$Id$";
#ifdef ADNS_JGAA_WIN32
# include "adns_win32.h"
#else
+1 -3
View File
@@ -51,7 +51,6 @@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* $Id$
*/
#ifndef ADNS_H_INCLUDED
@@ -95,8 +94,7 @@ typedef enum {
adns_if_eintr= 0x0020, /* allow _wait and _synchronous to return EINTR */
adns_if_nosigpipe= 0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */
adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */
adns_if_checkc_freq= 0x0300, /* do consistency checks very frequently (slow!) */
adns_if_noserver= 0x0800, /* do not get dns servers from the environment */
adns_if_checkc_freq= 0x0300 /* do consistency checks very frequently (slow!) */
} adns_initflags;
typedef enum {
+5 -5
View File
@@ -101,8 +101,8 @@ static void checkc_notcpbuf(adns_state ads) {
static void checkc_global(adns_state ads) {
int i;
assert(ads->udpsocket != INVALID_SOCKET);
assert(ads->udpsocket >= 0);
for (i=0; i<ads->nsortlist; i++)
assert(!(ads->sortlist[i].base.s_addr & ~ads->sortlist[i].mask.s_addr));
@@ -111,16 +111,16 @@ static void checkc_global(adns_state ads) {
switch (ads->tcpstate) {
case server_connecting:
assert(ads->tcpsocket != INVALID_SOCKET);
assert(ads->tcpsocket >= 0);
checkc_notcpbuf(ads);
break;
case server_disconnected:
case server_broken:
assert(ads->tcpsocket == INVALID_SOCKET);
assert(ads->tcpsocket == -1);
checkc_notcpbuf(ads);
break;
case server_ok:
assert(ads->tcpsocket != INVALID_SOCKET);
assert(ads->tcpsocket >= 0);
assert(ads->tcprecv_skip <= ads->tcprecv.used);
break;
default:
+7 -5
View File
@@ -28,10 +28,10 @@
*/
#include <errno.h>
# include "adns_win32.h"
#include <stdlib.h>
#ifdef ADNS_JGAA_WIN32
# include "adns_win32.h"
#else
# include <unistd.h>
# include <sys/types.h>
@@ -52,7 +52,7 @@ static void tcp_close(adns_state ads) {
serv= ads->tcpserver;
adns_socket_close(ads->tcpsocket);
ads->tcpsocket= INVALID_SOCKET;
ads->tcpsocket= -1;
ads->tcprecv.used= ads->tcprecv_skip= ads->tcpsend.used= 0;
}
@@ -114,7 +114,7 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
ADNS_CLEAR_ERRNO
fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
ADNS_CAPTURE_ERRNO;
if (fd == INVALID_SOCKET) {
if (fd<0) {
adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
return;
}
@@ -128,7 +128,9 @@ void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
addr.sin_family= AF_INET;
addr.sin_port= htons(DNS_PORT);
addr.sin_addr= ads->servers[ads->tcpserver].addr;
ADNS_CLEAR_ERRNO;
r= connect(fd,(const struct sockaddr*)&addr,sizeof(addr));
ADNS_CAPTURE_ERRNO;
ads->tcpsocket= fd;
ads->tcpstate= server_connecting;
if (r==0) { tcp_connected(ads,now); return; }
@@ -398,10 +400,10 @@ int adns_processreadable(adns_state ads, ADNS_SOCKET fd, const struct timeval *n
(struct sockaddr*)&udpaddr,&udpaddrlen);
ADNS_CAPTURE_ERRNO;
if (r<0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ECONNRESET) { r= 0; goto xit; }
if (errno == EINTR) continue;
if (errno_resources(errno)) { r= errno; goto xit; }
adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
adns__warn(ads,-1,0,"datagram receive error: %s (%d)",strerror(errno), errno);
r= 0; goto xit;
}
if (udpaddrlen != sizeof(udpaddr)) {
+2 -2
View File
@@ -254,7 +254,7 @@ static const struct sinfo {
SINFO( nodata, "No such data" )
};
static int __cdecl si_compar(const void *key, const void *elem) {
static int si_compar(const void *key, const void *elem) {
const adns_status *st= key;
const struct sinfo *si= elem;
@@ -295,7 +295,7 @@ static const struct stinfo {
STINFO( permfail )
};
static int __cdecl sti_compar(const void *key, const void *elem) {
static int sti_compar(const void *key, const void *elem) {
const adns_status *st= key;
const struct stinfo *sti= elem;
+8 -8
View File
@@ -31,7 +31,7 @@
#define ADNS_INTERNAL_H_INCLUDED
#include "config.h"
/*typedef unsigned char byte;*/ /* FIXME: horrible kludge to avoid conflicts with an SDK type */
typedef unsigned char byte;
#include <stdarg.h>
#include <assert.h>
@@ -575,7 +575,7 @@ typedef enum {
} parsedomain_flags;
adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
vbuf *vb, parsedomain_flags flags,
vbuf *vb, adns_queryflags flags,
const byte *dgram, int dglen, int *cbyte_io, int max);
/* vb must already have been initialised; it will be reset if necessary.
* If there is truncation, vb->used will be set to 0; otherwise
@@ -690,17 +690,17 @@ void adns__consistency(adns_state ads, adns_query qu, consistency_checks cc);
/* Useful static inline functions: */
static __inline int ctype_whitespace(int c) { return c==' ' || c=='\n' || c=='\t'; }
static __inline int ctype_digit(int c) { return c>='0' && c<='9'; }
static __inline int ctype_alpha(int c) {
static inline int ctype_whitespace(int c) { return c==' ' || c=='\n' || c=='\t'; }
static inline int ctype_digit(int c) { return c>='0' && c<='9'; }
static inline int ctype_alpha(int c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
static __inline int ctype_822special(int c) { return strchr("()<>@,;:\\\".[]",c) != 0; }
static __inline int ctype_domainunquoted(int c) {
static inline int ctype_822special(int c) { return strchr("()<>@,;:\\\".[]",c) != 0; }
static inline int ctype_domainunquoted(int c) {
return ctype_alpha(c) || ctype_digit(c) || (strchr("-_/+",c) != 0);
}
static __inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }
static inline int errno_resources(int e) { return e==ENOMEM || e==ENOBUFS; }
/* Useful macros */
+1 -1
View File
@@ -115,7 +115,7 @@ adns_status adns__findlabel_next(findlabel_state *fls,
}
adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
vbuf *vb, parsedomain_flags flags,
vbuf *vb, adns_queryflags flags,
const byte *dgram, int dglen, int *cbyte_io, int max) {
findlabel_state fls;
+37 -39
View File
@@ -131,13 +131,13 @@ static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf)
while (nextword(&bufp,&word,&l)) { count++; tl += l+1; }
newptrs= malloc(sizeof(char*)*count); if (!newptrs) { saveerr(ads,errno); return; }
newchars= malloc((size_t) tl); if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
newchars= malloc(tl); if (!newchars) { saveerr(ads,errno); free(newptrs); return; }
bufp= buf;
pp= newptrs;
while (nextword(&bufp,&word,&l)) {
*pp++= newchars;
memcpy(newchars,word,(size_t) l);
memcpy(newchars,word,l);
newchars += l;
*newchars++ = 0;
}
@@ -163,12 +163,12 @@ static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *bu
return;
}
if (l >= (int)sizeof(tbuf)) {
if (l >= sizeof(tbuf)) {
configparseerr(ads,fn,lno,"sortlist entry `%.*s' too long",l,word);
continue;
}
memcpy(tbuf,word, (size_t) l); tbuf[l]= 0;
memcpy(tbuf,word,l); tbuf[l]= 0;
slash= strchr(tbuf,'/');
if (slash) *slash++= 0;
@@ -351,7 +351,7 @@ static int gl_text(adns_state ads, getline_ctx *src_io, const char *filename,
return -2;
}
memcpy(buf,cp, (size_t) l);
memcpy(buf,cp,l);
buf[l]= 0;
return l;
}
@@ -382,7 +382,7 @@ static void readconfiggeneric(adns_state ads, const char *filename,
while (*q && !ctype_whitespace(*q)) q++;
dirl= q-p;
for (ccip=configcommandinfos;
ccip->name && !((int)strlen(ccip->name)==dirl && !memcmp(ccip->name,p,(size_t) (q-p)));
ccip->name && !((int)strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p));
ccip++);
if (!ccip->name) {
adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'",
@@ -457,7 +457,7 @@ static void readconfigenvtext(adns_state ads, const char *envvar) {
int adns__setnonblock(adns_state ads, ADNS_SOCKET fd) {
#ifdef ADNS_JGAA_WIN32
unsigned long Val = 1;
return (ioctlsocket (fd, (long) FIONBIO, &Val) == 0) ? 0 : -1;
return (ioctlsocket (fd, FIONBIO, &Val) == 0) ? 0 : -1;
#else
int r;
@@ -488,7 +488,7 @@ static int init_begin(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
LIST_INIT(ads->output);
ads->forallnext= 0;
ads->nextid= 0x311f;
ads->udpsocket= ads->tcpsocket= ((unsigned) -1);
ads->udpsocket= ads->tcpsocket= -1;
adns__vbuf_init(&ads->tcpsend);
adns__vbuf_init(&ads->tcprecv);
ads->tcprecv_skip= 0;
@@ -525,7 +525,7 @@ static int init_finish(adns_state ads) {
struct protoent *proto;
int r;
if (!ads->nservers && !(ads->iflags & adns_if_noserver)) {
if (!ads->nservers) {
if (ads->diagfile && ads->iflags & adns_if_debug)
fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
ia.s_addr= htonl(INADDR_LOOPBACK);
@@ -536,7 +536,7 @@ static int init_finish(adns_state ads) {
ADNS_CLEAR_ERRNO;
ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
ADNS_CAPTURE_ERRNO;
if (ads->udpsocket == INVALID_SOCKET) { r= errno; goto x_free; }
if (ads->udpsocket<0) { r= errno; goto x_free; }
r= adns__setnonblock(ads,ads->udpsocket);
if (r) { r= errno; goto x_closeudp; }
@@ -589,35 +589,33 @@ int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
#ifdef ADNS_JGAA_WIN32
if (!(flags & adns_if_noserver)) {
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\resolv.conf");
readconfig(ads,PathBuf,1);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\resolv-adns.conf");
readconfig(ads,PathBuf,0);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
readconfig(ads,PathBuf,1);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
readconfig(ads,PathBuf,0);
network_info_result = GetNetworkParams(network_info, &network_info_blen);
if (network_info_result != ERROR_SUCCESS){
switch(network_info_result) {
case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break;
case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break;
case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break;
case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;}
adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s",
network_info_result,network_err_str);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\resolv.conf");
readconfig(ads,PathBuf,1);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\resolv-adns.conf");
readconfig(ads,PathBuf,0);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
readconfig(ads,PathBuf,1);
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
readconfig(ads,PathBuf,0);
network_info_result = GetNetworkParams(network_info, &network_info_blen);
if (network_info_result != ERROR_SUCCESS){
switch(network_info_result) {
case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break;
case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break;
case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break;
case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;}
adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s",
network_info_result,network_err_str);
}
else {
for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) {
addr.s_addr = inet_addr(pip->IpAddress.String);
if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
addserver(ads, addr);
}
else {
for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) {
addr.s_addr = inet_addr(pip->IpAddress.String);
if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
addserver(ads, addr);
}
}
#else
@@ -682,7 +680,7 @@ void adns_finish(adns_state ads) {
else break;
}
adns_socket_close(ads->udpsocket);
if (ads->tcpsocket != INVALID_SOCKET) adns_socket_close(ads->tcpsocket);
if (ads->tcpsocket >= 0) adns_socket_close(ads->tcpsocket);
adns__vbuf_free(&ads->tcpsend);
adns__vbuf_free(&ads->tcprecv);
freesearchlist(ads);
+5 -2
View File
@@ -194,10 +194,13 @@ void adns__querysend_tcp(adns_query qu, struct timeval now) {
iov[1].iov_base= (char*)qu->query_dgram;
iov[1].iov_len= qu->query_dglen;
adns__sigpipe_protect(qu->ads);
ADNS_CLEAR_ERRNO;
wr= writev(qu->ads->tcpsocket,iov,2);
ADNS_CAPTURE_ERRNO;
adns__sigpipe_unprotect(qu->ads);
if (wr < 0) {
if (!(errno == EAGAIN || errno == EINTR || errno == ENOSPC ||
if (!(errno == EAGAIN || EWOULDBLOCK || errno == EINTR || errno == ENOSPC ||
errno == ENOBUFS || errno == ENOMEM)) {
adns__tcp_broken(ads,"write",strerror(errno));
return;
@@ -255,7 +258,7 @@ void adns__query_send(adns_query qu, struct timeval now) {
(const struct sockaddr*)&servaddr,sizeof(servaddr));
ADNS_CAPTURE_ERRNO;
if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; }
if (r<0 && errno != EAGAIN) adns__warn(ads,serv,0,"sendto failed: %s (%d)",strerror(errno), errno);
if (r<0 && ((errno != EAGAIN) && (errno != EWOULDBLOCK))) adns__warn(ads,serv,0,"sendto failed: %s (%d)",strerror(errno), errno);
qu->timeout= now;
timevaladd(&qu->timeout,UDPRETRYMS);