mirror of https://github.com/getdnsapi/getdns.git
Things that came out of compiling on Windows
This commit is contained in:
parent
8897bdf18f
commit
712f62a4c1
18
configure.ac
18
configure.ac
|
@ -1149,10 +1149,20 @@ fi
|
||||||
|
|
||||||
|
|
||||||
#---- check for pthreads library
|
#---- check for pthreads library
|
||||||
AC_SEARCH_LIBS([pthread_mutex_init],[pthread], [
|
AC_ARG_WITH(libpthread, AS_HELP_STRING([--without-libpthread],
|
||||||
AC_DEFINE([HAVE_PTHREAD], [1], [Have pthreads library])
|
[Disable libpthread (default is autodetect)]),
|
||||||
LIBS="-lpthread $LIBS"
|
[], [withval="yes"])
|
||||||
], [AC_MSG_WARN([pthreads not available])])
|
|
||||||
|
case "$withval" in
|
||||||
|
yes)
|
||||||
|
AC_SEARCH_LIBS([pthread_mutex_init],[pthread], [
|
||||||
|
AC_DEFINE([HAVE_PTHREAD], [1], [Have pthreads library])
|
||||||
|
LIBS="-lpthread $LIBS"
|
||||||
|
], [AC_MSG_WARN([pthreads not available])])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable])
|
AC_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable])
|
||||||
AC_LANG_PUSH(C)
|
AC_LANG_PUSH(C)
|
||||||
|
|
16
src/anchor.c
16
src/anchor.c
|
@ -988,9 +988,7 @@ static void tas_read_cb(void *userarg);
|
||||||
static void tas_write_cb(void *userarg);
|
static void tas_write_cb(void *userarg);
|
||||||
static void tas_doc_read(getdns_context *context, tas_connection *a)
|
static void tas_doc_read(getdns_context *context, tas_connection *a)
|
||||||
{
|
{
|
||||||
DEBUG_ANCHOR("doc (size: %d): \"%.*s\"\n",
|
DEBUG_ANCHOR("doc (size: %d)\n", (int)a->tcp.read_buf_len);
|
||||||
(int)a->tcp.read_buf_len,
|
|
||||||
(int)a->tcp.read_buf_len, (char *)a->tcp.read_buf);
|
|
||||||
|
|
||||||
assert(a->tcp.read_pos == a->tcp.read_buf + a->tcp.read_buf_len);
|
assert(a->tcp.read_pos == a->tcp.read_buf + a->tcp.read_buf_len);
|
||||||
assert(context);
|
assert(context);
|
||||||
|
@ -1085,7 +1083,11 @@ static void tas_read_cb(void *userarg)
|
||||||
DEBUG_ANCHOR( "state: %d, to_read: %d\n"
|
DEBUG_ANCHOR( "state: %d, to_read: %d\n"
|
||||||
, (int)a->state, (int)a->tcp.to_read);
|
, (int)a->state, (int)a->tcp.to_read);
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
n = recv(a->fd, (char *)a->tcp.read_pos, a->tcp.to_read, 0);
|
||||||
|
#else
|
||||||
n = read(a->fd, a->tcp.read_pos, a->tcp.to_read);
|
n = read(a->fd, a->tcp.read_pos, a->tcp.to_read);
|
||||||
|
#endif
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
DEBUG_ANCHOR("Connection closed\n");
|
DEBUG_ANCHOR("Connection closed\n");
|
||||||
GETDNS_CLEAR_EVENT(a->loop, &a->event);
|
GETDNS_CLEAR_EVENT(a->loop, &a->event);
|
||||||
|
@ -1218,7 +1220,13 @@ static void tas_write_cb(void *userarg)
|
||||||
DEBUG_ANCHOR( "state: %d, to_write: %d\n"
|
DEBUG_ANCHOR( "state: %d, to_write: %d\n"
|
||||||
, (int)a->state, (int)a->tcp.write_buf_len);
|
, (int)a->state, (int)a->tcp.write_buf_len);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
DEBUG_ANCHOR("sending to: %d\n", a->fd);
|
||||||
|
written = send(a->fd, (const char *)a->tcp.write_buf, a->tcp.write_buf_len, 0);
|
||||||
|
#else
|
||||||
written = write(a->fd, a->tcp.write_buf, a->tcp.write_buf_len);
|
written = write(a->fd, a->tcp.write_buf, a->tcp.write_buf_len);
|
||||||
|
#endif
|
||||||
if (written >= 0) {
|
if (written >= 0) {
|
||||||
assert(written <= (ssize_t)a->tcp.write_buf_len);
|
assert(written <= (ssize_t)a->tcp.write_buf_len);
|
||||||
|
|
||||||
|
@ -1240,7 +1248,7 @@ static void tas_write_cb(void *userarg)
|
||||||
tas_read_cb, NULL, tas_timeout_cb));
|
tas_read_cb, NULL, tas_timeout_cb));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (_getdns_EWOULDBLOCK)
|
} else if (_getdns_EWOULDBLOCK || _getdns_EINPROGRESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBUG_ANCHOR("Write error: %s\n", strerror(errno));
|
DEBUG_ANCHOR("Write error: %s\n", strerror(errno));
|
||||||
|
|
|
@ -54,6 +54,7 @@ typedef unsigned short in_port_t;
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -4613,17 +4614,19 @@ static size_t _getdns_get_appdata(char *path)
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
|
# define SLASHTOK '\\'
|
||||||
# define APPDATA_SUBDIR "getdns"
|
# define APPDATA_SUBDIR "getdns"
|
||||||
|
|
||||||
if (! SUCCEEDED(SHGetFolderPath(NULL,
|
if (! SUCCEEDED(SHGetFolderPath(NULL,
|
||||||
CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
|
CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
|
||||||
DEBUG_ANCHOR("ERROR %s(): Could not get \%AppData\% directory\n"
|
DEBUG_ANCHOR("ERROR %s(): Could not get %%AppData%% directory\n"
|
||||||
, __FUNC__);
|
, __FUNC__);
|
||||||
|
|
||||||
else if ((len = strlen(path)) + sizeof(APPDATA_SUBDIR) + 2 >= PATH_MAX)
|
else if ((len = strlen(path)) + sizeof(APPDATA_SUBDIR) + 2 >= PATH_MAX)
|
||||||
DEBUG_ANCHOR("ERROR %s(): Home path too long for appdata\n"
|
DEBUG_ANCHOR("ERROR %s(): Home path too long for appdata\n"
|
||||||
, __FUNC__);
|
, __FUNC__);
|
||||||
#else
|
#else
|
||||||
|
# define SLASHTOK '/'
|
||||||
# define APPDATA_SUBDIR ".getdns"
|
# define APPDATA_SUBDIR ".getdns"
|
||||||
struct passwd *p = getpwuid(getuid());
|
struct passwd *p = getpwuid(getuid());
|
||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
|
@ -4642,17 +4645,23 @@ static size_t _getdns_get_appdata(char *path)
|
||||||
else {
|
else {
|
||||||
if (len == 0 || ( path[len - 1] != '/'
|
if (len == 0 || ( path[len - 1] != '/'
|
||||||
&& path[len - 1] != '\\')) {
|
&& path[len - 1] != '\\')) {
|
||||||
path[len++] = '/';
|
path[len++] = SLASHTOK;
|
||||||
path[len ] = '\0';
|
path[len ] = '\0';
|
||||||
}
|
}
|
||||||
(void) strcpy(path + len, APPDATA_SUBDIR);
|
(void) strcpy(path + len, APPDATA_SUBDIR);
|
||||||
len += sizeof(APPDATA_SUBDIR) - 1;
|
len += sizeof(APPDATA_SUBDIR) - 1;
|
||||||
|
|
||||||
if (mkdir(path, 0755) < 0 && errno != EEXIST)
|
if (0 >
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
mkdir(path)
|
||||||
|
#else
|
||||||
|
mkdir(path, 0755)
|
||||||
|
#endif
|
||||||
|
&& errno != EEXIST)
|
||||||
DEBUG_ANCHOR("ERROR %s(): Could not mkdir %s: %s\n"
|
DEBUG_ANCHOR("ERROR %s(): Could not mkdir %s: %s\n"
|
||||||
, __FUNC__, path, strerror(errno));
|
, __FUNC__, path, strerror(errno));
|
||||||
else {
|
else {
|
||||||
path[len++] = '/';
|
path[len++] = SLASHTOK;
|
||||||
path[len ] = '\0';
|
path[len ] = '\0';
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
time_t tsec_dEbUgSyM; \
|
time_t tsec_dEbUgSyM; \
|
||||||
\
|
\
|
||||||
gettimeofday(&tv_dEbUgSyM, NULL); \
|
gettimeofday(&tv_dEbUgSyM, NULL); \
|
||||||
tsec = (time_t) tv_dEbUgSyM.tv_sec; \
|
tsec_dEbUgSyM = (time_t) tv_dEbUgSyM.tv_sec; \
|
||||||
gmtime_s(&tm_dEbUgSyM, (const time_t *) &tsec_dEbUgSyM); \
|
gmtime_s(&tm_dEbUgSyM, (const time_t *) &tsec_dEbUgSyM); \
|
||||||
strftime(buf_dEbUgSyM, 10, "%H:%M:%S", &tm_dEbUgSyM); \
|
strftime(buf_dEbUgSyM, 10, "%H:%M:%S", &tm_dEbUgSyM); \
|
||||||
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
fprintf(stderr, "[%s.%.6d] ", buf_dEbUgSyM, (int)tv_dEbUgSyM.tv_usec); \
|
||||||
|
|
|
@ -235,20 +235,21 @@ select_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
||||||
tv.tv_usec = (long)((timeout - now) % 1000000);
|
tv.tv_usec = (long)((timeout - now) % 1000000);
|
||||||
}
|
}
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
if (max_fd == -1)
|
if (max_fd == -1) {
|
||||||
{
|
if (timeout != TIMEOUT_FOREVER) {
|
||||||
if (timeout != TIMEOUT_FOREVER)
|
uint32_t timeout_ms = (tv.tv_usec / 1000) + (tv.tv_sec * 1000);
|
||||||
{
|
Sleep(timeout_ms);
|
||||||
uint32_t timeout_ms = (tv.tv_usec / 1000) + (tv.tv_sec * 1000);
|
}
|
||||||
Sleep(timeout_ms);
|
} else {
|
||||||
}
|
|
||||||
} else
|
|
||||||
#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");
|
perror("select() failed");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
}
|
||||||
|
#endif
|
||||||
now = get_now_plus(0);
|
now = get_now_plus(0);
|
||||||
for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
|
for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
|
||||||
if (select_loop->fd_events[fd] &&
|
if (select_loop->fd_events[fd] &&
|
||||||
|
|
|
@ -189,7 +189,8 @@ static void tcp_write_cb(void *userarg)
|
||||||
}
|
}
|
||||||
to_write = conn->to_write;
|
to_write = conn->to_write;
|
||||||
if (conn->fd == -1 ||
|
if (conn->fd == -1 ||
|
||||||
(written = send(conn->fd, &to_write->write_buf[to_write->written],
|
(written = send(conn->fd,
|
||||||
|
(const void *)&to_write->write_buf[to_write->written],
|
||||||
to_write->write_buf_len - to_write->written, 0)) == -1) {
|
to_write->write_buf_len - to_write->written, 0)) == -1) {
|
||||||
|
|
||||||
/* IO error, close connection */
|
/* IO error, close connection */
|
||||||
|
@ -367,7 +368,8 @@ static void tcp_read_cb(void *userarg)
|
||||||
(void) loop->vmt->schedule(loop, conn->fd,
|
(void) loop->vmt->schedule(loop, conn->fd,
|
||||||
DOWNSTREAM_IDLE_TIMEOUT, &conn->event);
|
DOWNSTREAM_IDLE_TIMEOUT, &conn->event);
|
||||||
|
|
||||||
if ((bytes_read = recv(conn->fd, conn->read_pos, conn->to_read, 0)) < 0) {
|
if ((bytes_read = recv(conn->fd,
|
||||||
|
(void *)conn->read_pos, conn->to_read, 0)) < 0) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||||
return; /* Come back to do the read later */
|
return; /* Come back to do the read later */
|
||||||
|
|
||||||
|
|
|
@ -840,7 +840,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
|
||||||
/* Coming back from an earlier unfinished write or handshake.
|
/* Coming back from an earlier unfinished write or handshake.
|
||||||
* Try to send remaining data */
|
* Try to send remaining data */
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
written = send(fd, tcp->write_buf + tcp->written,
|
written = send(fd, (void *)(tcp->write_buf + tcp->written),
|
||||||
tcp->write_buf_len - tcp->written, 0);
|
tcp->write_buf_len - tcp->written, 0);
|
||||||
#else
|
#else
|
||||||
written = write(fd, tcp->write_buf + tcp->written,
|
written = write(fd, tcp->write_buf + tcp->written,
|
||||||
|
|
|
@ -76,7 +76,7 @@ getdns_sync_data_init(getdns_context *context, getdns_sync_data *data)
|
||||||
# ifdef HAVE_UNBOUND_EVENT_API
|
# ifdef HAVE_UNBOUND_EVENT_API
|
||||||
if (_getdns_ub_loop_enabled(&context->ub_loop)) {
|
if (_getdns_ub_loop_enabled(&context->ub_loop)) {
|
||||||
context->ub_loop.extension = ext;
|
context->ub_loop.extension = ext;
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
# ifndef USE_WINSOCK
|
# ifndef USE_WINSOCK
|
||||||
return ext->vmt->schedule(ext, ub_fd(context->unbound_ctx),
|
return ext->vmt->schedule(ext, ub_fd(context->unbound_ctx),
|
||||||
|
@ -85,7 +85,9 @@ getdns_sync_data_init(getdns_context *context, getdns_sync_data *data)
|
||||||
/* No sync full recursion requests on windows without
|
/* No sync full recursion requests on windows without
|
||||||
* UNBOUND_EVENT_API because ub_fd() doesn't work on windows.
|
* UNBOUND_EVENT_API because ub_fd() doesn't work on windows.
|
||||||
*/
|
*/
|
||||||
; /* pass */
|
# ifdef HAVE_UNBOUND_EVENT_API
|
||||||
|
{ ; } /* pass */
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
|
|
|
@ -341,7 +341,7 @@ static getdns_return_t validate_chain(getdns_dict *response)
|
||||||
if ((r = getdns_list_set_dict(to_validate, 0, reply)))
|
if ((r = getdns_list_set_dict(to_validate, 0, reply)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (verbosity) printf("reply "PRIsz", dnssec_status: ", i);
|
if (verbosity) printf("reply %d, dnssec_status: ", (int)i);
|
||||||
switch ((s = getdns_validate_dnssec(
|
switch ((s = getdns_validate_dnssec(
|
||||||
to_validate, validation_chain, trust_anchor))) {
|
to_validate, validation_chain, trust_anchor))) {
|
||||||
|
|
||||||
|
@ -1075,11 +1075,11 @@ next: ;
|
||||||
/* apply the accumulated pubkey pinset to all upstreams: */
|
/* apply the accumulated pubkey pinset to all upstreams: */
|
||||||
for (j = 0; j < upstream_count; j++) {
|
for (j = 0; j < upstream_count; j++) {
|
||||||
if (r = getdns_list_get_dict(upstream_list, j, &upstream), r) {
|
if (r = getdns_list_get_dict(upstream_list, j, &upstream), r) {
|
||||||
fprintf(stderr, "Failed to get upstream "PRIsz" when adding pinset\n", j);
|
fprintf(stderr, "Failed to get upstream %d when adding pinset\n", (int)j);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
if (r = getdns_dict_set_list(upstream, "tls_pubkey_pinset", pubkey_pinset), r) {
|
if (r = getdns_dict_set_list(upstream, "tls_pubkey_pinset", pubkey_pinset), r) {
|
||||||
fprintf(stderr, "Failed to set pubkey pinset on upstream "PRIsz"\n", j);
|
fprintf(stderr, "Failed to set pubkey pinset on upstream %d\n", (int)j);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ INLINE uint64_t _getdns_get_now_ms()
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
(void) gettimeofday(&tv, NULL);
|
(void) gettimeofday(&tv, NULL);
|
||||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
return (uint64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE uint64_t _getdns_ms_until_expiry(uint64_t expires)
|
INLINE uint64_t _getdns_ms_until_expiry(uint64_t expires)
|
||||||
|
|
|
@ -471,13 +471,13 @@ void report_parser_error(yaml_parser_t *parser)
|
||||||
|
|
||||||
case YAML_SCANNER_ERROR:
|
case YAML_SCANNER_ERROR:
|
||||||
if (parser->context) {
|
if (parser->context) {
|
||||||
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n"
|
fprintf(stderr, "Scanner error: %s at line "PRIsz", column "PRIsz"\n"
|
||||||
"%s at line %lu, column %lu\n", parser->context,
|
"%s at line "PRIsz", column "PRIsz"\n", parser->context,
|
||||||
parser->context_mark.line+1, parser->context_mark.column+1,
|
parser->context_mark.line+1, parser->context_mark.column+1,
|
||||||
parser->problem, parser->problem_mark.line+1,
|
parser->problem, parser->problem_mark.line+1,
|
||||||
parser->problem_mark.column+1);
|
parser->problem_mark.column+1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Scanner error: %s at line %lu, column %lu\n",
|
fprintf(stderr, "Scanner error: %s at line "PRIsz", column "PRIsz"\n",
|
||||||
parser->problem, parser->problem_mark.line+1,
|
parser->problem, parser->problem_mark.line+1,
|
||||||
parser->problem_mark.column+1);
|
parser->problem_mark.column+1);
|
||||||
}
|
}
|
||||||
|
@ -485,13 +485,13 @@ void report_parser_error(yaml_parser_t *parser)
|
||||||
|
|
||||||
case YAML_PARSER_ERROR:
|
case YAML_PARSER_ERROR:
|
||||||
if (parser->context) {
|
if (parser->context) {
|
||||||
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n"
|
fprintf(stderr, "Parser error: %s at line "PRIsz", column "PRIsz"\n"
|
||||||
"%s at line %lu, column %lu\n", parser->context,
|
"%s at line "PRIsz", column "PRIsz"\n", parser->context,
|
||||||
parser->context_mark.line+1, parser->context_mark.column+1,
|
parser->context_mark.line+1, parser->context_mark.column+1,
|
||||||
parser->problem, parser->problem_mark.line+1,
|
parser->problem, parser->problem_mark.line+1,
|
||||||
parser->problem_mark.column+1);
|
parser->problem_mark.column+1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Parser error: %s at line %lu, column %lu\n",
|
fprintf(stderr, "Parser error: %s at line "PRIsz", column "PRIsz"\n",
|
||||||
parser->problem, parser->problem_mark.line+1,
|
parser->problem, parser->problem_mark.line+1,
|
||||||
parser->problem_mark.column+1);
|
parser->problem_mark.column+1);
|
||||||
}
|
}
|
||||||
|
|
2
stubby
2
stubby
|
@ -1 +1 @@
|
||||||
Subproject commit 3f132bf7d51bdd156d28758acb884de3fb1249b0
|
Subproject commit 993cbb35c1e1c2bcccb49fc0781e94c34c21a5ee
|
Loading…
Reference in New Issue