Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling jsonrpc_notification fail in failure route when fr_timer timeout #713

Closed
ianlin opened this issue Jul 16, 2016 · 4 comments
Closed

Comments

@ianlin
Copy link
Contributor

ianlin commented Jul 16, 2016

Environment

Kamailio 4.3.3
Ubuntu 14.04.1 x86_64

Problem

I'm using t_suspend() and t_continue() for mobile push notification scenario. Before calling t_suspend() I set the fr_timer to 12 seconds and t_on_failure() to my custom failure route (e.g. failure_route[MY_FAILURE_ROUTE]). The scenario is fairly similar to [SR-Users] Timeout after t_suspend and failure route, the only difference is I try to use jsonrpc_notificaion() to notify the user asynchronously in my custom failure route.

There are 2 different results depending on how it goes to the failure route:

  1. Caller cancel the call before fr_timer expires
    • jsonrpc_notification can successfully be called in failure route
  2. The fr_timer did timeout after 12 seconds
    • An error occurred while calling jsonrpc_notification:
    • jsonrpc_notification(): failed to write to io pipe: Bad file descriptor

Investigation

For the first case that perform normally, the IDs of Kamailio processes being used are the same for both calling t_suspend() and entering failure route, while in the second case the processes are different.

Following added some debug messages in Kamailio's main.c it showed that the process being used in the failure route of case 2 is slow timer process, and from jsonrpc_mod.c's child_init() function, the rank of slow timer process is -1 therefore it doesn't assign the fd to this process.

My workaround was just assigning the fd to each child during child_init() in jsonrpc_mod.c but that's definitely not a good way to go. I am appreciated if you can give me some advice to solve this problem correctly.

Cheers,
Ian

@miconda
Copy link
Member

miconda commented Jul 19, 2016

Can you paste here the patch to the solution you tried?

@ianlin
Copy link
Contributor Author

ianlin commented Jul 20, 2016

Thanks for replying. Here it is. As I said this is not a good solution.

--- jsonrpc_mod.c.orig
+++ jsonrpc_mod.c
@@ -120,7 +120,6 @@
 {
    int pid;

-   if (rank>PROC_MAIN)
        cmd_pipe = pipe_fds[1];

    if (rank!=PROC_MAIN)

miconda added a commit that referenced this issue Sep 12, 2016
@miconda
Copy link
Member

miconda commented Sep 12, 2016

Thanks, finally got back to this one after holidays season, pushing a slightly different patch to master branch (it will be backported).

@miconda miconda closed this as completed Sep 12, 2016
@ianlin
Copy link
Contributor Author

ianlin commented Sep 13, 2016

Thanks!

miconda added a commit that referenced this issue Sep 14, 2016
- reported by Ian Yu-Hsun Lin, GH #713

(cherry picked from commit 3b31c51)
miconda added a commit that referenced this issue Jun 13, 2017
- reported by Ian Yu-Hsun Lin, GH #713

(cherry picked from commit 3b31c51)
(cherry picked from commit f5017b0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants