Commit a1f132ae authored by venaas's avatar venaas Committed by venaas
Browse files

more abstracted refcounting

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@408 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent 8be5ce2b
...@@ -897,6 +897,11 @@ unsigned char *attrget(unsigned char *attrs, int length, uint8_t type) { ...@@ -897,6 +897,11 @@ unsigned char *attrget(unsigned char *attrs, int length, uint8_t type) {
return NULL; return NULL;
} }
struct request *newrqref(struct request *rq) {
rq->refcount++;
return rq;
}
void freerq(struct request *rq) { void freerq(struct request *rq) {
if (!rq) if (!rq)
return; return;
...@@ -1648,8 +1653,7 @@ void respond(struct request *rq, uint8_t code, char *message) { ...@@ -1648,8 +1653,7 @@ void respond(struct request *rq, uint8_t code, char *message) {
radmsg_free(rq->msg); radmsg_free(rq->msg);
rq->msg = msg; rq->msg = msg;
debug(DBG_DBG, "respond: sending %s to %s", radmsgtype2string(msg->code), rq->from->conf->host); debug(DBG_DBG, "respond: sending %s to %s", radmsgtype2string(msg->code), rq->from->conf->host);
rq->refcount++; sendreply(newrqref(rq));
sendreply(rq);
} }
struct clsrvconf *choosesrvconf(struct list *srvconfs) { struct clsrvconf *choosesrvconf(struct list *srvconfs) {
...@@ -1725,8 +1729,7 @@ int addclientrq(struct request *rq) { ...@@ -1725,8 +1729,7 @@ int addclientrq(struct request *rq) {
if (now.tv_sec - r->created.tv_sec < r->from->conf->dupinterval) { if (now.tv_sec - r->created.tv_sec < r->from->conf->dupinterval) {
if (r->replybuf) { if (r->replybuf) {
debug(DBG_INFO, "addclientrq: already sent reply to request with id %d from %s, resending", rq->rqid, addr2string(r->from->addr)); debug(DBG_INFO, "addclientrq: already sent reply to request with id %d from %s, resending", rq->rqid, addr2string(r->from->addr));
r->refcount++; sendreply(newrqref(r));
sendreply(r);
} else } else
debug(DBG_INFO, "addclientrq: already got request with id %d from %s, ignoring", rq->rqid, addr2string(r->from->addr)); debug(DBG_INFO, "addclientrq: already got request with id %d from %s, ignoring", rq->rqid, addr2string(r->from->addr));
return 0; return 0;
...@@ -1734,8 +1737,7 @@ int addclientrq(struct request *rq) { ...@@ -1734,8 +1737,7 @@ int addclientrq(struct request *rq) {
} }
freerq(r); freerq(r);
} }
rq->refcount++; rq->from->rqs[rq->rqid] = newrqref(rq);
rq->from->rqs[rq->rqid] = rq;
return 1; return 1;
} }
...@@ -2001,8 +2003,7 @@ void replyh(struct server *server, unsigned char *buf) { ...@@ -2001,8 +2003,7 @@ void replyh(struct server *server, unsigned char *buf) {
debug(DBG_INFO, "replyh: passing reply to client %s", from->conf->name); debug(DBG_INFO, "replyh: passing reply to client %s", from->conf->name);
radmsg_free(rqout->rq->msg); radmsg_free(rqout->rq->msg);
rqout->rq->msg = msg; rqout->rq->msg = msg;
rqout->rq->refcount++; sendreply(newrqref(rqout->rq));
sendreply(rqout->rq);
freerqoutdata(rqout); freerqoutdata(rqout);
pthread_mutex_unlock(rqout->lock); pthread_mutex_unlock(rqout->lock);
return; return;
......
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