Changeset 2771


Ignore:
Timestamp:
Jun 17, 2009 1:31:13 PM (15 years ago)
Author:
bennylp
Message:

Ticket #758 (Problem with TCP transport on Symbian)

  • fixed TCP recv() to use RecvOneOrMore?()
  • fixed activesock unit test in pjlib-test
Location:
pjproject/trunk/pjlib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp

    r2481 r2771  
    214214        aAddress_.SetAddress(0); 
    215215        aAddress_.SetPort(0); 
    216         sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 
     216 
     217        if (sock_->IsDatagram()) { 
     218            sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 
     219        } else { 
     220            // Using static like this is not pretty, but we don't need to use 
     221            // the value anyway, hence doing it like this is probably most 
     222            // optimal. 
     223            static TSockXfrLength len; 
     224            sock_->Socket().RecvOneOrMore(aBufferPtr_, flags, iStatus, len); 
     225        } 
    217226    } 
    218227 
     
    278287{ 
    279288        CPjSocket *pjNewSock = new CPjSocket(get_pj_socket()->GetAf(),  
     289                                             get_pj_socket()->GetSockType(), 
    280290                                             blank_sock_); 
    281291        int addrlen = 0; 
  • pjproject/trunk/pjlib/src/pj/os_symbian.h

    r2481 r2771  
    5555 
    5656    // Construct CPjSocket 
    57     CPjSocket(int af, RSocket &sock) 
    58         : af_(af), sock_(sock), connected_(false), sockReader_(NULL) 
     57    CPjSocket(int af, int sock_type, RSocket &sock) 
     58        : af_(af), sock_(sock), sock_type_(sock_type), connected_(false),  
     59          sockReader_(NULL) 
    5960    {  
    6061    } 
     
    8788    } 
    8889 
     90    // Get socket type 
     91    int GetSockType() const 
     92    { 
     93        return sock_type_; 
     94    } 
     95     
     96    // Returns true if socket is a datagram 
     97    bool IsDatagram() const 
     98    { 
     99        return sock_type_ == KSockDatagram; 
     100    } 
     101     
    89102    // Get socket reader, if any. 
    90103    // May return NULL. 
     
    104117    RSocket          sock_;         // Must not be reference, or otherwise 
    105118                                    // it may point to local variable! 
     119    unsigned         sock_type_; 
     120     
    106121    bool             connected_; 
    107122    CPjSocketReader *sockReader_; 
  • pjproject/trunk/pjlib/src/pj/sock_symbian.cpp

    r2481 r2771  
    126126void CPjSocketReader::ConstructL(unsigned max_len) 
    127127{ 
    128     TProtocolDesc aProtocol; 
    129     TInt err; 
    130  
    131     err = sock_.Socket().Info(aProtocol); 
    132     User::LeaveIfError(err); 
    133  
    134     isDatagram_ = (aProtocol.iSockType == KSockDatagram); 
     128    isDatagram_ = sock_.IsDatagram(); 
    135129 
    136130    TUint8 *ptr = new TUint8[max_len]; 
     
    518512 
    519513    /* Wrap Symbian RSocket into PJLIB's CPjSocket, and return to caller */ 
    520     CPjSocket *pjSock = new CPjSocket(af, rSock); 
     514    CPjSocket *pjSock = new CPjSocket(af, type, rSock); 
    521515    *p_sock = (pj_sock_t)pjSock; 
    522516 
     
    734728 
    735729    CPjSocket *pjSock = (CPjSocket*)sock; 
    736     RSocket &rSock = pjSock->Socket(); 
    737730 
    738731    if (pjSock->Reader()) { 
     
    758751    TPtr8 data((TUint8*)buf, (TInt)*len, (TInt)*len); 
    759752 
    760     rSock.Recv(data, flags, reqStatus, recvLen); 
     753    if (pjSock->IsDatagram()) { 
     754        pjSock->Socket().Recv(data, flags, reqStatus); 
     755    } else { 
     756        // Using static like this is not pretty, but we don't need to use 
     757        // the value anyway, hence doing it like this is probably most 
     758        // optimal. 
     759        static TSockXfrLength len; 
     760        pjSock->Socket().RecvOneOrMore(data, flags, reqStatus, len); 
     761    } 
    761762    User::WaitForRequest(reqStatus); 
    762763 
     
    998999 
    9991000    // Create PJ socket 
    1000     CPjSocket *newPjSock = new CPjSocket(pjSock->GetAf(), newSock); 
     1001    CPjSocket *newPjSock = new CPjSocket(pjSock->GetAf(), pjSock->GetSockType(), 
     1002                                         newSock); 
    10011003    newPjSock->SetConnected(true); 
    10021004 
  • pjproject/trunk/pjlib/src/pjlib-test/activesock.c

    r2394 r2771  
    213213        for (i=0; i<10 && last_rx1 == srv1->rx_cnt && last_rx2 == srv2->rx_cnt; ++i) { 
    214214            pj_time_val delay = {0, 10}; 
     215#ifdef PJ_SYMBIAN 
     216            pj_symbianos_poll(-1, 100); 
     217#else 
    215218            pj_ioqueue_poll(ioqueue, &delay); 
     219#endif 
    216220        } 
    217221 
     
    404408        if (status == PJ_EPENDING) { 
    405409            do { 
     410#if PJ_SYMBIAN 
     411                pj_symbianos_poll(-1, -1); 
     412#else 
    406413                pj_ioqueue_poll(ioqueue, NULL); 
     414#endif 
    407415            } while (!state2->sent); 
    408         } else if (status != PJ_SUCCESS) { 
    409                 PJ_LOG(1,("", "   err: send status=%d", status)); 
    410             status = -180; 
    411             break; 
    412         } else if (status == PJ_SUCCESS) { 
    413             if (len != sizeof(*pkt)) { 
    414                 PJ_LOG(1,("", "   err: shouldn't report partial sent")); 
    415                 status = -190; 
    416                 break; 
    417             } 
     416        } else { 
     417#if PJ_SYMBIAN 
     418                /* The Symbian socket always returns PJ_SUCCESS for TCP send, 
     419                 * eventhough the remote end hasn't received the data yet. 
     420                 * If we continue sending, eventually send() will block, 
     421                 * possibly because the send buffer is full. So we need to 
     422                 * poll the ioqueue periodically, to let receiver gets the  
     423                 * data. 
     424                 */ 
     425                pj_symbianos_poll(-1, 0); 
     426#endif 
     427                if (status != PJ_SUCCESS) { 
     428                    PJ_LOG(1,("", "   err: send status=%d", status)); 
     429                    status = -180; 
     430                    break; 
     431                } else if (status == PJ_SUCCESS) { 
     432                    if (len != sizeof(*pkt)) { 
     433                        PJ_LOG(1,("", "   err: shouldn't report partial sent")); 
     434                        status = -190; 
     435                        break; 
     436                    } 
     437                } 
    418438        } 
    419439    } 
     
    421441    /* Wait until everything has been sent/received */ 
    422442    if (state1->next_recv_seq < COUNT) { 
     443#ifdef PJ_SYMBIAN 
     444        while (pj_symbianos_poll(-1, 1000) == PJ_TRUE) 
     445            ; 
     446#else 
    423447        pj_time_val delay = {0, 100}; 
    424448        while (pj_ioqueue_poll(ioqueue, &delay) > 0) 
    425449            ; 
     450#endif 
    426451    } 
    427452 
Note: See TracChangeset for help on using the changeset viewer.