From dcf62b0ecc7c3459badd4a67c85d328220a95d31 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 27 Nov 2010 06:50:41 +0000 Subject: one side of cleint connections works for recv git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@11 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/tcpproxy.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/tcpproxy.c') diff --git a/src/tcpproxy.c b/src/tcpproxy.c index d82b057..fce2e2c 100644 --- a/src/tcpproxy.c +++ b/src/tcpproxy.c @@ -38,15 +38,18 @@ #include "daemon.h" #include "listener.h" +#include "clients.h" int main_loop(options_t* opt, listeners_t* listeners) { log_printf(INFO, "entering main loop"); - int return_value = 0; int sig_fd = signal_init(); if(sig_fd < 0) - return_value -1; + return -1; + + clients_t clients; + int return_value = clients_init(&clients); while(!return_value) { fd_set readfds; @@ -54,6 +57,7 @@ int main_loop(options_t* opt, listeners_t* listeners) FD_SET(sig_fd, &readfds); int nfds = sig_fd; listener_read_fds(listeners, &readfds, &nfds); + clients_read_fds(&clients, &readfds, &nfds); int ret = select(nfds + 1, &readfds, NULL, NULL, NULL); if(ret == -1 && errno != EINTR) { log_printf(ERROR, "select returned with error: %s", strerror(errno)); @@ -70,10 +74,13 @@ int main_loop(options_t* opt, listeners_t* listeners) } } - return_value = listener_handle_accept(listeners, &readfds); + return_value = listener_handle_accept(listeners, &clients, &readfds); if(return_value) break; + + return_value = clients_read(&clients, &readfds); } + clients_clear(&clients); signal_stop(); return return_value; } -- cgit v1.2.3