Changeset 433 for pjproject/trunk/pjlib/src/pjlib-test/ioq_udp.c
- Timestamp:
- May 10, 2006 7:24:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/ioq_udp.c
r365 r433 42 42 #define PORT 51233 43 43 #define LOOP 100 44 ///#define LOOP 2 44 45 #define BUF_MIN_SIZE 32 45 46 #define BUF_MAX_SIZE 2048 … … 50 51 #undef TRACE_ 51 52 #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 52 60 53 61 static pj_ssize_t callback_read_size, … … 70 78 callback_read_op = op_key; 71 79 callback_read_size = bytes_read; 80 TRACE__((THIS_FILE, " callback_read_key = %p, bytes=%d", 81 key, bytes_read)); 72 82 } 73 83 … … 255 265 status=-45; goto on_error; 256 266 } else if (rc < 0) { 257 app_perror("...ERROR in ioqueue_poll()", rc);267 app_perror("...ERROR in ioqueue_poll()", -rc); 258 268 status=-50; goto on_error; 259 269 } … … 493 503 pj_ioqueue_key_t **key; 494 504 pj_status_t rc; 495 int count, i; 505 int count, i; /* must be signed */ 496 506 497 507 PJ_LOG(3,(THIS_FILE,"...testing with so many handles")); … … 534 544 /* Now deregister and close all handles. */ 535 545 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) { 537 559 rc = pj_ioqueue_unregister(key[i]); 538 560 if (rc != PJ_SUCCESS) { … … 571 593 pj_ioqueue_key_t *skey, *ckey, *key; 572 594 pj_timestamp t1, t2, t_elapsed; 573 int rc=0, i; 595 int rc=0, i; /* i must be signed */ 574 596 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)); 576 600 577 601 // Create pool. … … 692 716 &addr, sizeof(addr)); 693 717 if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { 694 app_perror("...error: pj_ioqueue_write()", bytes);718 app_perror("...error: pj_ioqueue_write()", rc); 695 719 break; 720 } 721 if (rc == PJ_SUCCESS) { 722 if (bytes < 0) { 723 app_perror("...error: pj_ioqueue_sendto()", -bytes); 724 break; 725 } 696 726 } 697 727 … … 702 732 callback_read_key = NULL; 703 733 callback_read_size = 0; 734 TRACE__((THIS_FILE, " waiting for key = %p", skey)); 704 735 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)); 706 739 } while (rc >= 0 && callback_read_key != skey); 707 740 … … 750 783 751 784 // Cleaning up. 752 for (i= 0; i<inactive_sock_count; ++i)785 for (i=inactive_sock_count-1; i>=0; --i) { 753 786 pj_sock_close(inactive_sock[i]); 787 } 788 754 789 pj_sock_close(ssock); 755 790 pj_sock_close(csock); 791 756 792 757 793 pj_ioqueue_destroy(ioque);
Note: See TracChangeset
for help on using the changeset viewer.