X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=a1ca9ab9c6891992b7a8f140f5920f0fc60466aa;hb=4d0621b1f39537699b0ec4655b0c6e6b84581c9a;hp=3a44ce66b61d151dd42329e1118a2d5c00c54f43;hpb=38c25d62c2bc76908bd95fb21c8f5e39ad269884;p=tinc diff --git a/src/net.c b/src/net.c index 3a44ce66..a1ca9ab9 100644 --- a/src/net.c +++ b/src/net.c @@ -128,17 +128,9 @@ static int build_fdset(void) connection_del(c); if(!connection_tree->head) purge(); - } else { - short events = EV_READ; - if(c->outbuflen > 0) - events |= EV_WRITE; - event_del(&c->ev); - event_set(&c->ev, c->socket, events, - handle_meta_connection_data, c); - if (event_add(&c->ev, NULL) < 0) - return -1; } } + return 0; } @@ -168,6 +160,8 @@ void terminate_connection(connection_t *c, bool report) if(c->socket) closesocket(c->socket); + event_del(&c->ev); + if(c->edge) { if(report && !tunnelserver) send_del_edge(broadcast, c->edge); @@ -274,33 +268,25 @@ void handle_meta_connection_data(int fd, short events, void *data) if (c->status.remove) return; - if (events & EV_READ) { - if(c->status.connecting) { - c->status.connecting = false; - getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); - - if(!result) - finish_connecting(c); - else { - ifdebug(CONNECTIONS) logger(LOG_DEBUG, - _("Error while connecting to %s (%s): %s"), - c->name, c->hostname, strerror(result)); - closesocket(c->socket); - do_outgoing_connection(c); - return; - } - } - - if (!receive_meta(c)) { - terminate_connection(c, c->status.active); + if(c->status.connecting) { + c->status.connecting = false; + getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); + + if(!result) + finish_connecting(c); + else { + ifdebug(CONNECTIONS) logger(LOG_DEBUG, + _("Error while connecting to %s (%s): %s"), + c->name, c->hostname, strerror(result)); + closesocket(c->socket); + do_outgoing_connection(c); return; } } - if (events & EV_WRITE) { - if(!flush_meta(c)) { - terminate_connection(c, c->status.active); - } + if (!receive_meta(c)) { + terminate_connection(c, c->status.active); + return; } } @@ -315,7 +301,7 @@ int main_loop(void) { struct timeval tv; int r; - time_t last_ping_check, last_config_check, last_graph_dump; + time_t last_ping_check, last_config_check; tevent_t *event; struct event timeout; @@ -323,7 +309,6 @@ int main_loop(void) last_ping_check = now; last_config_check = now; - last_graph_dump = now; srand(now); @@ -445,13 +430,6 @@ int main_loop(void) try_outgoing_connections(); } - - /* Dump graph if wanted every 60 seconds*/ - - if(last_graph_dump + 60 < now) { - dump_graph(); - last_graph_dump = now; - } } return 0;