Ignore:
Timestamp:
Feb 13, 2008 3:17:28 PM (16 years ago)
Author:
bennylp
Message:

Ticket #474: option in ioqueue to control concurrency (to allow/disallow simultaneous/multiple callback calls)

File:
1 edited

Legend:

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

    r1405 r1789  
    126126 * data between two sockets. 
    127127 */  
    128 static int compliance_test(void) 
     128static int compliance_test(pj_bool_t allow_concur) 
    129129{ 
    130130    pj_sock_t ssock=-1, csock=-1; 
     
    177177    if (rc != PJ_SUCCESS) { 
    178178        status=-20; goto on_error; 
     179    } 
     180 
     181    // Set concurrency 
     182    TRACE_("set concurrency..."); 
     183    rc = pj_ioqueue_set_default_concurrency(ioque, allow_concur); 
     184    if (rc != PJ_SUCCESS) { 
     185        status=-21; goto on_error; 
    179186    } 
    180187 
     
    352359 * closed. 
    353360 */  
    354 static int unregister_test(void) 
     361static int unregister_test(pj_bool_t allow_concur) 
    355362{ 
    356363    enum { RPORT = 50000, SPORT = 50001 }; 
     
    382389    } 
    383390 
     391    // Set concurrency 
     392    TRACE_("set concurrency..."); 
     393    status = pj_ioqueue_set_default_concurrency(ioqueue, allow_concur); 
     394    if (status != PJ_SUCCESS) { 
     395        return -112; 
     396    } 
     397 
    384398    /* Create sender socket */ 
    385399    status = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, SPORT, &ssock); 
     
    513527 * of sockets to the ioqueue. 
    514528 */ 
    515 static int many_handles_test(void) 
     529static int many_handles_test(pj_bool_t allow_concur) 
    516530{ 
    517531    enum { MAX = PJ_IOQUEUE_MAX_HANDLES }; 
     
    538552        app_perror("...error in pj_ioqueue_create", rc); 
    539553        return -10; 
     554    } 
     555 
     556    // Set concurrency 
     557    rc = pj_ioqueue_set_default_concurrency(ioqueue, allow_concur); 
     558    if (rc != PJ_SUCCESS) { 
     559        return -11; 
    540560    } 
    541561 
     
    601621 * Benchmarking IOQueue 
    602622 */ 
    603 static int bench_test(int bufsize, int inactive_sock_count) 
     623static int bench_test(pj_bool_t allow_concur, int bufsize,  
     624                      int inactive_sock_count) 
    604625{ 
    605626    pj_sock_t ssock=-1, csock=-1; 
     
    649670    if (rc != PJ_SUCCESS) { 
    650671        app_perror("...error: pj_ioqueue_create()", rc); 
     672        goto on_error; 
     673    } 
     674 
     675    // Set concurrency 
     676    rc = pj_ioqueue_set_default_concurrency(ioque, allow_concur); 
     677    if (rc != PJ_SUCCESS) { 
     678        app_perror("...error: pj_ioqueue_set_default_concurrency()", rc); 
    651679        goto on_error; 
    652680    } 
     
    840868} 
    841869 
    842 int udp_ioqueue_test() 
     870static int udp_ioqueue_test_imp(pj_bool_t allow_concur) 
    843871{ 
    844872    int status; 
    845873    int bufsize, sock_count; 
    846874 
     875    PJ_LOG(3,(THIS_FILE, "..testing with concurency=%d", allow_concur)); 
     876 
    847877    //goto pass1; 
    848878 
    849879    PJ_LOG(3, (THIS_FILE, "...compliance test (%s)", pj_ioqueue_name())); 
    850     if ((status=compliance_test()) != 0) { 
     880    if ((status=compliance_test(allow_concur)) != 0) { 
    851881        return status; 
    852882    } 
     
    855885 
    856886    PJ_LOG(3, (THIS_FILE, "...unregister test (%s)", pj_ioqueue_name())); 
    857     if ((status=unregister_test()) != 0) { 
     887    if ((status=unregister_test(allow_concur)) != 0) { 
    858888        return status; 
    859889    } 
    860890    PJ_LOG(3, (THIS_FILE, "....unregister test ok")); 
    861891 
    862     if ((status=many_handles_test()) != 0) { 
     892    if ((status=many_handles_test(allow_concur)) != 0) { 
    863893        return status; 
    864894    } 
     
    880910 
    881911    for (bufsize=BUF_MIN_SIZE; bufsize <= BUF_MAX_SIZE; bufsize *= 2) { 
    882         if ((status=bench_test(bufsize, SOCK_INACTIVE_MIN)) != 0) 
     912        if ((status=bench_test(allow_concur, bufsize, SOCK_INACTIVE_MIN)) != 0) 
    883913            return status; 
    884914    } 
     
    890920    { 
    891921        //PJ_LOG(3,(THIS_FILE, "...testing with %d fds", sock_count)); 
    892         if ((status=bench_test(bufsize, sock_count-2)) != 0) 
     922        if ((status=bench_test(allow_concur, bufsize, sock_count-2)) != 0) 
    893923            return status; 
    894924    } 
     925    return 0; 
     926} 
     927 
     928int udp_ioqueue_test() 
     929{ 
     930    int rc; 
     931 
     932    rc = udp_ioqueue_test_imp(PJ_TRUE); 
     933    if (rc != 0) 
     934        return rc; 
     935 
     936    rc = udp_ioqueue_test_imp(PJ_FALSE); 
     937    if (rc != 0) 
     938        return rc; 
     939 
    895940    return 0; 
    896941} 
Note: See TracChangeset for help on using the changeset viewer.