Ignore:
Timestamp:
May 10, 2006 7:24:40 PM (18 years ago)
Author:
bennylp
Message:

Merge-in RTEMS port patch by Phil Torre <ptorre@…>, alpha release.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pjlib-test/ioq_udp.c

    r365 r433  
    4242#define PORT                51233 
    4343#define LOOP                100 
     44///#define LOOP             2 
    4445#define BUF_MIN_SIZE        32 
    4546#define BUF_MAX_SIZE        2048 
     
    5051#undef TRACE_ 
    5152#define TRACE_(msg)         PJ_LOG(3,(THIS_FILE,"....." msg)) 
     53 
     54#if 0 
     55#  define TRACE__(args)     PJ_LOG(3,args) 
     56#else 
     57#  define TRACE__(args) 
     58#endif 
     59 
    5260 
    5361static pj_ssize_t            callback_read_size, 
     
    7078    callback_read_op = op_key; 
    7179    callback_read_size = bytes_read; 
     80    TRACE__((THIS_FILE, "     callback_read_key = %p, bytes=%d",  
     81             key, bytes_read)); 
    7282} 
    7383 
     
    255265            status=-45; goto on_error; 
    256266        } else if (rc < 0) { 
    257             app_perror("...ERROR in ioqueue_poll()", rc); 
     267            app_perror("...ERROR in ioqueue_poll()", -rc); 
    258268            status=-50; goto on_error; 
    259269        } 
     
    493503    pj_ioqueue_key_t **key; 
    494504    pj_status_t rc; 
    495     int count, i; 
     505    int count, i; /* must be signed */ 
    496506 
    497507    PJ_LOG(3,(THIS_FILE,"...testing with so many handles")); 
     
    534544    /* Now deregister and close all handles. */  
    535545 
    536     for (i=0; i<count; ++i) { 
     546    /* NOTE for RTEMS: 
     547     *  It seems that the order of close(sock) is pretty important here. 
     548     *  If we close the sockets with the same order as when they were created, 
     549     *  RTEMS doesn't seem to reuse the sockets, thus next socket created 
     550     *  will have descriptor higher than the last socket created. 
     551     *  If we close the sockets in the reverse order, then the descriptor will 
     552     *  get reused. 
     553     *  This used to cause problem with select ioqueue, since the ioqueue 
     554     *  always gives FD_SETSIZE for the first select() argument. This ioqueue 
     555     *  behavior can be changed with setting PJ_SELECT_NEEDS_NFDS macro. 
     556     */ 
     557    for (i=count-1; i>=0; --i) { 
     558    ///for (i=0; i<count; ++i) { 
    537559        rc = pj_ioqueue_unregister(key[i]); 
    538560        if (rc != PJ_SUCCESS) { 
     
    571593    pj_ioqueue_key_t *skey, *ckey, *key; 
    572594    pj_timestamp t1, t2, t_elapsed; 
    573     int rc=0, i; 
     595    int rc=0, i;    /* i must be signed */ 
    574596    pj_str_t temp; 
    575     char errbuf[128]; 
     597    char errbuf[PJ_ERR_MSG_SIZE]; 
     598 
     599    TRACE__((THIS_FILE, "   bench test %d", inactive_sock_count)); 
    576600 
    577601    // Create pool. 
     
    692716                               &addr, sizeof(addr)); 
    693717        if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { 
    694             app_perror("...error: pj_ioqueue_write()", bytes); 
     718            app_perror("...error: pj_ioqueue_write()", rc); 
    695719            break; 
     720        } 
     721        if (rc == PJ_SUCCESS) { 
     722            if (bytes < 0) { 
     723                app_perror("...error: pj_ioqueue_sendto()", -bytes); 
     724                break; 
     725            } 
    696726        } 
    697727 
     
    702732        callback_read_key = NULL; 
    703733        callback_read_size = 0; 
     734        TRACE__((THIS_FILE, "     waiting for key = %p", skey)); 
    704735        do { 
    705             rc = pj_ioqueue_poll(ioque, NULL); 
     736            pj_time_val timeout = { 1, 0 }; 
     737            rc = pj_ioqueue_poll(ioque, &timeout); 
     738            TRACE__((THIS_FILE, "     poll rc=%d", rc)); 
    706739        } while (rc >= 0 && callback_read_key != skey); 
    707740 
     
    750783 
    751784    // Cleaning up. 
    752     for (i=0; i<inactive_sock_count; ++i) 
     785    for (i=inactive_sock_count-1; i>=0; --i) { 
    753786        pj_sock_close(inactive_sock[i]); 
     787    } 
     788 
    754789    pj_sock_close(ssock); 
    755790    pj_sock_close(csock); 
     791 
    756792 
    757793    pj_ioqueue_destroy(ioque); 
Note: See TracChangeset for help on using the changeset viewer.