]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Skinny: no need for heartbeat event to handle keepalive timeout
authorMathieu Parent <math.parent@gmail.com>
Thu, 23 Sep 2010 17:48:25 +0000 (19:48 +0200)
committerMathieu Parent <math.parent@gmail.com>
Thu, 23 Sep 2010 17:51:14 +0000 (19:51 +0200)
src/mod/endpoints/mod_skinny/mod_skinny.c
src/mod/endpoints/mod_skinny/mod_skinny.h
src/mod/endpoints/mod_skinny/skinny_protocol.c

index 165815078b21d32c3d29cf06d153f95ceb756b98..c67c20fde46b5479c75c70e08a508ae040a3a5b6 100644 (file)
@@ -1343,19 +1343,6 @@ static switch_status_t kill_listener(listener_t *listener, void *pvt)
        return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t kill_expired_listener(listener_t *listener, void *pvt)
-{
-       switch_event_t *event = NULL;
-
-       if(listener->expire_time < switch_epoch_time_now(NULL)) {
-               /* skinny::expire event */
-               skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_EXPIRE);
-               switch_event_fire(&event);
-               return kill_listener(listener, pvt);
-       }
-       return SWITCH_STATUS_SUCCESS;
-}
-
 switch_status_t keepalive_listener(listener_t *listener, void *pvt)
 {
        skinny_profile_t *profile;
@@ -1414,6 +1401,13 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
                                case SWITCH_STATUS_TIMEOUT:
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Communication Time Out with %s:%d.\n",
                                                listener->remote_ip, listener->remote_port);
+
+                                       if(listener->expire_time < switch_epoch_time_now(NULL)) {
+                                               switch_event_t *event = NULL;
+                                               /* skinny::expire event */
+                                               skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_EXPIRE);
+                                               switch_event_fire(&event);
+                                       }
                                        break;
                                default: 
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Communication Error with %s:%d.\n",
@@ -1917,11 +1911,6 @@ static switch_status_t load_skinny_config(void)
        return SWITCH_STATUS_SUCCESS;
 }
 
-static void skinny_heartbeat_event_handler(switch_event_t *event)
-{
-       walk_listeners(kill_expired_listener, NULL);
-}
-
 static void skinny_call_state_event_handler(switch_event_t *event)
 {
        char *subclass;
@@ -2129,10 +2118,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load)
                return SWITCH_STATUS_TERM;
        }
        /* bind to events */
-       if ((switch_event_bind_removable(modname, SWITCH_EVENT_HEARTBEAT, NULL, skinny_heartbeat_event_handler, NULL, &globals.heartbeat_node) != SWITCH_STATUS_SUCCESS)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Couldn't bind our heartbeat handler!\n");
-               /* Not such severe to prevent loading */
-       }
        if ((switch_event_bind_removable(modname, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_CALL_STATE, skinny_call_state_event_handler, NULL, &globals.call_state_node) != SWITCH_STATUS_SUCCESS)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind our call_state handler!\n");
                return SWITCH_STATUS_TERM;
@@ -2205,7 +2190,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skinny_shutdown)
        skinny_api_unregister();
        
        /* release events */
-       switch_event_unbind(&globals.heartbeat_node);
        switch_event_unbind(&globals.call_state_node);
        switch_event_unbind(&globals.message_waiting_node);
        switch_event_unbind(&globals.trap_node);
index bbd318b7462bec396e54cb90c31df6d7e8a3cf56..7a4df6ff03f0232a37a0955da571b40371bd6f54 100644 (file)
@@ -49,7 +49,6 @@ struct skinny_globals {
     switch_memory_pool_t *pool;
     switch_mutex_t *mutex;
     switch_hash_t *profile_hash;
-    switch_event_node_t *heartbeat_node;
     switch_event_node_t *call_state_node;
     switch_event_node_t *message_waiting_node;
     switch_event_node_t *trap_node;
index 1aea8125745f9449d083cf24581c4643614b8e22..465e41b21c92be6fc2ba5931c771fb6e52b13b2d 100644 (file)
@@ -135,6 +135,10 @@ switch_status_t skinny_read_packet(listener_t *listener, skinny_message_t **req)
 
                status = switch_socket_recv(listener->sock, ptr, &mlen);
 
+               if (listener->expire_time && listener->expire_time < switch_epoch_time_now(NULL)) {
+                       return SWITCH_STATUS_TIMEOUT;
+               }
+
                if (!listener_is_ready(listener)) {
                        break;
                }