@@ -1066,6 +1066,54 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
10661066 return err ;
10671067}
10681068
1069+ static int ClientWriteRead (WOLFSSL * ssl , const char * msg , int msgSz ,
1070+ char * reply , int replyLen , int mustRead ,
1071+ const char * str , int exitWithRet )
1072+ {
1073+ int ret = 0 ;
1074+
1075+ do {
1076+ ret = ClientWrite (ssl , msg , msgSz , str , exitWithRet );
1077+ if (ret != 0 ) {
1078+ if (!exitWithRet )
1079+ err_sys ("ClientWrite failed" );
1080+ else
1081+ break ;
1082+ }
1083+ if (wolfSSL_dtls (ssl )) {
1084+ ret = tcp_select (wolfSSL_get_fd (ssl ), DEFAULT_TIMEOUT_SEC );
1085+ if (ret == TEST_TIMEOUT ) {
1086+ continue ;
1087+ }
1088+ else if (ret == TEST_RECV_READY ) {
1089+ /* Ready to read */
1090+ }
1091+ else {
1092+ LOG_ERROR ("%s tcp_select error\n" , str );
1093+ if (!exitWithRet )
1094+ err_sys ("tcp_select failed" );
1095+ else
1096+ ret = WOLFSSL_FATAL_ERROR ;
1097+ break ;
1098+ }
1099+ }
1100+ ret = ClientRead (ssl , reply , replyLen , mustRead , str , exitWithRet );
1101+ if (mustRead && ret != 0 ) {
1102+ if (!exitWithRet )
1103+ err_sys ("ClientRead failed" );
1104+ else
1105+ break ;
1106+ }
1107+ } while (0 );
1108+
1109+ if (ret != 0 ) {
1110+ char buffer [WOLFSSL_MAX_ERROR_SZ ];
1111+ LOG_ERROR ("SSL_write%s msg error %d, %s\n" , str , ret ,
1112+ wolfSSL_ERR_error_string (ret , buffer ));
1113+ }
1114+
1115+ return ret ;
1116+ }
10691117
10701118/* when adding new option, please follow the steps below: */
10711119/* 1. add new option message in English section */
@@ -4195,15 +4243,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
41954243 wolfSSL_update_keys (ssl );
41964244#endif
41974245
4198- err = ClientWrite (ssl , msg , msgSz , "" , exitWithRet );
4199- if (exitWithRet && (err != 0 )) {
4200- ((func_args * )args )-> return_code = err ;
4201- wolfSSL_free (ssl ); ssl = NULL ;
4202- wolfSSL_CTX_free (ctx ); ctx = NULL ;
4203- goto exit ;
4204- }
4205-
4206- err = ClientRead (ssl , reply , sizeof (reply )- 1 , 1 , "" , exitWithRet );
4246+ err = ClientWriteRead (ssl , msg , msgSz , reply , sizeof (reply )- 1 , 1 , "" ,
4247+ exitWithRet );
42074248 if (exitWithRet && (err != 0 )) {
42084249 ((func_args * )args )-> return_code = err ;
42094250 wolfSSL_free (ssl ); ssl = NULL ;
@@ -4500,10 +4541,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
45004541 msgSz = (int )XSTRLEN (kResumeMsg );
45014542 XMEMCPY (msg , kResumeMsg , msgSz );
45024543 }
4503- (void )ClientWrite (sslResume , msg , msgSz , " resume" , 0 );
45044544
4505- (void )ClientRead (sslResume , reply , sizeof (reply )- 1 , sendGET ,
4506- "Server resume: " , 0 );
4545+ (void )ClientWriteRead (sslResume , msg , msgSz , reply , sizeof (reply ),
4546+ sendGET , " resume" , 0 );
45074547
45084548 ret = wolfSSL_shutdown (sslResume );
45094549 if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE )
0 commit comments