Commit 036bbbf5 authored by venaas's avatar venaas Committed by venaas
Browse files

bug fixing

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@34 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent ec687014
...@@ -494,17 +494,24 @@ void sendrq(struct server *to, struct client *from, struct request *rq) { ...@@ -494,17 +494,24 @@ void sendrq(struct server *to, struct client *from, struct request *rq) {
int i; int i;
pthread_mutex_lock(&to->newrq_mutex); pthread_mutex_lock(&to->newrq_mutex);
/* might simplify if only try nextid, might be ok */
/* should search from where inserted last */ for (i = to->nextid; i < MAX_REQUESTS; i++)
for (i = 0; i < MAX_REQUESTS; i++)
if (!to->requests[i].buf) if (!to->requests[i].buf)
break; break;
if (i == MAX_REQUESTS) { if (i == MAX_REQUESTS) {
printf("No room in queue, dropping request\n"); for (i = 0; i < to->nextid; i++)
pthread_mutex_unlock(&to->newrq_mutex); if (!to->requests[i].buf)
return; break;
if (i == to->nextid) {
printf("No room in queue, dropping request\n");
pthread_mutex_unlock(&to->newrq_mutex);
return;
}
} }
to->nextid = i + 1;
rq->buf[1] = (char)i; rq->buf[1] = (char)i;
printf("sendrq: inserting packet with id %d in queue for %s\n", i, to->peer.host);
if (!createmessageauth(rq->buf, rq->messageauthattrval, to->peer.secret)) if (!createmessageauth(rq->buf, rq->messageauthattrval, to->peer.secret))
return; return;
......
...@@ -95,6 +95,7 @@ struct server { ...@@ -95,6 +95,7 @@ struct server {
pthread_t clientth; pthread_t clientth;
struct timeval lastconnecttry; struct timeval lastconnecttry;
uint8_t connectionok; uint8_t connectionok;
int nextid;
struct request *requests; struct request *requests;
uint8_t newrq; uint8_t newrq;
pthread_mutex_t newrq_mutex; pthread_mutex_t newrq_mutex;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment