Ignore:
Timestamp:
Feb 13, 2008 3:17:28 PM (14 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_tcp.c

    r1405 r1789  
    233233 * Compliance test for success scenario. 
    234234 */ 
    235 static int compliance_test_0(void) 
     235static int compliance_test_0(pj_bool_t allow_concur) 
    236236{ 
    237237    pj_sock_t ssock=-1, csock0=-1, csock1=-1; 
     
    291291        app_perror("...ERROR in pj_ioqueue_create()", rc); 
    292292        status=-20; goto on_error; 
     293    } 
     294 
     295    // Concurrency 
     296    rc = pj_ioqueue_set_default_concurrency(ioque, allow_concur); 
     297    if (rc != PJ_SUCCESS) { 
     298        app_perror("...ERROR in pj_ioqueue_set_default_concurrency()", rc); 
     299        status=-21; goto on_error; 
    293300    } 
    294301 
     
    459466 * In this case, the client connects to a non-existant service. 
    460467 */ 
    461 static int compliance_test_1(void) 
     468static int compliance_test_1(pj_bool_t allow_concur) 
    462469{ 
    463470    pj_sock_t csock1=PJ_INVALID_SOCKET; 
     
    478485    if (!ioque) { 
    479486        status=-20; goto on_error; 
     487    } 
     488 
     489    // Concurrency 
     490    rc = pj_ioqueue_set_default_concurrency(ioque, allow_concur); 
     491    if (rc != PJ_SUCCESS) { 
     492        status=-21; goto on_error; 
    480493    } 
    481494 
     
    582595 * Repeated connect/accept on the same listener socket. 
    583596 */ 
    584 static int compliance_test_2(void) 
     597static int compliance_test_2(pj_bool_t allow_concur) 
    585598{ 
    586599#if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 
     
    648661    } 
    649662 
     663 
     664    // Concurrency 
     665    rc = pj_ioqueue_set_default_concurrency(ioque, allow_concur); 
     666    if (rc != PJ_SUCCESS) { 
     667        app_perror("...ERROR in pj_ioqueue_set_default_concurrency()", rc); 
     668        return -11; 
     669    } 
    650670 
    651671    // Allocate buffers for send and receive. 
     
    888908 
    889909 
    890 int tcp_ioqueue_test() 
     910static int tcp_ioqueue_test_impl(pj_bool_t allow_concur) 
    891911{ 
    892912    int status; 
     913 
     914    PJ_LOG(3,(THIS_FILE, "..testing with concurency=%d", allow_concur)); 
    893915 
    894916    PJ_LOG(3, (THIS_FILE, "..%s compliance test 0 (success scenario)", 
    895917               pj_ioqueue_name())); 
    896     if ((status=compliance_test_0()) != 0) { 
     918    if ((status=compliance_test_0(allow_concur)) != 0) { 
    897919        PJ_LOG(1, (THIS_FILE, "....FAILED (status=%d)\n", status)); 
    898920        return status; 
     
    900922    PJ_LOG(3, (THIS_FILE, "..%s compliance test 1 (failed scenario)", 
    901923               pj_ioqueue_name())); 
    902     if ((status=compliance_test_1()) != 0) { 
     924    if ((status=compliance_test_1(allow_concur)) != 0) { 
    903925        PJ_LOG(1, (THIS_FILE, "....FAILED (status=%d)\n", status)); 
    904926        return status; 
     
    907929    PJ_LOG(3, (THIS_FILE, "..%s compliance test 2 (repeated accept)", 
    908930               pj_ioqueue_name())); 
    909     if ((status=compliance_test_2()) != 0) { 
     931    if ((status=compliance_test_2(allow_concur)) != 0) { 
    910932        PJ_LOG(1, (THIS_FILE, "....FAILED (status=%d)\n", status)); 
    911933        return status; 
    912934    } 
     935 
     936    return 0; 
     937} 
     938 
     939int tcp_ioqueue_test() 
     940{ 
     941    int rc; 
     942 
     943    rc = tcp_ioqueue_test_impl(PJ_TRUE); 
     944    if (rc != 0) 
     945        return rc; 
     946 
     947    rc = tcp_ioqueue_test_impl(PJ_FALSE); 
     948    if (rc != 0) 
     949        return rc; 
    913950 
    914951    return 0; 
Note: See TracChangeset for help on using the changeset viewer.