Changeset 3491


Ignore:
Timestamp:
Mar 31, 2011 5:54:16 AM (13 years ago)
Author:
bennylp
Message:

Fixed #1225: iPhone: UDP socket send error after waking up from background mode (thanks Joe Meade for the report)

Location:
pjproject/trunk/pjlib/src/pj
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ioqueue_common_abs.c

    r3299 r3491  
    313313            //write_op->op = 0; 
    314314        } else if (write_op->op == PJ_IOQUEUE_OP_SEND_TO) { 
    315             send_rc = pj_sock_sendto(h->fd,  
    316                                      write_op->buf+write_op->written, 
    317                                      &sent, write_op->flags, 
    318                                      &write_op->rmt_addr,  
    319                                      write_op->rmt_addrlen); 
     315            int retry; 
     316            for (retry=0; retry<2; ++retry) { 
     317                send_rc = pj_sock_sendto(h->fd,  
     318                                         write_op->buf+write_op->written, 
     319                                         &sent, write_op->flags, 
     320                                         &write_op->rmt_addr,  
     321                                         write_op->rmt_addrlen); 
     322#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     323            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
     324                /* Special treatment for dead UDP sockets here, see ticket #1107 */ 
     325                if (send_rc==PJ_STATUS_FROM_OS(EPIPE) && !IS_CLOSING(h) && 
     326                    h->fd_type==pj_SOCK_DGRAM()) 
     327                { 
     328                    PJ_PERROR(4,(THIS_FILE, send_rc, 
     329                                 "Send error for socket %d, retrying", 
     330                                 h->fd)); 
     331                    replace_udp_sock(h); 
     332                    continue; 
     333                } 
     334#endif 
     335                break; 
     336            } 
     337 
    320338            /* Can't do this. We only clear "op" after we're finished sending 
    321339             * the whole buffer. 
     
    918936    struct write_operation *write_op; 
    919937    unsigned retry; 
     938#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     939            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
     940    pj_bool_t restart_retry = PJ_FALSE; 
     941#endif 
    920942    pj_status_t status; 
    921943    pj_ssize_t sent; 
     
    924946    PJ_CHECK_STACK(); 
    925947 
     948retry_on_restart: 
    926949    /* Check if key is closing. */ 
    927950    if (IS_CLOSING(key)) 
     
    960983             */ 
    961984            if (status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL)) { 
     985#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     986            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
     987                /* Special treatment for dead UDP sockets here, see ticket #1107 */ 
     988                if (status==PJ_STATUS_FROM_OS(EPIPE) && !IS_CLOSING(key) && 
     989                    key->fd_type==pj_SOCK_DGRAM() && !restart_retry) 
     990                { 
     991                    PJ_PERROR(4,(THIS_FILE, status, 
     992                                 "Send error for socket %d, retrying", 
     993                                 key->fd)); 
     994                    replace_udp_sock(key); 
     995                    restart_retry = PJ_TRUE; 
     996                    goto retry_on_restart; 
     997                } 
     998#endif 
     999 
    9621000                return status; 
    9631001            } 
  • pjproject/trunk/pjlib/src/pj/ioqueue_select.c

    r3456 r3491  
    126126 
    127127/* Proto */ 
     128#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     129            PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0 
    128130static pj_status_t replace_udp_sock(pj_ioqueue_key_t *h); 
     131#endif 
    129132 
    130133/* Include implementation for common abstraction after we declare 
Note: See TracChangeset for help on using the changeset viewer.