mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'features/mingw-win10-perror' into develop
This commit is contained in:
commit
f26fd6c8ee
43
configure.ac
43
configure.ac
|
@ -254,7 +254,7 @@ esac
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_EVENTLOOP=select_eventloop
|
DEFAULT_EVENTLOOP=select_eventloop
|
||||||
AC_CHECK_HEADERS([sys/poll.h poll.h sys/resource.h sys/types.h],,, [AC_INCLUDES_DEFAULT])
|
AC_CHECK_HEADERS([signal.h sys/poll.h poll.h sys/resource.h sys/types.h],,, [AC_INCLUDES_DEFAULT])
|
||||||
AC_ARG_ENABLE(poll-eventloop, AC_HELP_STRING([--disable-poll-eventloop], [Disable default eventloop based on poll (default=enabled if available)]))
|
AC_ARG_ENABLE(poll-eventloop, AC_HELP_STRING([--disable-poll-eventloop], [Disable default eventloop based on poll (default=enabled if available)]))
|
||||||
case "$enable_poll_eventloop" in
|
case "$enable_poll_eventloop" in
|
||||||
no)
|
no)
|
||||||
|
@ -677,29 +677,29 @@ if test "$USE_WINSOCK" = 1; then
|
||||||
LIBS="$LIBS -lgdi32 -liphlpapi"
|
LIBS="$LIBS -lgdi32 -liphlpapi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Check if -D_POSIX is needed for sigset_t
|
dnl sigset_t or _sigset_t? MinGW is latter by default.
|
||||||
|
AC_CHECK_TYPES([sigset_t],
|
||||||
AC_CHECK_TYPE([sigset_t], [
|
[],
|
||||||
AC_MSG_NOTICE(-D_POSIX is NOT needed for the sigset_t type)
|
[AC_CHECK_TYPES([_sigset_t],
|
||||||
], [
|
[],
|
||||||
BACKCFLAGS="$CFLAGS"
|
[AC_MSG_ERROR([Can't find type `sigset_t' or type `_sigset_t'])],
|
||||||
CFLAGS="-D_POSIX $CFLAGS"
|
[AC_INCLUDES_DEFAULT
|
||||||
AC_CHECK_TYPE([sigset_t], [
|
#ifdef HAVE_SIGNAL_H
|
||||||
AC_MSG_NOTICE(-D_POSIX is needed for the sigset_t type)
|
#include <signal.h>
|
||||||
], [
|
#endif
|
||||||
AC_MSG_NOTICE(Unclear whether -D_POSIX is needed for the sigset_t type)
|
|
||||||
BACKCFLAGS="$CFLAGS"
|
|
||||||
], [AC_INCLUDES_DEFAULT
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
])
|
])
|
||||||
], [AC_INCLUDES_DEFAULT
|
],
|
||||||
|
[AC_INCLUDES_DEFAULT
|
||||||
|
#ifdef HAVE_SIGNAL_H
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_CHECK_FUNCS(sigemptyset sigfillset sigaddset)
|
AC_CHECK_FUNCS(sigemptyset sigfillset sigaddset)
|
||||||
|
|
||||||
my_with_libidn=1
|
my_with_libidn=1
|
||||||
|
@ -1376,12 +1376,6 @@ AH_BOTTOM([
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef USE_WINSOCK
|
|
||||||
# define ARG_LL "%ll"
|
|
||||||
# else
|
|
||||||
# define ARG_LL "%I64"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
|
/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */
|
||||||
# ifdef HAVE_WINSOCK2_H
|
# ifdef HAVE_WINSOCK2_H
|
||||||
# define FD_SET_T (u_int)
|
# define FD_SET_T (u_int)
|
||||||
|
@ -1566,11 +1560,14 @@ struct tm;
|
||||||
char *strptime(const char *s, const char *format, struct tm *tm);
|
char *strptime(const char *s, const char *format, struct tm *tm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_SIGSET_T) && defined(HAVE__SIGSET_T)
|
||||||
|
typedef _sigset_t sigset_t;
|
||||||
|
#endif
|
||||||
#if !defined(HAVE_SIGEMPTYSET)
|
#if !defined(HAVE_SIGEMPTYSET)
|
||||||
# define sigemptyset(pset) (*(pset) = 0)
|
# define sigemptyset(pset) (*(pset) = 0)
|
||||||
#endif
|
#endif
|
||||||
#if !defined(HAVE_SIGFILLSET)
|
#if !defined(HAVE_SIGFILLSET)
|
||||||
# define sigfillset(pset) (*(pset) = (_sigset_t)-1)
|
# define sigfillset(pset) (*(pset) = (sigset_t)-1)
|
||||||
#endif
|
#endif
|
||||||
#if !defined(HAVE_SIGADDSET)
|
#if !defined(HAVE_SIGADDSET)
|
||||||
# define sigaddset(pset, num) (*(pset) |= (1L<<(num)))
|
# define sigaddset(pset, num) (*(pset) |= (1L<<(num)))
|
||||||
|
|
|
@ -77,7 +77,7 @@ C99COMPATFLAGS=@C99COMPATFLAGS@
|
||||||
DEFAULT_EVENTLOOP_OBJ=@DEFAULT_EVENTLOOP@.lo
|
DEFAULT_EVENTLOOP_OBJ=@DEFAULT_EVENTLOOP@.lo
|
||||||
|
|
||||||
GETDNS_OBJ=const-info.lo convert.lo dict.lo dnssec.lo general.lo \
|
GETDNS_OBJ=const-info.lo convert.lo dict.lo dnssec.lo general.lo \
|
||||||
list.lo request-internal.lo pubkey-pinning.lo rr-dict.lo \
|
list.lo request-internal.lo platform.lo pubkey-pinning.lo rr-dict.lo \
|
||||||
rr-iter.lo server.lo stub.lo sync.lo ub_loop.lo util-internal.lo \
|
rr-iter.lo server.lo stub.lo sync.lo ub_loop.lo util-internal.lo \
|
||||||
mdns.lo
|
mdns.lo
|
||||||
|
|
||||||
|
@ -386,6 +386,8 @@ mdns.lo mdns.o: $(srcdir)/mdns.c \
|
||||||
$(srcdir)/gldns/pkthdr.h $(srcdir)/anchor.h $(srcdir)/general.h $(srcdir)/gldns/rrdef.h $(srcdir)/util-internal.h \
|
$(srcdir)/gldns/pkthdr.h $(srcdir)/anchor.h $(srcdir)/general.h $(srcdir)/gldns/rrdef.h $(srcdir)/util-internal.h \
|
||||||
$(srcdir)/platform.h $(srcdir)/mdns.h $(srcdir)/util/auxiliary/util/fptr_wlist.h $(srcdir)/util/lookup3.h \
|
$(srcdir)/platform.h $(srcdir)/mdns.h $(srcdir)/util/auxiliary/util/fptr_wlist.h $(srcdir)/util/lookup3.h \
|
||||||
$(srcdir)/util/orig-headers/lookup3.h
|
$(srcdir)/util/orig-headers/lookup3.h
|
||||||
|
platform.lo platform.o: $(srcdir)/platform.c $(srcdir)/platform.h \
|
||||||
|
config.h
|
||||||
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c \
|
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c \
|
||||||
config.h \
|
config.h \
|
||||||
$(srcdir)/debug.h \
|
$(srcdir)/debug.h \
|
||||||
|
@ -588,7 +590,8 @@ select_eventloop.lo select_eventloop.o: $(srcdir)/extension/select_eventloop.c \
|
||||||
$(srcdir)/debug.h $(srcdir)/types-internal.h \
|
$(srcdir)/debug.h $(srcdir)/types-internal.h \
|
||||||
getdns/getdns.h \
|
getdns/getdns.h \
|
||||||
getdns/getdns_extra.h \
|
getdns/getdns_extra.h \
|
||||||
$(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/extension/select_eventloop.h
|
$(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/platform.h \
|
||||||
|
$(srcdir)/extension/select_eventloop.h
|
||||||
stubby.lo stubby.o: $(stubbysrcdir)/src/stubby.c \
|
stubby.lo stubby.o: $(stubbysrcdir)/src/stubby.c \
|
||||||
config.h \
|
config.h \
|
||||||
getdns/getdns.h \
|
getdns/getdns.h \
|
||||||
|
|
17
src/debug.h
17
src/debug.h
|
@ -59,6 +59,20 @@
|
||||||
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define DEBUG_NL(...) do { \
|
||||||
|
struct timeval tv_dEbUgSyM; \
|
||||||
|
struct tm tm_dEbUgSyM; \
|
||||||
|
char buf_dEbUgSyM[10]; \
|
||||||
|
time_t tsec_dEbUgSyM; \
|
||||||
|
\
|
||||||
|
gettimeofday(&tv_dEbUgSyM, NULL); \
|
||||||
|
tsec_dEbUgSyM = (time_t) tv_dEbUgSyM.tv_sec; \
|
||||||
|
gmtime_s(&tm_dEbUgSyM, (const time_t *) &tsec_dEbUgSyM); \
|
||||||
|
strftime(buf_dEbUgSyM, 10, "%H:%M:%S", &tm_dEbUgSyM); \
|
||||||
|
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
||||||
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define DEBUG_ON(...) do { \
|
#define DEBUG_ON(...) do { \
|
||||||
struct timeval tv_dEbUgSyM; \
|
struct timeval tv_dEbUgSyM; \
|
||||||
|
@ -71,7 +85,6 @@
|
||||||
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_NL(...) do { \
|
#define DEBUG_NL(...) do { \
|
||||||
struct timeval tv_dEbUgSyM; \
|
struct timeval tv_dEbUgSyM; \
|
||||||
|
@ -85,7 +98,7 @@
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, "\n"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG_OFF(...) do {} while (0)
|
#define DEBUG_OFF(...) do {} while (0)
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ poll_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (_getdns_poll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
|
if (_getdns_poll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
|
||||||
perror("poll() failed");
|
_getdns_perror("poll() failed");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
now = get_now_plus(0);
|
now = get_now_plus(0);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "types-internal.h"
|
#include "types-internal.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "extension/select_eventloop.h"
|
#include "extension/select_eventloop.h"
|
||||||
|
|
||||||
static uint64_t get_now_plus(uint64_t amount)
|
static uint64_t get_now_plus(uint64_t amount)
|
||||||
|
@ -244,7 +245,7 @@ select_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
||||||
#endif
|
#endif
|
||||||
if (select(max_fd + 1, &readfds, &writefds, NULL,
|
if (select(max_fd + 1, &readfds, &writefds, NULL,
|
||||||
(timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) {
|
(timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) {
|
||||||
perror("select() failed");
|
_getdns_perror("select() failed");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
|
|
|
@ -1059,11 +1059,7 @@ int gldns_wire2str_tsigtime_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
|
||||||
d4 = (*d)[4];
|
d4 = (*d)[4];
|
||||||
d5 = (*d)[5];
|
d5 = (*d)[5];
|
||||||
tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
|
tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
|
||||||
#ifndef USE_WINSOCK
|
w = gldns_str_print(s, sl, "%"PRIu64, (uint64_t)tsigtime);
|
||||||
w = gldns_str_print(s, sl, "%llu", (long long)tsigtime);
|
|
||||||
#else
|
|
||||||
w = gldns_str_print(s, sl, "%I64u", (long long)tsigtime);
|
|
||||||
#endif
|
|
||||||
(*d)+=6;
|
(*d)+=6;
|
||||||
(*dl)-=6;
|
(*dl)-=6;
|
||||||
return w;
|
return w;
|
||||||
|
@ -1746,13 +1742,8 @@ int gldns_wire2str_edns_llq_print(char** s, size_t* sl, uint8_t* data,
|
||||||
if(error_code < llq_errors_num)
|
if(error_code < llq_errors_num)
|
||||||
w += gldns_str_print(s, sl, " %s", llq_errors[error_code]);
|
w += gldns_str_print(s, sl, " %s", llq_errors[error_code]);
|
||||||
else w += gldns_str_print(s, sl, " error %d", (int)error_code);
|
else w += gldns_str_print(s, sl, " error %d", (int)error_code);
|
||||||
#ifndef USE_WINSOCK
|
w += gldns_str_print(s, sl, " id %"PRIx64" lease-life %lu",
|
||||||
w += gldns_str_print(s, sl, " id %llx lease-life %lu",
|
(uint64_t)llq_id, (unsigned long)lease_life);
|
||||||
(unsigned long long)llq_id, (unsigned long)lease_life);
|
|
||||||
#else
|
|
||||||
w += gldns_str_print(s, sl, " id %I64x lease-life %lu",
|
|
||||||
(unsigned long long)llq_id, (unsigned long)lease_life);
|
|
||||||
#endif
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* \file platform.c
|
||||||
|
* @brief general functions with platform-dependent implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, NLnet Labs, Sinodun
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the names of the copyright holders nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
|
||||||
|
void _getdns_perror(const char *str)
|
||||||
|
{
|
||||||
|
char msg[256];
|
||||||
|
int errid = WSAGetLastError();
|
||||||
|
|
||||||
|
*msg = '\0';
|
||||||
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
errid,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
msg,
|
||||||
|
sizeof(msg),
|
||||||
|
NULL);
|
||||||
|
if (*msg == '\0')
|
||||||
|
sprintf(msg, "Unknown error: %d", errid);
|
||||||
|
if (str && *str != '\0')
|
||||||
|
fprintf(stderr, "%s: ", str);
|
||||||
|
fputs(msg, stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void _getdns_perror(const char *str)
|
||||||
|
{
|
||||||
|
perror(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* /brief general functions with platform-dependent implementations
|
* \file platform.h
|
||||||
|
* @brief general functions with platform-dependent implementations
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -78,4 +79,6 @@ typedef u_short sa_family_t;
|
||||||
#define _getdns_socketerror() (errno)
|
#define _getdns_socketerror() (errno)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void _getdns_perror(const char *str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue