]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5431: --resolve fix socket creation loop for mod_skinny to avoid segfault
authorNathan Neulinger <nneul@neulinger.org>
Thu, 23 May 2013 13:13:44 +0000 (08:13 -0500)
committerNathan Neulinger <nneul@neulinger.org>
Fri, 31 May 2013 20:10:43 +0000 (15:10 -0500)
src/mod/endpoints/mod_skinny/mod_skinny.c

index 792895a3e4988c4c3ab012cb0a13d2e9e2f4efc5..3a590e4433213041431840fa1af0112b84a42d4e 100644 (file)
@@ -1543,7 +1543,7 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void
        }
 
 new_socket:
-       while(globals.running) {
+       while(globals.running && !profile->sock) {
                char *listening_ip = NULL;
                switch_clear_flag_locked(profile, PFLAG_RESPAWN);
                rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool);
@@ -1570,6 +1570,10 @@ new_socket:
                break;
 sock_fail:
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error! Could not listen on %s:%u\n", profile->ip, profile->port);
+               if (profile->sock) {
+                       close_socket(&profile->sock, profile);
+                       profile->sock = NULL;
+               }
                switch_yield(100000);
        }
 
@@ -1582,6 +1586,8 @@ sock_fail:
                        goto fail;
                }
 
+               assert(profile->sock);
+
                if ((rv = switch_socket_accept(&inbound_socket, profile->sock, listener_pool))) {
                        if (!globals.running) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n");