diff options
author | venaas <venaas> | 2008-09-18 11:10:44 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-09-18 11:10:44 +0000 |
commit | e153afc401ccb9256385a0a3da10bf412d87fe1f (patch) | |
tree | c8396299971af9241c237b2d62ebcc945e376c77 /udp.c | |
parent | 4f7c11c9ea5795ac0dd32540e5045d3fc10f0a89 (diff) |
fixed some bugs, improved duplicate detection
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@391 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -47,6 +47,7 @@ unsigned char *radudpget(int s, struct client **client, struct server **server, struct clsrvconf *p; struct list_node *node; fd_set readfds; + struct client *c = NULL; for (;;) { if (rad) { @@ -103,26 +104,27 @@ unsigned char *radudpget(int s, struct client **client, struct server **server, if (client) { pthread_mutex_lock(p->lock); - for (node = list_first(p->clients); node; node = list_next(node)) - if (addr_equal((struct sockaddr *)&from, ((struct client *)node->data)->addr)) + for (node = list_first(p->clients); node; node = list_next(node)) { + c = (struct client *)node->data; + if (s == c->sock && addr_equal((struct sockaddr *)&from, c->addr)) break; - if (node) { - *client = (struct client *)node->data; - pthread_mutex_unlock(p->lock); - break; } - fromcopy = addr_copy((struct sockaddr *)&from); - if (!fromcopy) { - pthread_mutex_unlock(p->lock); - continue; + if (!node) { + fromcopy = addr_copy((struct sockaddr *)&from); + if (!fromcopy) { + pthread_mutex_unlock(p->lock); + continue; + } + c = addclient(p, 0); + if (!c) { + free(fromcopy); + pthread_mutex_unlock(p->lock); + continue; + } + c->sock = s; + c->addr = fromcopy; } - *client = addclient(p, 0); - if (!*client) { - free(fromcopy); - pthread_mutex_unlock(p->lock); - continue; - } - (*client)->addr = fromcopy; + *client = c; pthread_mutex_unlock(p->lock); } else if (server) *server = p->servers; |