cherry pick PR that fixes windows build for testing

This commit is contained in:
Sara Dickinson 2023-06-20 20:37:44 +01:00
parent f8c95b4f15
commit 83bbb57b00
5 changed files with 23 additions and 4 deletions

View File

@ -551,7 +551,11 @@ static void tas_rinse(getdns_context *context, tas_connection *a)
GETDNS_CLEAR_EVENT(a->loop, &a->event);
a->event.ev = NULL;
if (a->fd >= 0)
#ifdef USE_WINSOCK
closesocket(a->fd);
#else
close(a->fd);
#endif
a->fd = -1;
if (a->xml.data)
GETDNS_FREE(context->mf, a->xml.data);
@ -662,7 +666,11 @@ static void tas_reconnect_cb(void *userarg)
, "Waiting for second document timeout. Reconnecting...\n");
GETDNS_CLEAR_EVENT(a->loop, &a->event);
#ifdef USE_WINSOCK
closesocket(a->fd);
#else
close(a->fd);
#endif
a->fd = -1;
if (a->state == TAS_READ_PS7_HDR) {
a->state = TAS_RETRY;
@ -778,7 +786,11 @@ static void tas_read_cb(void *userarg)
if (n == 0) {
DEBUG_ANCHOR("Connection closed\n");
GETDNS_CLEAR_EVENT(a->loop, &a->event);
#ifdef USE_WINSOCK
closesocket(a->fd);
#else
close(a->fd);
#endif
a->fd = -1;
if (a->state == TAS_READ_PS7_HDR) {
a->state = TAS_RETRY;

View File

@ -30,14 +30,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <io.h>
int mkstemp(char *template)
{
if (_mktemp_s(template, strlen(template) + 1) != 0)
return -1;
return open(template, _O_CREAT | _O_EXCL | _O_RDWR, _S_IWRITE | _S_IREAD);
return _open(template, _O_CREAT | _O_EXCL | _O_RDWR, _S_IWRITE | _S_IREAD);
}

View File

@ -13,7 +13,7 @@
#include "gldns/gbuffer.h"
#include <limits.h>
#include <strings.h>
#include <string.h>
gldns_lookup_table gldns_directive_types[] = {
{ GLDNS_DIR_TTL, "$TTL" },

View File

@ -14,7 +14,9 @@
#include "config.h"
#include "gldns/parseutil.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>
#include <ctype.h>

View File

@ -903,8 +903,13 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
just fall back to a 'normal' write. */
if (written == -1
&& _getdns_socketerror() == _getdns_EISCONN)
#ifdef USE_WINSOCK
written = send(fd, (const char *)(netreq->query - 2)
, pkt_len + 2, 0);
#else
written = write(fd, netreq->query - 2
, pkt_len + 2);
#endif
} else
written = send(fd, (const char *)(netreq->query - 2)
, pkt_len + 2, 0);