From a1f132ae5a8720d5894d9231eefcd0bf046ce8d5 Mon Sep 17 00:00:00 2001 From: venaas Date: Fri, 26 Sep 2008 20:45:01 +0000 Subject: more abstracted refcounting git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@408 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- radsecproxy.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'radsecproxy.c') 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; -- cgit v1.2.3