Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
My work was to get it at least work as before of 839cf89. I do not have time for any further work, so anyone else willing to do it is more than welcome. You can open a PR when you start the work and ask for review/suggestions if you get stuck. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366648433___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Hi, Daniel! I did more testing and provided change works. What do you think regarding proper solution with comparing call-id (as you mentioned in the beginning)? Because current change improve the situation, but it is not what is expected by RFC. Anyway - I think this changes should be committed. Regarding the following work, should we create another task, or leave this thread open? (I have plans to work on the task following weeks, and possibly will need advice/review) -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366646317___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Thanks, reopen (if related) or create a new item (if different) when something wrong pops up. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366631994___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Closed #1427. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#event-1480150056___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
thanks for the last patch, I tried it. Making the fast check the match of multiple dialog body works as expected. Let me do deeper testing today. Will report results later. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366179888___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
I just pushed patch 29d09b38fab5a1ee8d7f6f82818e3d3446d4dd8b for it. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366168714___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
my shame... I did not do NULL check and that was the reason for crash. With your logging added (processing same body and input PUBLISH as before): ``` Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:361]: ps_match_dialog_state_from_body(): vstate is terminated, tmp_state is terminated Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:388]: ps_match_dialog_state_from_body(): do entered Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:396]: ps_match_dialog_state_from_body(): compared [dialog] with [text] Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:399]: ps_match_dialog_state_from_body(): node->next Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:388]: ps_match_dialog_state_from_body(): do entered Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:396]: ps_match_dialog_state_from_body(): compared [text] with [dialog] Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:399]: ps_match_dialog_state_from_body(): node->next Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:388]: ps_match_dialog_state_from_body(): do entered Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:396]: ps_match_dialog_state_from_body(): compared [dialog] with [text] Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:399]: ps_match_dialog_state_from_body(): node->next Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:388]: ps_match_dialog_state_from_body(): do entered Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:399]: ps_match_dialog_state_from_body(): node->next Feb 16 08:54:16 0050562c117c /usr/sbin/kamailio[30264]: ERROR: presence [presentity.c:406]: ps_match_dialog_state_from_body(): going to return rmatch 1 ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-366167097___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Put this do...while(): ``` /* search for next dialog node */ do { LM_ERR("do entered \n"); if(node->next != NULL && node->next->name != NULL && xmlStrcmp(node->name, node->next->name) == 0) { node = node->next; LM_ERR("break it \n"); break; } if(node->next != NULL && node->next->name != NULL) { LM_ERR("compared [%s] with [%s]\n", node->name, node->next->name); } node = node->next; LM_ERR("node->next \n"); } while(node != NULL); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365991818___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Hi, Daniel! Thank you for your help! I tried to print that value in logs, but get stuck a bit (I did not found how to print xml elements correctly). I got some sequence of crashes while attempts to add appropriate logs. What I tried more: I changed: ` && xmlStrcmp(node->name, node->next->name) == 0) { ` to ` && xmlStrcmp(node->next->name, (const xmlChar *)"dialog") == 0) { ` and now second dialog compare works, appropriate logs are (all is the same as in my latest comment): ``` Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:361]: ps_match_dialog_state_from_body(): vstate is terminated, tmp_state is terminated Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:375]: ps_match_dialog_state_from_body(): do entered Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:389]: ps_match_dialog_state_from_body(): node->next Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:375]: ps_match_dialog_state_from_body(): do entered Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:385]: ps_match_dialog_state_from_body(): break it Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:361]: ps_match_dialog_state_from_body(): vstate is terminated, tmp_state is confirmed Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:364]: ps_match_dialog_state_from_body(): states are different! goto done Feb 15 15:15:18 0050562c117c /usr/sbin/kamailio[8030]: ERROR: presence [presentity.c:395]: ps_match_dialog_state_from_body(): going to return rmatch 0 ``` in my understanding of your proposed patch, we compare: `node->name` - is always the name of current node `node->next->name` - name of next node such compare would match only if there are to consecutive "dialog" nodes. (and that did not happen in my yesterday's tests). Sorry if I'am writing/supposing something trivial or incorrect, I have never worked before with libxml and XML from C code as well. Thanks -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365941679___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Can you print `node->name` and `node->next->name` inside the `do { } while()` to see the names that are compared there? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365878809___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
re-tested it again, it does check only first dialog in a body your code with my custom logging ``` int ps_match_dialog_state_from_body(str body, int *is_dialog, char *vstate) { xmlDocPtr doc; xmlNodePtr node; xmlNodePtr childNode; char *tmp_state; int rmatch = 0; *is_dialog = 0; LM_ERR("** body to parse %s\n", body); doc = xmlParseMemory(body.s, body.len); if(doc == NULL || doc->children == NULL) { LM_ERR("failed to parse xml document\n"); return -1; } node = xmlNodeGetChildByName(doc->children, "dialog"); while(node != NULL) { *is_dialog = 1; childNode = xmlNodeGetChildByName(node, "state"); tmp_state = (char *)xmlNodeGetContent(childNode); if (tmp_state != NULL) { LM_ERR("vstate is %s, tmp_state is %s\n", vstate, tmp_state); if(strcmp(tmp_state, vstate)!=0) { LM_ERR("states are different! goto done \n"); xmlFree(tmp_state); rmatch = 0; goto done; } rmatch = 1; xmlFree(tmp_state); } /* search for next dialog node */ do { LM_ERR("do entered \n"); if(node->next != NULL && node->next->name != NULL && xmlStrcmp(node->name, node->next->name) == 0) { node = node->next; LM_ERR("break it \n"); break; } node = node->next; LM_ERR("node->next \n"); } while(node != NULL); } done: xmlFreeDoc(doc); LM_ERR("going to return rmatch %d\n", rmatch); return rmatch; } ``` body of PUBLISH, that being processed: ``` On the phone sip:252@10.100.1.85 sip:254@10.100.1.85 confirmed ``` logs printed by kamailio: ``` Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:321]: ps_match_dialog_state_from_body(): ** body to parse Ready 252 251 terminated On the phone sip:252@10.100.1.85 sip:254@10.100.1.85 confirmed Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:341]: ps_match_dialog_state_from_body(): vstate is terminated, tmp_state is terminated Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:355]: ps_match_dialog_state_from_body(): do entered Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:363]: ps_match_dialog_state_from_body(): node->next Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:355]: ps_match_dialog_state_from_body(): do entered Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:363]: ps_match_dialog_state_from_body(): node->next Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:355]: ps_match_dialog_state_from_body(): do entered Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:363]: ps_match_dialog_state_from_body(): node->next Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:355]: ps_match_dialog_state_from_body(): do entered Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:363]: ps_match_dialog_state_from_body(): node->next Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:369]: ps_match_dialog_state_from_body(): going to return rmatch 1 Feb 14 09:25:48 0050562c117c /usr/sbin/kamailio[29343]: ERROR: presence [presentity.c:559]: ps_match_dialog_state(): rmatch is 1 ``` so for some reason in `do { ... } while ()` it did not break. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365531427___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
The result: for multiple dialog bodie only first body checked (I added custom logging inside your code to see where it worked) -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365178957___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
What was the result of testing it? Not working? The `while()` is there to deal with xml docs that have many `dialog` nodes. The `do { ... } while ()` is to find the next node with `dialog` name. These are to be compliant with xml specs, as there can be other nodes with different names. So just doing `node=node->next` doesn't ensure it will be the next `dialog` node, but the next node in the xml document. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-365172882___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
I tried proposed changes. in ps_match_dialog_state_from_body there is a loop: while(node != NULL) { why do we need there one more while loop? What actually happens: . if(strcmp(tmp_state, vstate)!=0) { // here we come only once, when matching first dialog ... all later dialogs are iterating in the second while loop. as for me this part of code ``` + do { + if(node->next != NULL && node->next->name != NULL + && xmlStrcmp(node->name, node->next->name) == 0) { + node = node->next; + break; + } + node = node->next; + } while(node != NULL); ``` should look like: ``` node = node->next; ``` maybe that checks for NULL are also necessary, but not while do-while. General question - is there a way to propose changes in your custom branch? thanks for your help! -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-364987310___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
Hi, Daniel! thanks for the patch! will give it a try today -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-364885964___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
@vance-od - I tried a quick fix with the patches referenced above. Can you try with them and see if all ok? It relies on matching all related dialog states in the same xml document. If one found mismatching, then will not consider it terminated. Likely it can be improved with matching on callid, but this can be a starting point. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-364866447___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Re: [sr-dev] [kamailio/kamailio] presence: incorrect dialog state for multiple dialogs xml body (#1427)
@phil-lavin , can you take a look at this thread? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/1427#issuecomment-363106217___ Kamailio (SER) - Development Mailing List sr-dev@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev