#include "avl_tree.h"
#include "conf.h"
#include "connection.h"
-#include "tevent.h"
#include "logger.h"
#include "meta.h"
#include "net.h"
return nfd;
}
-void retry_outgoing(outgoing_t *outgoing)
-{
- tevent_t *event;
+static void retry_outgoing_handler(int fd, short events, void *data) {
+ retry_outgoing(data);
+}
+void retry_outgoing(outgoing_t *outgoing) {
cp();
outgoing->timeout += 5;
if(outgoing->timeout > maxtimeout)
outgoing->timeout = maxtimeout;
- event = new_tevent();
- event->handler = (event_handler_t) setup_outgoing_connection;
- event->time = now + outgoing->timeout;
- event->data = outgoing;
- tevent_add(event);
+ timeout_set(&outgoing->ev, retry_outgoing_handler, outgoing);
+ event_add(&outgoing->ev, &(struct timeval){outgoing->timeout, 0});
ifdebug(CONNECTIONS) logger(LOG_NOTICE,
_("Trying to re-establish outgoing connection in %d seconds"),
c->outgoing = outgoing;
c->last_ping_time = now;
+ connection_add(c);
+
+ do_outgoing_connection(c);
+
event_set(&c->ev, c->socket, EV_READ | EV_PERSIST, handle_meta_connection_data, c);
event_set(&c->outev, c->socket, EV_WRITE | EV_PERSIST, flush_meta, c);
if(event_add(&c->ev, NULL) < 0) {
- logger(LOG_ERR, _("event_add failed: %s"), strerror(errno));
- connection_del(c);
- return;
+ logger(LOG_EMERG, _("event_add failed: %s"), strerror(errno));
+ abort();
}
-
- connection_add(c);
-
- do_outgoing_connection(c);
}
/*