Changeset 260


Ignore:
Timestamp:
Mar 1, 2006 11:05:11 PM (18 years ago)
Author:
bennylp
Message:

Maximize the size of SO_SNDBUF and SO_RCVBUF for UDP transport

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c

    r252 r260  
    2020#include <pjsip/sip_endpoint.h> 
    2121#include <pjsip/sip_errno.h> 
     22#include <pj/addr_resolv.h> 
     23#include <pj/assert.h> 
     24#include <pj/lock.h> 
     25#include <pj/log.h> 
     26#include <pj/os.h> 
    2227#include <pj/pool.h> 
    2328#include <pj/sock.h> 
    24 #include <pj/addr_resolv.h> 
    25 #include <pj/os.h> 
    26 #include <pj/lock.h> 
    2729#include <pj/string.h> 
    28 #include <pj/assert.h> 
     30 
     31 
     32#define THIS_FILE   "sip_transport_udp.c" 
     33 
     34/** 
     35 * These are the values for socket send and receive buffer sizes, 
     36 * respectively. They will be applied to UDP socket with setsockopt(). 
     37 */ 
     38#ifndef PJSIP_UDP_SO_SNDBUF_SIZE 
     39#   define PJSIP_UDP_SO_SNDBUF_SIZE     (4*1024*1024) 
     40#endif 
     41 
     42#ifndef PJSIP_UDP_SO_RCVBUF_SIZE 
     43#   define PJSIP_UDP_SO_RCVBUF_SIZE     (4*1024*1024) 
     44#endif 
    2945 
    3046 
     
    330346    pj_ioqueue_t *ioqueue; 
    331347    pj_ioqueue_callback ioqueue_cb; 
     348    long sobuf_size; 
    332349    unsigned i; 
    333350    pj_status_t status; 
     
    335352    PJ_ASSERT_RETURN(endpt && sock!=PJ_INVALID_SOCKET && a_name && async_cnt>0, 
    336353                     PJ_EINVAL); 
     354 
     355 
     356    /* Adjust socket rcvbuf size */ 
     357    sobuf_size = PJSIP_UDP_SO_RCVBUF_SIZE; 
     358    status = pj_sock_setsockopt(sock, PJ_SOL_SOCKET, PJ_SO_RCVBUF, 
     359                                &sobuf_size, sizeof(sobuf_size)); 
     360    if (status != PJ_SUCCESS) { 
     361        char errmsg[PJ_ERR_MSG_SIZE]; 
     362        pj_strerror(status, errmsg, sizeof(errmsg)); 
     363        PJ_LOG(4,(THIS_FILE, "Error setting SO_RCVBUF: %s [%d]", errmsg, 
     364                  status)); 
     365    } 
     366 
     367    /* Adjust socket sndbuf size */ 
     368    sobuf_size = PJSIP_UDP_SO_SNDBUF_SIZE; 
     369    status = pj_sock_setsockopt(sock, PJ_SOL_SOCKET, PJ_SO_SNDBUF, 
     370                                &sobuf_size, sizeof(sobuf_size)); 
     371    if (status != PJ_SUCCESS) { 
     372        char errmsg[PJ_ERR_MSG_SIZE]; 
     373        pj_strerror(status, errmsg, sizeof(errmsg)); 
     374        PJ_LOG(4,(THIS_FILE, "Error setting SO_SNDBUF: %s [%d]", errmsg, 
     375                  status)); 
     376    } 
    337377 
    338378    /* Create pool. */ 
Note: See TracChangeset for help on using the changeset viewer.