fixup backup1
authorAndreas Eversberg <jolly@eversberg.eu>
Fri, 1 Dec 2017 16:38:49 +0000 (17:38 +0100)
committerAndreas Eversberg <jolly@eversberg.eu>
Fri, 1 Dec 2017 16:38:49 +0000 (17:38 +0100)
sip.cpp

diff --git a/sip.cpp b/sip.cpp
index ff8ed89..b5d9635 100644 (file)
--- a/sip.cpp
+++ b/sip.cpp
@@ -2201,6 +2201,7 @@ static void sip_callback(nua_event_t event, int status, char const *phrase, nua_
                if ((port->p_type & PORT_CLASS_mISDN_MASK) == PORT_CLASS_SIP) {
                        psip = (class Psip *)port;
                        if (psip->p_s_handle == nh) {
+                               PDEBUG(DEBUG_SIP, "Event found for port %s\n", psip->p_name);
                                break;
                        }
                }
@@ -2210,18 +2211,21 @@ static void sip_callback(nua_event_t event, int status, char const *phrase, nua_
                psip = NULL;
 
        /* new handle */
-       if (!psip && !inst->register_handle) {
-               switch (event) {
-               case nua_i_options:
+       switch (event) {
+       case nua_i_options:
+               if (!inst->register_handle) {
                        PDEBUG(DEBUG_SIP, "New options instance\n");
                        inst->register_handle = nh;
-                       break;
-               case nua_i_register:
+               }
+               break;
+       case nua_i_register:
+               if (!inst->register_handle) {
                        PDEBUG(DEBUG_SIP, "New register instance\n");
                        inst->register_handle = nh;
-                       break;
-               case nua_i_invite:
-                   {
+               }
+               break;
+       case nua_i_invite:
+               if (!psip) {
                        char name[64];
                        struct interface *interface = interface_first;
 
@@ -2238,9 +2242,10 @@ static void sip_callback(nua_event_t event, int status, char const *phrase, nua_
                                FATAL("Cannot find interface %s.\n", inst->interface_name);
                        if (!(psip = new Psip(PORT_TYPE_SIP_IN, name, NULL, interface)))
                                FATAL("Cannot create Port instance.\n");
-                       break;
-                   }
-               default:
+               }
+               break;
+       default:
+               if (!psip && !inst->register_handle) {
                        PDEBUG(DEBUG_SIP, "Destroying unknown instance\n");
                        nua_handle_destroy(nh);
                        return;