if(sighup) {
connection_t *c;
- avl_node_t *node;
+ avl_node_t *node, *next;
char *fname;
struct stat s;
return 1;
}
+ /* Cancel non-active outgoing connections */
+
+ for(node = connection_tree->head; node; node = next) {
+ next = node->next;
+ c = node->data;
+
+ c->outgoing = NULL;
+
+ if(c->status.connecting) {
+ terminate_connection(c, false);
+ connection_del(c);
+ }
+ }
+
+ /* Wipe list of outgoing connections */
+
+ for(list_node_t *node = outgoing_list->head; node; node = node->next) {
+ outgoing_t *outgoing = node->data;
+
+ if(outgoing->event)
+ event_del(outgoing->event);
+ }
+
+ list_delete_list(outgoing_list);
+
/* Close connections to hosts that have a changed or deleted host config file */
for(node = connection_tree->head; node; node = node->next) {
for(node = connection_tree->head; node; node = next) {
next = node->next;
c = node->data;
- c->outgoing = false;
+ c->outgoing = NULL;
terminate_connection(c, false);
}
+ for(list_node_t *node = outgoing_list->head; node; node = node->next) {
+ outgoing_t *outgoing = node->data;
+
+ if(outgoing->event)
+ event_del(outgoing->event);
+ }
+
list_delete_list(outgoing_list);
if(myself && myself->connection) {
} /* int setup_vpn_in_socket */
void retry_outgoing(outgoing_t *outgoing) {
- event_t *event;
-
outgoing->timeout += 5;
if(outgoing->timeout > maxtimeout)
outgoing->timeout = maxtimeout;
- event = new_event();
- event->handler = (event_handler_t) setup_outgoing_connection;
- event->time = now + outgoing->timeout;
- event->data = outgoing;
- event_add(event);
+ if(outgoing->event)
+ event_del(outgoing->event);
+ outgoing->event = new_event();
+ outgoing->event->handler = (event_handler_t) setup_outgoing_connection;
+ outgoing->event->time = now + outgoing->timeout;
+ outgoing->event->data = outgoing;
+ event_add(outgoing->event);
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
"Trying to re-establish outgoing connection in %d seconds",
char *address, *port;
int result;
+ if(!c->outgoing) {
+ logger(LOG_ERR, "do_outgoing_connection() for %s called without c->outgoing", c->name);
+ abort();
+ }
+
begin:
if(!c->outgoing->ai) {
if(!c->outgoing->cfg) {
c->name);
c->status.remove = true;
retry_outgoing(c->outgoing);
+ c->outgoing = NULL;
return;
}
connection_t *c;
node_t *n;
+ outgoing->event = NULL;
+
n = lookup_node(outgoing->name);
if(n)
static config_t *cfg = NULL;
char *name;
outgoing_t *outgoing;
- connection_t *c;
- avl_node_t *node;
- if(outgoing_list) {
- for(node = connection_tree->head; node; node = node->next) {
- c = node->data;
- c->outgoing = NULL;
- }
-
- list_delete_list(outgoing_list);
- }
-
outgoing_list = list_alloc((list_action_t)free_outgoing);
for(cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {