summaryrefslogtreecommitdiff
path: root/radsecproxy.c
diff options
context:
space:
mode:
authorvenaas <venaas>2008-09-26 20:45:01 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-09-26 20:45:01 +0000
commita1f132ae5a8720d5894d9231eefcd0bf046ce8d5 (patch)
tree8bbdf2e334d7992561ce09bdc5cc39ab8022ddca /radsecproxy.c
parent8be5ce2bcac0f8063d05e4a0561b71fcb63d88d4 (diff)
more abstracted refcounting
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@408 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'radsecproxy.c')
-rw-r--r--radsecproxy.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/radsecproxy.c b/radsecproxy.c
index 53935f2..ba342fe 100644
--- a/radsecproxy.c
+++ b/radsecproxy.c
@@ -897,6 +897,11 @@ unsigned char *attrget(unsigned char *attrs, int length, uint8_t type) {
return NULL;
}
+struct request *newrqref(struct request *rq) {
+ rq->refcount++;
+ return rq;
+}
+
void freerq(struct request *rq) {
if (!rq)
return;
@@ -1648,8 +1653,7 @@ void respond(struct request *rq, uint8_t code, char *message) {
radmsg_free(rq->msg);
rq->msg = msg;
debug(DBG_DBG, "respond: sending %s to %s", radmsgtype2string(msg->code), rq->from->conf->host);
- rq->refcount++;
- sendreply(rq);
+ sendreply(newrqref(rq));
}
struct clsrvconf *choosesrvconf(struct list *srvconfs) {
@@ -1725,8 +1729,7 @@ int addclientrq(struct request *rq) {
if (now.tv_sec - r->created.tv_sec < r->from->conf->dupinterval) {
if (r->replybuf) {
debug(DBG_INFO, "addclientrq: already sent reply to request with id %d from %s, resending", rq->rqid, addr2string(r->from->addr));
- r->refcount++;
- sendreply(r);
+ sendreply(newrqref(r));
} else
debug(DBG_INFO, "addclientrq: already got request with id %d from %s, ignoring", rq->rqid, addr2string(r->from->addr));
return 0;
@@ -1734,8 +1737,7 @@ int addclientrq(struct request *rq) {
}
freerq(r);
}
- rq->refcount++;
- rq->from->rqs[rq->rqid] = rq;
+ rq->from->rqs[rq->rqid] = newrqref(rq);
return 1;
}
@@ -2001,8 +2003,7 @@ void replyh(struct server *server, unsigned char *buf) {
debug(DBG_INFO, "replyh: passing reply to client %s", from->conf->name);
radmsg_free(rqout->rq->msg);
rqout->rq->msg = msg;
- rqout->rq->refcount++;
- sendreply(rqout->rq);
+ sendreply(newrqref(rqout->rq));
freerqoutdata(rqout);
pthread_mutex_unlock(rqout->lock);
return;