]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add new function to init an empty switch_sockaddr_t to avoid an unnecessary dns looku...
authorAnthony Minessale <anthm@freeswitch.org>
Sat, 11 Dec 2010 17:41:19 +0000 (11:41 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Sat, 11 Dec 2010 17:41:19 +0000 (11:41 -0600)
src/include/switch_apr.h
src/switch_apr.c
src/switch_rtp.c

index dc81d1a522e89ffdefb8989d5894b0dc41fce33e..d89a13bb30193b019c3be1e08d0399939fea9eaf 100644 (file)
@@ -1110,6 +1110,8 @@ SWITCH_DECLARE(int) switch_sockaddr_equal(const switch_sockaddr_t *sa1, const sw
 SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname,
                                                                                                                 int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
 
+SWITCH_DECLARE(switch_status_t) switch_sockaddr_create(switch_sockaddr_t **sa, switch_memory_pool_t *pool);
+
 /**
  * Send data over a network.
  * @param sock The socket to send the data over.
index dccc37be9625fc20c7d99b7776d0791fbe70a83e..7c027f8c68f8331515e36accb220eb68522877dc 100644 (file)
@@ -729,6 +729,18 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *
        return apr_socket_recv(sock, buf, len);
 }
 
+SWITCH_DECLARE(switch_status_t) switch_sockaddr_create(switch_sockaddr_t **sa, switch_memory_pool_t *pool)
+{
+       switch_sockaddr_t *new_sa;
+
+       new_sa = apr_pcalloc(pool, sizeof(apr_sockaddr_t));
+       switch_assert(new_sa);
+       new_sa->pool = pool;
+       memset(new_sa, 0, sizeof(new_sa));
+       *sa = new_sa;
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname, int32_t family,
                                                                                                                 switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
 {
index aba14b2d0a99494aa5f89518738627a815db3492..772c2508a014770d2e23b4d29b5bafd3fa635c7b 100644 (file)
@@ -1367,9 +1367,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
        switch_rtp_set_flag(rtp_session, flags);
 
        /* for from address on recvfrom calls */
-       switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, pool);
+       switch_sockaddr_create(&rtp_session->from_addr, pool);
+
        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
-               switch_sockaddr_info_get(&rtp_session->rtcp_from_addr, NULL, SWITCH_UNSPEC, 0, 0, pool);
+               switch_sockaddr_create(&rtp_session->rtcp_from_addr, pool);
        }
        rtp_session->seq = (uint16_t) rand();
        rtp_session->ssrc = (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL));