Changeset 3478


Ignore:
Timestamp:
Mar 23, 2011 6:08:36 AM (9 years ago)
Author:
ming
Message:

Fixed #1221: Crash when SIP transport tried to write to a broken pipe.

Location:
pjproject/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/sock.h

    r3145 r3478  
    298298extern const pj_uint16_t PJ_SO_REUSEADDR; 
    299299 
     300/** Do not generate SIGPIPE. @see pj_SO_NOSIGPIPE */ 
     301extern const pj_uint16_t PJ_SO_NOSIGPIPE; 
     302 
    300303/** Set the protocol-defined priority for all packets to be sent on socket. 
    301304 */ 
     
    334337    PJ_DECL(pj_uint16_t) pj_SO_REUSEADDR(void); 
    335338 
     339    /** Get #PJ_SO_NOSIGPIPE constant */ 
     340    PJ_DECL(pj_uint16_t) pj_SO_NOSIGPIPE(void); 
     341 
    336342    /** Get #PJ_SO_PRIORITY constant */ 
    337343    PJ_DECL(pj_uint16_t) pj_SO_PRIORITY(void); 
     
    366372    /** Get #PJ_SO_REUSEADDR constant */ 
    367373#   define pj_SO_REUSEADDR() PJ_SO_REUSEADDR 
     374 
     375    /** Get #PJ_SO_NOSIGPIPE constant */ 
     376#   define pj_SO_NOSIGPIPE() PJ_SO_NOSIGPIPE 
    368377 
    369378    /** Get #PJ_SO_PRIORITY constant */ 
  • pjproject/trunk/pjlib/src/pj/sock_bsd.c

    r3408 r3478  
    136136const pj_uint16_t PJ_TCP_NODELAY= TCP_NODELAY; 
    137137const pj_uint16_t PJ_SO_REUSEADDR= SO_REUSEADDR; 
     138#ifdef SO_NOSIGPIPE 
     139const pj_uint16_t PJ_SO_NOSIGPIPE = SO_NOSIGPIPE; 
     140#else 
     141const pj_uint16_t PJ_SO_NOSIGPIPE = 0xFFFF; 
     142#endif 
    138143#if defined(SO_PRIORITY) 
    139144const pj_uint16_t PJ_SO_PRIORITY = SO_PRIORITY; 
  • pjproject/trunk/pjlib/src/pj/sock_common.c

    r3186 r3478  
    11381138} 
    11391139 
     1140PJ_DEF(pj_uint16_t) pj_SO_NOSIGPIPE(void) 
     1141{ 
     1142    return PJ_SO_NOSIGPIPE; 
     1143} 
     1144 
    11401145PJ_DEF(pj_uint16_t) pj_SO_PRIORITY(void) 
    11411146{ 
  • pjproject/trunk/pjlib/src/pj/sock_symbian.cpp

    r2966 r3478  
    5454const pj_uint16_t PJ_SOL_UDP    = 0xFFFF; 
    5555const pj_uint16_t PJ_SOL_IPV6   = 0xFFFF; 
     56const pj_uint16_t PJ_SO_NOSIGPIPE = 0xFFFF; 
    5657 
    5758/* TOS */ 
  • pjproject/trunk/pjsip-apps/src/pjsua/main.c

    r2892 r3478  
    6767} 
    6868 
     69static void setup_socket_signal() 
     70{ 
     71} 
     72 
    6973#else 
     74#include <signal.h> 
    7075 
    7176static void setup_signal_handler(void) 
    7277{ 
     78} 
     79 
     80static void setup_socket_signal() 
     81{ 
     82    signal(SIGPIPE, SIG_IGN); 
    7383} 
    7484 
     
    7787int main(int argc, char *argv[]) 
    7888{ 
     89    setup_socket_signal(); 
     90 
    7991    do { 
    8092        app_restart = PJ_FALSE; 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r3138 r3478  
    545545    pj_activesock_cb tcp_callback; 
    546546    const pj_str_t ka_pkt = PJSIP_TCP_KEEP_ALIVE_DATA; 
     547    pj_int32_t val = 1; 
    547548    pj_status_t status; 
    548549     
     
    632633    pj_ioqueue_op_key_init(&tcp->ka_op_key.key, sizeof(pj_ioqueue_op_key_t)); 
    633634    pj_strdup(tcp->base.pool, &tcp->ka_pkt, &ka_pkt); 
     635     
     636    /* Prevent SIGPIPE */ 
     637    pj_sock_setsockopt(tcp->sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(), 
     638                       &val, sizeof(val)); 
    634639 
    635640    /* Done setting up basic transport. */ 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c

    r3148 r3478  
    528528    struct tls_transport *tls; 
    529529    const pj_str_t ka_pkt = PJSIP_TLS_KEEP_ALIVE_DATA; 
     530    pj_int32_t val = 1; 
    530531    pj_status_t status; 
    531532     
     
    617618    pj_strdup(tls->base.pool, &tls->ka_pkt, &ka_pkt); 
    618619 
     620    /* Prevent SIGPIPE */ 
     621    pj_sock_setsockopt(tcp->sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(), 
     622                       &val, sizeof(val)); 
     623     
    619624    /* Done setting up basic transport. */ 
    620625    *p_tls = tls; 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tls_ossl.c

    r2394 r3478  
    12301230    pj_ioqueue_callback tls_callback; 
    12311231    int rc; 
     1232    pj_int32_t val = 1; 
    12321233    pj_status_t status; 
    12331234     
     
    13321333    tls->ka_timer.user_data = (void*) tls; 
    13331334    tls->ka_timer.cb = &tls_keep_alive_timer; 
     1335 
     1336    /* Prevent SIGPIPE */ 
     1337    pj_sock_setsockopt(tcp->sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(), 
     1338                       &val, sizeof(val)); 
    13341339 
    13351340 
Note: See TracChangeset for help on using the changeset viewer.