topos: handle return code for parse_headers()
[sip-router] / src / modules / topos / topos_mod.c
index dfa8a77..0141c0f 100644 (file)
@@ -240,19 +240,21 @@ int tps_prepare_msg(sip_msg_t *msg)
                return 1;
        }
 
-       if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
-               LM_DBG("parsing headers failed [[%.*s]]\n",
-                               msg->len, msg->buf);
-               return 2;
+       if(parse_headers(msg, HDR_VIA2_F, 0)<0) {
+               LM_DBG("no via2 has been parsed\n");
        }
 
-       parse_headers(msg, HDR_VIA2_F, 0);
-
        if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
                LM_ERR("cannot parse cseq header\n");
                return -1;
        }
 
+       if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
+               LM_DBG("parsing headers failed [[%.*s]]\n",
+                               msg->len, msg->buf);
+               return 2;
+       }
+
        if(parse_from_header(msg)<0) {
                LM_ERR("cannot parse FROM header\n");
                return 3;