Changeset 2986 for pjproject/trunk/pjlib/src/pjlib-test/ssl_sock.c
- Timestamp:
- Nov 4, 2009 5:08:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/ssl_sock.c
r2981 r2986 151 151 } 152 152 153 /* Start reading data */ 154 read_buf[0] = st->read_buf; 155 status = pj_ssl_sock_start_read2(ssock, st->pool, sizeof(st->read_buf), (void**)read_buf, 0); 156 if (status != PJ_SUCCESS) { 157 app_perror("...ERROR pj_ssl_sock_start_read2()", status); 158 goto on_return; 159 } 160 153 161 /* Start sending data */ 154 162 while (st->sent < st->send_str_len) { … … 169 177 } 170 178 171 /* Start reading data */172 read_buf[0] = st->read_buf;173 status = pj_ssl_sock_start_read2(ssock, st->pool, sizeof(st->read_buf), (void**)read_buf, 0);174 if (status != PJ_SUCCESS && status != PJ_EPENDING) {175 app_perror("...ERROR pj_ssl_sock_start_read2()", status);176 goto on_return;177 }178 179 179 on_return: 180 180 st->err = status; … … 196 196 { 197 197 struct test_state *parent_st = (struct test_state*) 198 198 pj_ssl_sock_get_user_data(ssock); 199 199 struct test_state *st; 200 200 void *read_buf[1]; … … 237 237 dump_cert_info(".......", &info.remote_cert_info); 238 238 } 239 } 240 241 /* Start reading data */ 242 read_buf[0] = st->read_buf; 243 status = pj_ssl_sock_start_read2(newsock, st->pool, sizeof(st->read_buf), (void**)read_buf, 0); 244 if (status != PJ_SUCCESS) { 245 app_perror("...ERROR pj_ssl_sock_start_read2()", status); 246 goto on_return; 239 247 } 240 248 … … 255 263 else 256 264 break; 257 }258 259 /* Start reading data */260 read_buf[0] = st->read_buf;261 status = pj_ssl_sock_start_read2(newsock, st->pool, sizeof(st->read_buf), (void**)read_buf, 0);262 if (status != PJ_SUCCESS && status != PJ_EPENDING) {263 app_perror("...ERROR pj_ssl_sock_start_read2()", status);264 goto on_return;265 265 } 266 266 … … 422 422 #define HTTP_SERVER_PORT 443 423 423 424 static int https_client_test( void)424 static int https_client_test(unsigned ms_timeout) 425 425 { 426 426 pj_pool_t *pool = NULL; 427 427 pj_ioqueue_t *ioqueue = NULL; 428 pj_timer_heap_t *timer = NULL; 428 429 pj_ssl_sock_t *ssock = NULL; 429 430 pj_ssl_sock_param param; … … 436 437 437 438 status = pj_ioqueue_create(pool, 4, &ioqueue); 439 if (status != PJ_SUCCESS) { 440 goto on_return; 441 } 442 443 status = pj_timer_heap_create(pool, 4, &timer); 438 444 if (status != PJ_SUCCESS) { 439 445 goto on_return; … … 452 458 param.user_data = &state; 453 459 param.server_name = pj_str((char*)HTTP_SERVER_ADDR); 460 param.timer_heap = timer; 461 param.timeout.sec = 0; 462 param.timeout.msec = ms_timeout; 463 pj_time_val_normalize(¶m.timeout); 454 464 455 465 status = pj_ssl_sock_create(pool, ¶m, &ssock); … … 476 486 pj_time_val delay = {0, 100}; 477 487 pj_ioqueue_poll(ioqueue, &delay); 488 pj_timer_heap_poll(timer, &delay); 478 489 #endif 479 490 } … … 492 503 if (ioqueue) 493 504 pj_ioqueue_destroy(ioqueue); 505 if (timer) 506 pj_timer_heap_destroy(timer); 494 507 if (pool) 495 508 pj_pool_release(pool); … … 633 646 } 634 647 648 /* Clean up sockets */ 649 { 650 pj_time_val delay = {0, 100}; 651 while (pj_ioqueue_poll(ioqueue, &delay) > 0); 652 } 653 635 654 if (state_serv.err || state_cli.err) { 636 655 if (state_serv.err != PJ_SUCCESS) … … 683 702 st->err = status; 684 703 704 if (st->err != PJ_SUCCESS || st->done) { 705 pj_activesock_close(asock); 706 if (!st->is_server) 707 clients_num--; 708 return PJ_FALSE; 709 } 710 685 711 return PJ_TRUE; 686 712 } … … 694 720 695 721 if (status == PJ_SUCCESS) { 696 status = pj_activesock_start_read(asock, st->pool, 1, 0); 722 void *read_buf[1]; 723 724 /* Start reading data */ 725 read_buf[0] = st->read_buf; 726 status = pj_activesock_start_read2(asock, st->pool, sizeof(st->read_buf), (void**)read_buf, 0); 727 if (status != PJ_SUCCESS) { 728 app_perror("...ERROR pj_ssl_sock_start_read2()", status); 729 } 697 730 } 698 731 699 732 st->err = status; 733 734 if (st->err != PJ_SUCCESS) { 735 pj_activesock_close(asock); 736 if (!st->is_server) 737 clients_num--; 738 return PJ_FALSE; 739 } 700 740 701 741 return PJ_TRUE; … … 846 886 if (ssock_serv) 847 887 pj_ssl_sock_close(ssock_serv); 848 if (asock_cli )888 if (asock_cli && !state_cli.err && !state_cli.done) 849 889 pj_activesock_close(asock_cli); 850 890 if (timer) … … 859 899 860 900 901 /* Test will perform multiple clients trying to connect to single server. 902 * Once SSL connection established, echo test will be performed. 903 */ 861 904 static int perf_test(unsigned clients, unsigned ms_handshake_timeout) 862 905 { … … 1023 1066 } 1024 1067 1068 /* Clean up sockets */ 1069 { 1070 pj_time_val delay = {0, 500}; 1071 while (pj_ioqueue_poll(ioqueue, &delay) > 0); 1072 } 1073 1025 1074 if (state_serv.err != PJ_SUCCESS) { 1026 1075 status = state_serv.err; … … 1078 1127 return ret; 1079 1128 1080 // Disable this test as requiring internet connection.1081 #if 01082 1129 PJ_LOG(3,("", "..https client test")); 1083 ret = https_client_test(); 1084 if (ret != 0) 1085 return ret; 1086 #endif 1130 ret = https_client_test(30000); 1131 // Ignore test result as internet connection may not be available. 1132 //if (ret != 0) 1133 //return ret; 1134 1135 #ifndef PJ_SYMBIAN 1087 1136 1088 1137 PJ_LOG(3,("", "..echo test w/ TLSv1 and TLS_RSA_WITH_DES_CBC_SHA cipher")); … … 1110 1159 return PJ_EBUG; 1111 1160 1112 PJ_LOG(3,("", "..client non-SSL timeout in 5 secs"));1161 PJ_LOG(3,("", "..client non-SSL (handshake timeout 5 secs)")); 1113 1162 ret = client_non_ssl(5000); 1114 1163 if (ret != 0) … … 1119 1168 if (ret != 0) 1120 1169 return ret; 1170 1171 #endif 1121 1172 1122 1173 return 0;
Note: See TracChangeset
for help on using the changeset viewer.