Module: sip-router Branch: master Commit: e040485765e1d456c14d45de2d2c85bfd5bc5903 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e0404857...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Tue Mar 2 17:41:37 2010 +0100
core: added missing parsed flags & minor get_hdr optimization
- parsed flags were not set for some headers (ACCEPTCONTACT, ALLOWEVENTS, CONTENTENCODING, REFERREDBY, REJECTCONTACT, REQUESTDISPOSITION, WWW_AUTHENTICATE, PROXY_AUTHENTICATE, RETRY_AFTER).
- get_hdr() now checks first if the required header type was parsed using the parsed flags. If it was not, it exists immediately (it does not try to search through all the headers anymore).
---
parser/msg_parser.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/parser/msg_parser.c b/parser/msg_parser.c index 97378c7..a2a834e 100644 --- a/parser/msg_parser.c +++ b/parser/msg_parser.c @@ -364,7 +364,8 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next) case HDR_WWW_AUTHENTICATE_T: case HDR_PROXY_AUTHENTICATE_T: case HDR_RETRY_AFTER_T: - case HDR_OTHER_T: /*do nothing*/ + case HDR_OTHER_T: /* mark the type as found/parsed*/ + msg->parsed_flag|=HDR_T2F(hf->type); break; case HDR_CALLID_T: if (msg->callid==0) msg->callid=hf; @@ -830,9 +831,10 @@ struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht) { struct hdr_field *hdr;
- for(hdr = msg->headers; hdr; hdr = hdr->next) { - if(hdr->type == ht) return hdr; - } + if (msg->parsed_flag & HDR_T2F(ht)) + for(hdr = msg->headers; hdr; hdr = hdr->next) { + if(hdr->type == ht) return hdr; + } return NULL; }