projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix retrying outgoing connections.
[tinc]
/
src
/
net_socket.c
diff --git
a/src/net_socket.c
b/src/net_socket.c
index
5394d36
..
7ef8193
100644
(file)
--- a/
src/net_socket.c
+++ b/
src/net_socket.c
@@
-22,7
+22,7
@@
#include "system.h"
#include "system.h"
-#include "
avl
_tree.h"
+#include "
splay
_tree.h"
#include "conf.h"
#include "connection.h"
#include "logger.h"
#include "conf.h"
#include "connection.h"
#include "logger.h"
@@
-51,8
+51,7
@@
int listen_sockets;
/* Setup sockets */
/* Setup sockets */
-static void configure_tcp(connection_t *c)
-{
+static void configure_tcp(connection_t *c) {
int option;
#ifdef O_NONBLOCK
int option;
#ifdef O_NONBLOCK
@@
-80,8
+79,7
@@
static void configure_tcp(connection_t *c)
#endif
}
#endif
}
-int setup_listen_socket(const sockaddr_t *sa)
-{
+int setup_listen_socket(const sockaddr_t *sa) {
int nfd;
char *addrstr;
int option;
int nfd;
char *addrstr;
int option;
@@
-139,8
+137,7
@@
int setup_listen_socket(const sockaddr_t *sa)
return nfd;
}
return nfd;
}
-int setup_vpn_in_socket(const sockaddr_t *sa)
-{
+int setup_vpn_in_socket(const sockaddr_t *sa) {
int nfd;
char *addrstr;
int option;
int nfd;
char *addrstr;
int option;
@@
-234,7
+231,7
@@
int setup_vpn_in_socket(const sockaddr_t *sa)
}
static void retry_outgoing_handler(int fd, short events, void *data) {
}
static void retry_outgoing_handler(int fd, short events, void *data) {
-
retry_outgoing
(data);
+
setup_outgoing_connection
(data);
}
void retry_outgoing(outgoing_t *outgoing) {
}
void retry_outgoing(outgoing_t *outgoing) {
@@
-253,21
+250,20
@@
void retry_outgoing(outgoing_t *outgoing) {
outgoing->timeout);
}
outgoing->timeout);
}
-void finish_connecting(connection_t *c)
-{
+void finish_connecting(connection_t *c) {
cp();
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
configure_tcp(c);
cp();
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
configure_tcp(c);
- c->last_ping_time = now;
+ c->last_ping_time = time(NULL);
+ c->status.connecting = false;
send_id(c);
}
send_id(c);
}
-void do_outgoing_connection(connection_t *c)
-{
+void do_outgoing_connection(connection_t *c) {
char *address, *port;
int result;
char *address, *port;
int result;
@@
-278,8
+274,9
@@
begin:
if(!c->outgoing->cfg) {
ifdebug(CONNECTIONS) logger(LOG_ERR, _("Could not set up a meta connection to %s"),
c->name);
if(!c->outgoing->cfg) {
ifdebug(CONNECTIONS) logger(LOG_ERR, _("Could not set up a meta connection to %s"),
c->name);
- c->status.remove = true;
retry_outgoing(c->outgoing);
retry_outgoing(c->outgoing);
+ c->outgoing = NULL;
+ connection_del(c);
return;
}
return;
}
@@
-352,8
+349,7
@@
begin:
return;
}
return;
}
-void setup_outgoing_connection(outgoing_t *outgoing)
-{
+void setup_outgoing_connection(outgoing_t *outgoing) {
connection_t *c;
node_t *n;
connection_t *c;
node_t *n;
@@
-390,7
+386,7
@@
void setup_outgoing_connection(outgoing_t *outgoing)
}
c->outgoing = outgoing;
}
c->outgoing = outgoing;
- c->last_ping_time =
now
;
+ c->last_ping_time =
time(NULL)
;
connection_add(c);
connection_add(c);
@@
-408,8
+404,7
@@
void setup_outgoing_connection(outgoing_t *outgoing)
accept a new tcp connect and create a
new connection
*/
accept a new tcp connect and create a
new connection
*/
-void handle_new_meta_connection(int sock, short events, void *data)
-{
+void handle_new_meta_connection(int sock, short events, void *data) {
connection_t *c;
sockaddr_t sa;
int fd;
connection_t *c;
sockaddr_t sa;
int fd;
@@
-436,7
+431,7
@@
void handle_new_meta_connection(int sock, short events, void *data)
c->address = sa;
c->hostname = sockaddr2hostname(&sa);
c->socket = fd;
c->address = sa;
c->hostname = sockaddr2hostname(&sa);
c->socket = fd;
- c->last_ping_time =
now
;
+ c->last_ping_time =
time(NULL)
;
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
@@
-456,8
+451,7
@@
void handle_new_meta_connection(int sock, short events, void *data)
send_id(c);
}
send_id(c);
}
-void try_outgoing_connections(void)
-{
+void try_outgoing_connections(void) {
static config_t *cfg = NULL;
char *name;
outgoing_t *outgoing;
static config_t *cfg = NULL;
char *name;
outgoing_t *outgoing;