Hello,

 

please keep the list in CC.

 

Not sure what you mean by multi-process safe. The functions are safe to use in a kamailio multi-process context, relevant sections should be protected by internal locks etc..

 

Regarding query location manually by SQL client, its better to use the provided functions from the usrloc/registrar module instead.

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: riffs@sina.cn <riffs@sina.cn>
Sent: Thursday, December 1, 2022 10:47 AM
To: Henning Westerholt <hw@gilawa.com>
Subject: Re: Re: [SR-Users] uac_req_send() multi-process synchronization problem

 

 

To confirm that. Are reg_fetch_contacts and unregister_ruid multi-process safe?

 

 


riffs@sina.cn

 

From: riffs@sina.cn

Date: 2022-12-01 16:35

To: Henning Westerholt

Subject: Re: RE: [SR-Users] uac_req_send() multi-process synchronization problem

Hello 

Thank you for your reply very much.  My LOCATION is stored in the MYSQL database, and I also set the event_callback parameter of TCPOPS.

modparam("tcpops", "event_callback", "ksr_tcpops_event")

 

At the same time.I also deleted the contact inside the function

function ksr_tcpops_event(evname)

    local tcpconnid = KSR.pv.get("$conid") or "0"

       if (evname == "tcp:reset" or evname == "tcp:closed") and (tonumber(tcpconnid) ~= 0)  then

        local sql = string.format("select * from location where tcpconnid=%s", tcpconnid)

        local count, rows = execute_select(sql)

        if count > 0 then

             KSR.registrar.unregister_ruid("location", rows[1].contact, rows[1].ruid)

        end

    end

    return 1

end

When I use use_req_send(), I use the following sql statement to query location

string.format("select * from location where username='%s'", reciever)

I think because the query sql is executed before the execution of unregister_ruid completes, the location of user A can still be queried.

If unregister_ruid and reg_fetch_contacts are multi-process safe. I use reg_fetch_contacts query location to avoid this problem. Is that so?

thanks very much

 

 

 


 

Date: 2022-11-30 18:18

CC: 刘建峰

Subject: RE: [SR-Users] uac_req_send() multi-process synchronization problem

Hello,

 

not sure if I fully understand the problem. But regarding another user is registered with the same IP address as a previous user, there are several mitigations.

 

To give two options: you could choose a really short re-registration time, you could use TCP and when you lose the connection you delete the contact.

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: sr-users <sr-users-bounces@lists.kamailio.org> On Behalf Of ???
Sent: Wednesday, November 30, 2022 2:57 AM
To: sr-users@lists.kamailio.org
Subject: [SR-Users] uac_req_send() multi-process synchronization problem

 

When I use uac_req_send() to send a MESSAGE to the client. Will the following occur? The result of the message sent to user A is that B has received it. From the logs, the address of user A in the location table is the same as the IP address and port of user B, and the information of user A in the location table is not deleted in time. I took the address of user A directly from the location table without using KSR.registrar.reg_fetch_contacts(). If I use KSR.registrar.reg_fetch_contacts() can this be avoided. This is a multi-process synchronization problem, after user A registers, the IP port information in the address is 172.16.22.222:12345, and then user A disconnects the link because of some abnormal conditions, but it is not normal to cancel the registration, the socket link has failed, but it has not had time to delete the location, at this time user B registers, whether will it get the same IP port information as user A 172.16.22.222 : 12345, if possible? User A's location still exists, Using KSR.registrar.reg_fetch_contacts() TO query user A's location, and then using uac_req_send() to send a message to user A, User B will receive the MESSAGE. Whether this problem occurs?

 

Windows 邮件发送