diff options
author | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2012-02-10 16:33:27 +0200 |
---|---|---|
committer | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2012-02-10 16:33:27 +0200 |
commit | 724af49cf01c29dae55fb0b4b43d1d265cf4f3f1 (patch) | |
tree | 729e10de198e048a97b7fb3ca2d62a16b98ee613 /extra/yassl/examples | |
parent | a25adb1cc830d7e263daa03560a129ac9cd6828a (diff) | |
download | mariadb-git-724af49cf01c29dae55fb0b4b43d1d265cf4f3f1.tar.gz |
Bug #13706828: UPGRADE YASSL FROM 1.7.2 TO 2.1.4
$SUBJ$
1. Took a diff between the previous base version and the
mysql sources.
2. Added the new 2.1.4 base version.
3. Reviewed and re-applied the diff from step #1.
Diffstat (limited to 'extra/yassl/examples')
-rw-r--r-- | extra/yassl/examples/client/client.cpp | 22 | ||||
-rw-r--r-- | extra/yassl/examples/echoclient/echoclient.cpp | 6 | ||||
-rw-r--r-- | extra/yassl/examples/echoserver/echoserver.cpp | 12 | ||||
-rw-r--r-- | extra/yassl/examples/server/server.cpp | 17 |
4 files changed, 34 insertions, 23 deletions
diff --git a/extra/yassl/examples/client/client.cpp b/extra/yassl/examples/client/client.cpp index a80a8c2f1a2..d05c31d4d63 100644 --- a/extra/yassl/examples/client/client.cpp +++ b/extra/yassl/examples/client/client.cpp @@ -36,15 +36,20 @@ void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd) { int ret = SSL_connect(ssl); - while (ret =! SSL_SUCCESS && SSL_get_error(ssl, 0) == - SSL_ERROR_WANT_READ) { - printf("... client would block\n"); + int err = SSL_get_error(ssl, 0); + while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ || + err == SSL_ERROR_WANT_WRITE)) { + if (err == SSL_ERROR_WANT_READ) + printf("... client would read block\n"); + else + printf("... client would write block\n"); #ifdef _WIN32 Sleep(1000); #else sleep(1); #endif ret = SSL_connect(ssl); + err = SSL_get_error(ssl, 0); } if (ret != SSL_SUCCESS) ClientError(ctx, ssl, sockfd, "SSL_connect failed"); @@ -81,7 +86,8 @@ void client_test(void* args) #ifdef NON_BLOCKING NonBlockingSSL_Connect(ssl, ctx, sockfd); #else - if (SSL_connect(ssl) != SSL_SUCCESS) + // if you get an error here see note at top of README + if (SSL_connect(ssl) != SSL_SUCCESS) ClientError(ctx, ssl, sockfd, "SSL_connect failed"); #endif showPeer(ssl); @@ -105,7 +111,7 @@ void client_test(void* args) int input = SSL_read(ssl, reply, sizeof(reply)); if (input > 0) { reply[input] = 0; - printf("Server response: %s\n", reply); + printf("Server response: %s\n", reply); } #ifdef TEST_RESUME @@ -121,18 +127,18 @@ void client_test(void* args) tcp_connect(sockfd); SSL_set_fd(sslResume, sockfd); SSL_set_session(sslResume, session); - + if (SSL_connect(sslResume) != SSL_SUCCESS) ClientError(ctx, sslResume, sockfd, "SSL_resume failed"); showPeer(sslResume); - + if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg)) ClientError(ctx, sslResume, sockfd, "SSL_write failed"); input = SSL_read(sslResume, reply, sizeof(reply)); if (input > 0) { reply[input] = 0; - printf("Server response: %s\n", reply); + printf("Server response: %s\n", reply); } SSL_shutdown(sslResume); diff --git a/extra/yassl/examples/echoclient/echoclient.cpp b/extra/yassl/examples/echoclient/echoclient.cpp index 787e554f8bf..c2b8ff66ac9 100644 --- a/extra/yassl/examples/echoclient/echoclient.cpp +++ b/extra/yassl/examples/echoclient/echoclient.cpp @@ -74,10 +74,10 @@ void echoclient_test(void* args) char send[1024]; char reply[1024]; - + while (fgets(send, sizeof(send), fin)) { - int sendSz = strlen(send) + 1; + int sendSz = (int)strlen(send) + 1; if (SSL_write(ssl, send, sendSz) != sendSz) EchoClientError(ctx, ssl, sockfd, "SSL_write failed"); @@ -86,7 +86,7 @@ void echoclient_test(void* args) break; } - if (SSL_read(ssl, reply, sizeof(reply)) > 0) + if (SSL_read(ssl, reply, sizeof(reply)) > 0) fputs(reply, fout); } diff --git a/extra/yassl/examples/echoserver/echoserver.cpp b/extra/yassl/examples/echoserver/echoserver.cpp index a3ba8c12c60..bd044e70e8b 100644 --- a/extra/yassl/examples/echoserver/echoserver.cpp +++ b/extra/yassl/examples/echoserver/echoserver.cpp @@ -93,11 +93,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) #endif while (!shutdown) { - sockaddr_in client; + SOCKADDR_IN_T client; socklen_t client_len = sizeof(client); SOCKET_T clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len); - if (clientfd == -1) { + if (clientfd == (SOCKET_T) -1) { SSL_CTX_free(ctx); tcp_close(sockfd); err_sys("tcp accept failed"); @@ -111,11 +111,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) tcp_close(clientfd); continue; } - + char command[1024]; int echoSz(0); while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) { - + if ( strncmp(command, "quit", 4) == 0) { printf("client sent quit command: shutting down!\n"); shutdown = true; @@ -127,7 +127,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) char header[] = "<html><body BGCOLOR=\"#ffffff\">\n<pre>\n"; char body[] = "greetings from yaSSL\n"; char footer[] = "</body></html>\r\n\r\n"; - + strncpy(command, type, sizeof(type)); echoSz = sizeof(type) - 1; @@ -140,7 +140,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) if (SSL_write(ssl, command, echoSz) != echoSz) EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed"); - + break; } command[echoSz] = 0; diff --git a/extra/yassl/examples/server/server.cpp b/extra/yassl/examples/server/server.cpp index 8b8066eace5..3fac40e88c4 100644 --- a/extra/yassl/examples/server/server.cpp +++ b/extra/yassl/examples/server/server.cpp @@ -35,15 +35,20 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd) { int ret = SSL_accept(ssl); - while (ret != SSL_SUCCESS && SSL_get_error(ssl, 0) == - SSL_ERROR_WANT_READ) { - printf("... server would block\n"); + int err = SSL_get_error(ssl, 0); + while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ || + err == SSL_ERROR_WANT_WRITE)) { + if (err == SSL_ERROR_WANT_READ) + printf("... server would read block\n"); + else + printf("... server would write block\n"); #ifdef _WIN32 Sleep(1000); #else sleep(1); #endif ret = SSL_accept(ssl); + err = SSL_get_error(ssl, 0); } if (ret != SSL_SUCCESS) ServerError(ctx, ssl, clientfd, "SSL_accept failed"); @@ -78,14 +83,14 @@ THREAD_RETURN YASSL_API server_test(void* args) SSL* ssl = SSL_new(ctx); SSL_set_fd(ssl, clientfd); - + #ifdef NON_BLOCKING NonBlockingSSL_Accept(ssl, ctx, clientfd); #else if (SSL_accept(ssl) != SSL_SUCCESS) ServerError(ctx, ssl, clientfd, "SSL_accept failed"); #endif - + showPeer(ssl); printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl)); @@ -93,7 +98,7 @@ THREAD_RETURN YASSL_API server_test(void* args) int input = SSL_read(ssl, command, sizeof(command)); if (input > 0) { command[input] = 0; - printf("First client command: %s\n", command); + printf("First client command: %s\n", command); } char msg[] = "I hear you, fa shizzle!"; |