diff options
author | venaas <venaas> | 2007-10-10 09:20:51 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2007-10-10 09:20:51 +0000 |
commit | 326e0be389ddb33141527dd0f02e5db2511510f5 (patch) | |
tree | 83773687d48b5ba797088841e57f4373a1221705 | |
parent | 7e765c3b7cce6fbee1f6ac971fc4b88c272416e1 (diff) |
split clientrd into udpclientrd and tlsclientrd
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@182 e88ac4ed-0b26-0410-9574-a7f39faa03bf
-rw-r--r-- | radsecproxy.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/radsecproxy.c b/radsecproxy.c index 7e5fbc7..ad89cb3 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -1739,7 +1739,18 @@ int replyh(struct server *server, unsigned char *buf) { return 1; } -void *clientrd(void *arg) { +void *udpclientrd(void *arg) { + struct server *server = (struct server *)arg; + unsigned char *buf; + + for (;;) { + buf = radudpget(server->sock, NULL, &server, NULL); + if (!replyh(server, buf)) + free(buf); + } +} + +void *tlsclientrd(void *arg) { struct server *server = (struct server *)arg; unsigned char *buf; struct timeval lastconnecttry; @@ -1747,8 +1758,8 @@ void *clientrd(void *arg) { for (;;) { /* yes, lastconnecttry is really necessary */ lastconnecttry = server->lastconnecttry; - buf = (server->conf->type == 'U' ? radudpget(server->sock, NULL, &server, NULL) : radtlsget(server->ssl)); - if (!buf && server->conf->type == 'T') { + buf = radtlsget(server->ssl); + if (!buf) { tlsconnect(server, &lastconnecttry, "clientrd"); continue; } @@ -1784,14 +1795,16 @@ void *clientwr(void *arg) { if (server->conf->type == 'U') { if ((server->sock = connecttoserver(server->conf->addrinfo)) < 0) debugx(1, DBG_ERR, "clientwr: connecttoserver failed"); - } else + server->connectionok = 1; + if (pthread_create(&clientrdth, NULL, udpclientrd, (void *)server)) + debugx(1, DBG_ERR, "clientwr: pthread_create failed"); + } else { tlsconnect(server, NULL, "new client"); + server->connectionok = 1; + if (pthread_create(&clientrdth, NULL, tlsclientrd, (void *)server)) + debugx(1, DBG_ERR, "clientwr: pthread_create failed"); + } - server->connectionok = 1; - - if (pthread_create(&clientrdth, NULL, clientrd, (void *)server)) - debugx(1, DBG_ERR, "clientwr: pthread_create failed"); - for (;;) { pthread_mutex_lock(&server->newrq_mutex); if (!server->newrq) { |