]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Dec 2007 15:10:55 +0000 (15:10 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 13 Dec 2007 15:10:55 +0000 (15:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6747 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_dptools/mod_dptools.c
src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c
src/switch_rtp.c

index 01f72fa1daf25c579156da102c3a337db4d3cfeb..2ebe74375f3db63ab152ac76bd6bd7f2e3738872 100644 (file)
@@ -658,7 +658,7 @@ SWITCH_STANDARD_APP(info_function)
                switch_channel_event_set_data(channel, event);
                switch_event_serialize(event, &buf, SWITCH_FALSE);
                switch_assert(buf);
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:\n%s\n", buf);
                switch_event_destroy(&event);
                free(buf);
        }
index 789aab00a517b120efa17a4c2fbe0e040d86af9f..4d3deca02a9a05f843d2a7fc53c0e375fea6152c 100644 (file)
@@ -278,7 +278,7 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
                        switch_channel_event_set_data(channel, event);
                        switch_event_serialize(event, &buf, SWITCH_FALSE);
                        switch_assert(buf);
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:\n%s\n", buf);
                        switch_event_destroy(&event);
                        free(buf);
                }
index 2623ffb55a59d7ad79ee1e386c94e25b5c7bfe71..adcc2cebd4820edf6ca36b8ea437d20c63426e35 100644 (file)
@@ -310,17 +310,17 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port)
         return END_PORT;
 }
 
-static void release_port(switch_rtp_t *rtp_session)
+static void release_port(const char *host, int port)
 {
        switch_core_port_allocator_t *alloc = NULL;
 
-       if (!rtp_session->rx_host) {
+       if (!host) {
                return;
        }
 
     switch_mutex_lock(port_lock);
-    if ((alloc = switch_core_hash_find(alloc_hash, rtp_session->rx_host))) {
-               switch_core_port_allocator_free_port(alloc, rtp_session->rx_port);
+    if ((alloc = switch_core_hash_find(alloc_hash, host))) {
+               switch_core_port_allocator_free_port(alloc, port);
        }
        switch_mutex_unlock(port_lock);
 
@@ -412,7 +412,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
                *err = "Send myself a packet failed!";
                goto done;
        }
-       release_port(rtp_session);
        
        old_sock = rtp_session->sock;
        rtp_session->sock = new_sock;
@@ -429,12 +428,6 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
 
   done:
 
-       if (status == SWITCH_STATUS_SUCCESS) {
-               rtp_session->rx_host = switch_core_strdup(rtp_session->pool, host);
-               rtp_session->rx_port = port;
-               rtp_session->ready = 1;
-       }
-
        if (new_sock) {
                switch_socket_close(new_sock);
        }
@@ -611,21 +604,31 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
                                                                                          uint32_t ms_per_packet,
                                                                                          switch_rtp_flag_t flags, char *crypto_key, char *timer_name, const char **err, switch_memory_pool_t *pool)
 {
-       switch_rtp_t *rtp_session;
-
+       switch_rtp_t *rtp_session = NULL;
+       
        if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, crypto_key, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
-               return NULL;
+               goto end;
        }
-
+       
        if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, err) != SWITCH_STATUS_SUCCESS) {
-               return NULL;
+               rtp_session = NULL;
+               goto end;
        }
 
        if (switch_rtp_set_local_address(rtp_session, rx_host, rx_port, err) != SWITCH_STATUS_SUCCESS) {
-               return NULL;
+               rtp_session = NULL;
+       }
+
+ end:
+
+       if (rtp_session) {
+               rtp_session->ready = 1;
+               rtp_session->rx_host = switch_core_strdup(rtp_session->pool, rx_host);
+               rtp_session->rx_port = rx_port;
+       } else {
+               release_port(rx_host, rx_port);
        }
 
-       rtp_session->ready = 1;
        return rtp_session;
 }
 
@@ -720,7 +723,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
                switch_core_timer_destroy(&(*rtp_session)->timer);
        }
 
-       release_port(*rtp_session);
+       release_port((*rtp_session)->rx_host, (*rtp_session)->rx_port);
 
        switch_mutex_unlock((*rtp_session)->flag_mutex);
        return;