Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows build #538

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/anchor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/compat/mkstemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/gldns/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 2 additions & 0 deletions src/gldns/parseutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
5 changes: 5 additions & 0 deletions src/stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down