Module: sems
Branch: master
Commit: 9a732d46eb5d1ca387cefaf81596f07c8b50c1ed
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=9a732d46eb5d1ca387cefaf81596f07c8b50c1ed

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Tue Sep 27 08:31:49 2011 +0200

registrar_client: allow for custom handles to avoid race conditions.

---

 apps/registrar_client/SIPRegistrarClient.cpp |   13 ++++++++-----
 apps/registrar_client/SIPRegistrarClient.h   |    3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/apps/registrar_client/SIPRegistrarClient.cpp 
b/apps/registrar_client/SIPRegistrarClient.cpp
index cd0145d..c0110cc 100644
--- a/apps/registrar_client/SIPRegistrarClient.cpp
+++ b/apps/registrar_client/SIPRegistrarClient.cpp
@@ -331,14 +331,15 @@ string SIPRegistrarClient::createRegistration(const 
string& domain,
                                              const string& pwd,
                                              const string& sess_link,
                                              const string& proxy,
-                                              const string& contact) {
+                                              const string& contact,
+                                             const string& handle) {
        
-  string handle = AmSession::getNewId();
+  string l_handle = handle.empty() ? AmSession::getNewId() : handle;
   instance()->
     postEvent(new SIPNewRegistrationEvent(SIPRegistrationInfo(domain, user, 
                                                              name, auth_user, 
pwd, 
                                                              proxy, contact),
-                                         handle, sess_link));
+                                         l_handle, sess_link));
   return handle;
 }
 
@@ -390,11 +391,13 @@ void SIPRegistrarClient::invoke(const string& method, 
const AmArg& args,
                                AmArg& ret)
 {
   if(method == "createRegistration"){
-    string proxy, contact;
+    string proxy, contact, handle;
     if (args.size() > 6)
       proxy = args.get(6).asCStr();
     if (args.size() > 7)
       contact = args.get(7).asCStr();
+    if (args.size() > 8)
+      handle = args.get(8).asCStr();
 
     ret.push(createRegistration(args.get(0).asCStr(),
                                args.get(1).asCStr(),
@@ -402,7 +405,7 @@ void SIPRegistrarClient::invoke(const string& method, const 
AmArg& args,
                                args.get(3).asCStr(),
                                args.get(4).asCStr(),
                                args.get(5).asCStr(),
-                               proxy, contact
+                               proxy, contact, handle
                                ).c_str());
   }
   else if(method == "removeRegistration"){
diff --git a/apps/registrar_client/SIPRegistrarClient.h 
b/apps/registrar_client/SIPRegistrarClient.h
index 6a80566..7ba5d5f 100644
--- a/apps/registrar_client/SIPRegistrarClient.h
+++ b/apps/registrar_client/SIPRegistrarClient.h
@@ -95,7 +95,8 @@ class SIPRegistrarClient  : public AmThread,
                            const string& pwd,
                            const string& sess_link,
                            const string& proxy,
-                           const string& contact);
+                           const string& contact,
+                           const string& handle);
   void removeRegistration(const string& handle);
 
   bool hasRegistration(const string& handle);

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to