summaryrefslogtreecommitdiff
path: root/src/tcpproxy.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-11-27 06:50:41 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-11-27 06:50:41 +0000
commitdcf62b0ecc7c3459badd4a67c85d328220a95d31 (patch)
tree6456dfe8b93fa2dfb4631191519c510c5b3975af /src/tcpproxy.c
parentadded initial (not working) version of client list (diff)
one side of cleint connections works for recv
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@11 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
Diffstat (limited to 'src/tcpproxy.c')
-rw-r--r--src/tcpproxy.c13
1 files changed, 10 insertions, 3 deletions
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;
}