- last_ping_check = time(NULL);
-
- srand(time(NULL));
-
- running = true;
-
- while(running) {
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- /* XXX: libevent transition: old timeout code in this loop */
- timeout_set(&timeout, dummy, NULL);
- timeout_add(&timeout, &tv);
-
- r = build_fdset();
- if(r < 0) {
- logger(LOG_ERR, _("Error building fdset: %s"), strerror(errno));
- cp_trace();
- dump_connections();
- return 1;
- }
-
- r = event_loop(EVLOOP_ONCE);
- if(r < 0) {
- logger(LOG_ERR, _("Error while waiting for input: %s"),
- strerror(errno));
- cp_trace();
- dump_connections();
- return 1;
- }
-
- /* XXX: more libevent transition */
- timeout_del(&timeout);
-
- /* Let's check if everybody is still alive */
-
- if(last_ping_check + pingtimeout < time(NULL)) {
- check_dead_connections();
- last_ping_check = time(NULL);
- }
+ if(event_loop(0) < 0) {
+ logger(LOG_ERR, _("Error while waiting for input: %s"), strerror(errno));
+ return 1;