Skip to content

Commit

Permalink
sess,request: deref request and ctrans immediately (#1099)
Browse files Browse the repository at this point in the history
if no provisional response was received for the request.
  • Loading branch information
maximilianfridrich authored Apr 17, 2024
1 parent 9d00480 commit 3a60c39
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/re_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ int sip_drequestf(struct sip_request **reqp, struct sip *sip, bool stateful,
void sip_request_cancel(struct sip_request *req);
bool sip_request_loops(struct sip_loopstate *ls, uint16_t scode);
void sip_loopstate_reset(struct sip_loopstate *ls);
bool sip_request_provrecv(const struct sip_request *req);


/* reply */
Expand Down
17 changes: 16 additions & 1 deletion src/sip/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,13 +970,28 @@ void sip_request_cancel(struct sip_request *req)

req->canceled = true;

if (!req->provrecv)
if (!req->provrecv) {
req->ct = mem_deref(req->ct);
return;
}

(void)sip_ctrans_cancel(req->ct);
}


/**
* Check if a provisional response was received for a SIP Request
*
* @param req SIP Request
*
* @return True if a provisional response was received, false otherwise
*/
bool sip_request_provrecv(const struct sip_request *req)
{
return req ? req->provrecv : false;
}


void sip_request_close(struct sip *sip)
{
if (!sip)
Expand Down
9 changes: 7 additions & 2 deletions src/sipsess/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ static bool termwait(struct sipsess *sess)

if (sess->req) {
sip_request_cancel(sess->req);
mem_ref(sess);
wait = true;
if (!sip_request_provrecv(sess->req)) {
sess->req = mem_deref(sess->req);
}
else {
mem_ref(sess);
wait = true;
}
}

if (sess->replyl.head) {
Expand Down

0 comments on commit 3a60c39

Please sign in to comment.