Changeset 1405 for pjproject/trunk/pjlib/src/pjlib-test/ioq_tcp.c
- Timestamp:
- Jul 20, 2007 8:08:30 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/ioq_tcp.c
r1238 r1405 51 51 callback_accept_status, 52 52 callback_connect_status; 53 static unsigned callback_call_count; 53 54 static pj_ioqueue_key_t *callback_read_key, 54 55 *callback_write_key, … … 66 67 callback_read_op = op_key; 67 68 callback_read_size = bytes_read; 69 callback_call_count++; 68 70 } 69 71 … … 75 77 callback_write_op = op_key; 76 78 callback_write_size = bytes_written; 79 callback_call_count++; 77 80 } 78 81 … … 97 100 callback_accept_op = op_key; 98 101 callback_accept_status = status; 102 callback_call_count++; 99 103 } 100 104 } … … 104 108 callback_connect_key = key; 105 109 callback_connect_status = status; 110 callback_call_count++; 106 111 } 107 112 … … 169 174 while (pending_op > 0) { 170 175 timeout.sec = 1; timeout.msec = 0; 176 #ifdef PJ_SYMBIAN 177 PJ_UNUSED_ARG(ioque); 178 status = pj_symbianos_poll(-1, 1000); 179 #else 171 180 status = pj_ioqueue_poll(ioque, &timeout); 181 #endif 172 182 if (status > 0) { 173 183 if (callback_read_size) { … … 198 208 // Subsequent poll should yield zero too. 199 209 timeout.sec = timeout.msec = 0; 210 #ifdef PJ_SYMBIAN 211 status = pj_symbianos_poll(-1, 1); 212 #else 200 213 status = pj_ioqueue_poll(ioque, &timeout); 214 #endif 201 215 if (status != 0) 202 216 return -173; … … 227 241 char *send_buf, *recv_buf; 228 242 pj_ioqueue_t *ioque = NULL; 229 pj_ioqueue_key_t *skey , *ckey0, *ckey1;243 pj_ioqueue_key_t *skey=NULL, *ckey0=NULL, *ckey1=NULL; 230 244 pj_ioqueue_op_key_t accept_op; 231 245 int bufsize = BUF_MIN_SIZE; … … 244 258 245 259 // Create server socket and client socket for connecting 246 rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_STREAM, 0, &ssock);260 rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &ssock); 247 261 if (rc != PJ_SUCCESS) { 248 262 app_perror("...error creating socket", rc); … … 250 264 } 251 265 252 rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_STREAM, 0, &csock1);266 rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &csock1); 253 267 if (rc != PJ_SUCCESS) { 254 268 app_perror("...error creating socket", rc); … … 322 336 callback_read_size = callback_write_size = 0; 323 337 callback_accept_status = callback_connect_status = -2; 338 callback_call_count = 0; 324 339 325 340 callback_read_key = callback_write_key = … … 330 345 pj_time_val timeout = {1, 0}; 331 346 332 status=pj_ioqueue_poll(ioque, &timeout); 347 #ifdef PJ_SYMBIAN 348 callback_call_count = 0; 349 pj_symbianos_poll(-1, 1000); 350 status = callback_call_count; 351 #else 352 status = pj_ioqueue_poll(ioque, &timeout); 353 #endif 333 354 if (status > 0) { 334 355 if (callback_accept_status != -2) { … … 374 395 if (pending_op == 0) { 375 396 pj_time_val timeout = {1, 0}; 397 #ifdef PJ_SYMBIAN 398 status = pj_symbianos_poll(-1, 1000); 399 #else 376 400 status = pj_ioqueue_poll(ioque, &timeout); 401 #endif 377 402 if (status != 0) { 378 403 status=-60; goto on_error; … … 408 433 409 434 on_error: 410 if (ssock != PJ_INVALID_SOCKET) 435 if (skey != NULL) 436 pj_ioqueue_unregister(skey); 437 else if (ssock != PJ_INVALID_SOCKET) 411 438 pj_sock_close(ssock); 412 if (csock1 != PJ_INVALID_SOCKET) 439 440 if (ckey1 != NULL) 441 pj_ioqueue_unregister(ckey1); 442 else if (csock1 != PJ_INVALID_SOCKET) 413 443 pj_sock_close(csock1); 414 if (csock0 != PJ_INVALID_SOCKET) 444 445 if (ckey0 != NULL) 446 pj_ioqueue_unregister(ckey0); 447 else if (csock0 != PJ_INVALID_SOCKET) 415 448 pj_sock_close(csock0); 449 416 450 if (ioque != NULL) 417 451 pj_ioqueue_destroy(ioque); … … 427 461 static int compliance_test_1(void) 428 462 { 429 pj_sock_t csock1= -1;463 pj_sock_t csock1=PJ_INVALID_SOCKET; 430 464 pj_sockaddr_in addr; 431 465 pj_pool_t *pool = NULL; 432 466 pj_ioqueue_t *ioque = NULL; 433 pj_ioqueue_key_t *ckey1 ;467 pj_ioqueue_key_t *ckey1 = NULL; 434 468 pj_ssize_t status = -1; 435 469 int pending_op = 0; … … 447 481 448 482 // Create client socket 449 rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_STREAM, 0, &csock1);483 rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &csock1); 450 484 if (rc != PJ_SUCCESS) { 451 485 app_perror("...ERROR in pj_sock_socket()", rc); … … 484 518 pj_time_val timeout = {1, 0}; 485 519 486 status=pj_ioqueue_poll(ioque, &timeout); 520 #ifdef PJ_SYMBIAN 521 callback_call_count = 0; 522 pj_symbianos_poll(-1, 1000); 523 status = callback_call_count; 524 #else 525 status = pj_ioqueue_poll(ioque, &timeout); 526 #endif 487 527 if (status > 0) { 488 528 if (callback_connect_key==ckey1) { … … 513 553 if (pending_op == 0) { 514 554 pj_time_val timeout = {1, 0}; 555 #ifdef PJ_SYMBIAN 556 status = pj_symbianos_poll(-1, 1000); 557 #else 515 558 status = pj_ioqueue_poll(ioque, &timeout); 559 #endif 516 560 if (status != 0) { 517 561 status=-60; goto on_error; … … 523 567 524 568 on_error: 525 if (csock1 != PJ_INVALID_SOCKET) 569 if (ckey1 != NULL) 570 pj_ioqueue_unregister(ckey1); 571 else if (csock1 != PJ_INVALID_SOCKET) 526 572 pj_sock_close(csock1); 573 527 574 if (ioque != NULL) 528 575 pj_ioqueue_destroy(ioque); … … 577 624 pj_status_t rc; 578 625 626 listener.sock = PJ_INVALID_SOCKET; 627 listener.key = NULL; 628 629 for (i=0; i<MAX_PAIR; ++i) { 630 server[i].sock = PJ_INVALID_SOCKET; 631 server[i].key = NULL; 632 } 633 634 for (i=0; i<MAX_PAIR; ++i) { 635 client[i].sock = PJ_INVALID_SOCKET; 636 client[i].key = NULL; 637 } 638 579 639 // Create pool. 580 640 pool = pj_pool_create(mem, NULL, POOL_SIZE, 4000, NULL); … … 594 654 595 655 // Create listener socket 596 rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_STREAM, 0, &listener.sock);656 rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &listener.sock); 597 657 if (rc != PJ_SUCCESS) { 598 658 app_perror("...error creating socket", rc); … … 636 696 // Client connect and server accept. 637 697 for (i=0; i<MAX_PAIR; ++i) { 638 rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_STREAM, 0, &client[i].sock);698 rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &client[i].sock); 639 699 if (rc != PJ_SUCCESS) { 640 700 app_perror("...error creating socket", rc); … … 684 744 pj_time_val timeout = {1, 0}; 685 745 686 status=pj_ioqueue_poll(ioque, &timeout); 746 #ifdef PJ_SYMBIAN 747 status = pj_symbianos_poll(-1, 1000); 748 #else 749 status = pj_ioqueue_poll(ioque, &timeout); 750 #endif 687 751 if (status > 0) { 688 752 if (status > pending_op) { … … 705 769 if (pending_op == 0) { 706 770 pj_time_val timeout = {1, 0}; 771 #ifdef PJ_SYMBIAN 772 status = pj_symbianos_poll(-1, 1000); 773 #else 707 774 status = pj_ioqueue_poll(ioque, &timeout); 775 #endif 708 776 if (status != 0) { 709 777 status=-120; goto on_error; … … 720 788 721 789 // Check addresses 722 if (server[i].local_addr.sin_family != PJ_AF_INET||790 if (server[i].local_addr.sin_family != pj_AF_INET() || 723 791 server[i].local_addr.sin_addr.s_addr == 0 || 724 792 server[i].local_addr.sin_port == 0) … … 729 797 } 730 798 731 if (server[i].rem_addr.sin_family != PJ_AF_INET||799 if (server[i].rem_addr.sin_family != pj_AF_INET() || 732 800 server[i].rem_addr.sin_addr.s_addr == 0 || 733 801 server[i].rem_addr.sin_port == 0)
Note: See TracChangeset
for help on using the changeset viewer.