When libbsd is found on the system during the configure, the result
of `pkg-config --cflags libbsd-overlay` is added to `CFLAGS`:
`-DLIBBSD_OVERLAY -isystem /usr/include/bsd`
The result of `pkg-config --libs libbsd-overlay` is added to `LIBS`,
but not to `STUBBY_LIBS`, which is used when linking stubby.
Because of the new `CFLAGS`, the preprocessor replaces the call to
`getopt()` in stubby.c with a call to `bsd_getop()`:
```
#ifdef LIBBSD_OVERLAY
#undef getopt
#define getopt(argc, argv, optstr) bsd_getopt(argc, argv, optstr)
#endif
```
But since `-lbsd` has not been added to `STUBBY_LIBS`, the linking of
stubby fails with an unresolved symbol:
```
../libtool --tag=CC --mode=link gcc -o stubby stubby.lo convert_yaml_to_json.lo gbuffer.lo -lyaml libgetdns.la
libtool: link: gcc -o .libs/stubby .libs/stubby.o .libs/convert_yaml_to_json.o .libs/gbuffer.o -lyaml ./.libs/libgetdns.so
/usr/bin/ld: .libs/stubby.o: undefined reference to symbol 'bsd_getopt@@LIBBSD_0.0'
/usr/lib/libbsd.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
```
Simply adding the result of `pkg-config --libs libbsd-overlay` to
`STUBBY_LIBS` in addition to `LIBS` fixes the issue.
- backoff time was not incrementing correctly
- best authentication information state was not being kept for shutdowns during setup (needed if e.g. hostname authentication failed during handshake).
Can deal with timed out queries that are answered anyway.
+ reset the upstream on failure always
(since requests are rescheduled for fallback by upstream_failed now anyway)
The previous strategy for Windows of checking for sigset_t and if it failed repeating the check with -D_POSIX did not work as expected. Autoconf found the second instance of the test, thought it was the same as the first, and used the cached result from the first. It was only because a typo did not reset CFLAGS back, so always adding _POSIX, that this worked with mingw.
Change instead to checking for sigset_t and if that fails for _sigset_t, and in config.h if sigset_t does not exist but _sigset_t does then typedef _sigset_t to sigset_t. Also amend the implementation of sigfillset() to cast to sigset_t not _sigset_t; it may not be just mingw that doesn't have sigfilleset().
Also, ensure signal.h is one of the headers included when checking for sigset_t. It's the header Posix says sigset_t is defined in...
Winsock can return ECONNRESET when receiving UDP via recvfrom() if an ICMP Port Unreachable has been received. Rather than treat the socket as being in error and closing it, just ignore the error.