projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
CI: Fix installation of OpenSSL on CentOS and AlmaLinux.
[tinc]
/
src
/
upnp.c
diff --git
a/src/upnp.c
b/src/upnp.c
index
3e90210
..
553630e
100644
(file)
--- a/
src/upnp.c
+++ b/
src/upnp.c
@@
-1,6
+1,6
@@
/*
upnp.c -- UPnP-IGD client
/*
upnp.c -- UPnP-IGD client
- Copyright (C) 2015 Guus Sliepen <guus@tinc-vpn.org>,
+ Copyright (C) 2015
-2018
Guus Sliepen <guus@tinc-vpn.org>,
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-19,7
+19,9
@@
#include "upnp.h"
#include "upnp.h"
+#ifndef HAVE_MINGW
#include <pthread.h>
#include <pthread.h>
+#endif
#include "miniupnpc/miniupnpc.h"
#include "miniupnpc/upnpcommands.h"
#include "miniupnpc/miniupnpc.h"
#include "miniupnpc/upnpcommands.h"
@@
-61,7
+63,7
@@
static struct UPNPDev *upnp_discover(int delay, int *error) {
#else
#else
-#if MINIUPNPC_API_VERSION > 1
5
+#if MINIUPNPC_API_VERSION > 1
7
#warning "The version of libminiupnpc you're building against seems to be too recent. Expect trouble."
#endif
#warning "The version of libminiupnpc you're building against seems to be too recent. Expect trouble."
#endif
@@
-148,6
+150,8
@@
static void upnp_refresh() {
}
static void *upnp_thread(void *data) {
}
static void *upnp_thread(void *data) {
+ (void)data;
+
while(true) {
time_t start = time(NULL);
upnp_refresh();
while(true) {
time_t start = time(NULL);
upnp_refresh();
@@
-157,7
+161,9
@@
static void *upnp_thread(void *data) {
time_t now = time(NULL);
if(now < refresh_time) {
time_t now = time(NULL);
if(now < refresh_time) {
- sleep(refresh_time - now);
+ nanosleep(&(struct timespec) {
+ refresh_time - now, 0
+ }, NULL);
}
}
}
}
@@
-174,10
+180,20
@@
void upnp_init(bool tcp, bool udp) {
get_config_int(lookup_config(config_tree, "UPnPDiscoverWait"), &upnp_discover_wait);
get_config_int(lookup_config(config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period);
get_config_int(lookup_config(config_tree, "UPnPDiscoverWait"), &upnp_discover_wait);
get_config_int(lookup_config(config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period);
+#ifdef HAVE_MINGW
+ HANDLE handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)upnp_thread, NULL, 0, NULL);
+
+ if(!handle) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread");
+ }
+
+#else
pthread_t thread;
int error = pthread_create(&thread, NULL, upnp_thread, NULL);
if(error) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread: [%d] %s", error, strerror(error));
}
pthread_t thread;
int error = pthread_create(&thread, NULL, upnp_thread, NULL);
if(error) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread: [%d] %s", error, strerror(error));
}
+
+#endif
}
}