projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add an autoconf check for res_init().
[tinc]
/
src
/
net.c
diff --git
a/src/net.c
b/src/net.c
index
9799fea
..
fd79fdc
100644
(file)
--- a/
src/net.c
+++ b/
src/net.c
@@
-41,6
+41,10
@@
#include "subnet.h"
#include "xalloc.h"
#include "subnet.h"
#include "xalloc.h"
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+
bool do_purge = false;
volatile bool running = false;
#ifdef HAVE_PSELECT
bool do_purge = false;
volatile bool running = false;
#ifdef HAVE_PSELECT
@@
-134,7
+138,7
@@
static int build_fdset(fd_set *readset, fd_set *writeset) {
purge();
} else {
FD_SET(c->socket, readset);
purge();
} else {
FD_SET(c->socket, readset);
- if(c->outbuflen > 0)
+ if(c->outbuflen > 0
|| c->status.connecting
)
FD_SET(c->socket, writeset);
if(c->socket > max)
max = c->socket;
FD_SET(c->socket, writeset);
if(c->socket > max)
max = c->socket;
@@
-212,6
+216,12
@@
void terminate_connection(connection_t *c, bool report) {
c->status.remove = false;
do_outgoing_connection(c);
}
c->status.remove = false;
do_outgoing_connection(c);
}
+
+#ifndef HAVE_MINGW
+ /* Clean up dead proxy processes */
+
+ while(waitpid(-1, NULL, WNOHANG) > 0);
+#endif
}
/*
}
/*
@@
-308,7
+318,7
@@
static void check_network_activity(fd_set * readset, fd_set * writeset) {
if(c->status.remove)
continue;
if(c->status.remove)
continue;
- if(FD_ISSET(c->socket,
read
set)) {
+ if(FD_ISSET(c->socket,
write
set)) {
if(c->status.connecting) {
c->status.connecting = false;
getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
if(c->status.connecting) {
c->status.connecting = false;
getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
@@
-325,14
+335,14
@@
static void check_network_activity(fd_set * readset, fd_set * writeset) {
}
}
}
}
- if(!
receive
_meta(c)) {
+ if(!
flush
_meta(c)) {
terminate_connection(c, c->status.active);
continue;
}
}
terminate_connection(c, c->status.active);
continue;
}
}
- if(FD_ISSET(c->socket,
write
set)) {
- if(!
flush
_meta(c)) {
+ if(FD_ISSET(c->socket,
read
set)) {
+ if(!
receive
_meta(c)) {
terminate_connection(c, c->status.active);
continue;
}
terminate_connection(c, c->status.active);
continue;
}
@@
-488,9
+498,13
@@
int main_loop(void) {
avl_node_t *node;
logger(LOG_INFO, "Flushing event queue");
expire_events();
avl_node_t *node;
logger(LOG_INFO, "Flushing event queue");
expire_events();
+#ifdef HAVE_DECL_RES_INIT
+ res_init();
+#endif
for(node = connection_tree->head; node; node = node->next) {
connection_t *c = node->data;
for(node = connection_tree->head; node; node = node->next) {
connection_t *c = node->data;
- send_ping(c);
+ if(c->status.active)
+ send_ping(c);
}
sigalrm = false;
}
}
sigalrm = false;
}