Use libevent for retrying outgoing connections.
This commit is contained in:
parent
3321591d93
commit
a67ab277c9
2 changed files with 7 additions and 9 deletions
|
@ -115,6 +115,7 @@ typedef struct outgoing_t {
|
||||||
struct config_t *cfg;
|
struct config_t *cfg;
|
||||||
struct addrinfo *ai;
|
struct addrinfo *ai;
|
||||||
struct addrinfo *aip;
|
struct addrinfo *aip;
|
||||||
|
struct event ev;
|
||||||
} outgoing_t;
|
} outgoing_t;
|
||||||
|
|
||||||
extern int maxoutbufsize;
|
extern int maxoutbufsize;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "avl_tree.h"
|
#include "avl_tree.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "tevent.h"
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
@ -234,10 +233,11 @@ int setup_vpn_in_socket(const sockaddr_t *sa)
|
||||||
return nfd;
|
return nfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retry_outgoing(outgoing_t *outgoing)
|
static void retry_outgoing_handler(int fd, short events, void *data) {
|
||||||
{
|
retry_outgoing(data);
|
||||||
tevent_t *event;
|
}
|
||||||
|
|
||||||
|
void retry_outgoing(outgoing_t *outgoing) {
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
outgoing->timeout += 5;
|
outgoing->timeout += 5;
|
||||||
|
@ -245,11 +245,8 @@ void retry_outgoing(outgoing_t *outgoing)
|
||||||
if(outgoing->timeout > maxtimeout)
|
if(outgoing->timeout > maxtimeout)
|
||||||
outgoing->timeout = maxtimeout;
|
outgoing->timeout = maxtimeout;
|
||||||
|
|
||||||
event = new_tevent();
|
timeout_set(&outgoing->ev, retry_outgoing_handler, outgoing);
|
||||||
event->handler = (event_handler_t) setup_outgoing_connection;
|
event_add(&outgoing->ev, &(struct timeval){outgoing->timeout, 0});
|
||||||
event->time = now + outgoing->timeout;
|
|
||||||
event->data = outgoing;
|
|
||||||
tevent_add(event);
|
|
||||||
|
|
||||||
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
|
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
|
||||||
_("Trying to re-establish outgoing connection in %d seconds"),
|
_("Trying to re-establish outgoing connection in %d seconds"),
|
||||||
|
|
Loading…
Reference in a new issue