diff options
author | Vic Lee <llyzs@163.com> | 2011-06-25 10:41:48 +0400 |
---|---|---|
committer | Vic Lee <llyzs@163.com> | 2011-06-25 10:41:48 +0400 |
commit | 6acc9e53e1c4dda5c8c2995140d936b9706dffd3 (patch) | |
tree | 0960267dc16523cb1765e58955f756edd1954b7d | |
parent | d6c5514f191aada3c308b1bdda3a3d6f9f422193 (diff) |
libfreerdp-core/openssl: fix high CPU usage when TLS is blocking.
-rw-r--r-- | libfreerdp-core/crypto/openssl.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libfreerdp-core/crypto/openssl.c b/libfreerdp-core/crypto/openssl.c index 333585b..84417d7 100644 --- a/libfreerdp-core/crypto/openssl.c +++ b/libfreerdp-core/crypto/openssl.c @@ -21,6 +21,7 @@ #include "crypto.h" #include <freerdp/utils/memory.h> #include <freerdp/constants/constants.h> +#include <time.h> #include "tls.h" #include "crypto/openssl.h" @@ -349,6 +350,7 @@ struct rdp_tls { SSL_CTX * ctx; SSL * ssl; + struct timespec ts; }; RD_BOOL @@ -428,6 +430,10 @@ tls_new(void) SSL_CTX_set_options(tls->ctx, SSL_OP_ALL); + /* a small 0.1ms delay when network blocking happens. */ + tls->ts.tv_sec = 0; + tls->ts.tv_nsec = 100000; + return tls; } @@ -515,6 +521,7 @@ tls_write(rdpTls * tls, char* b, int length) break; case SSL_ERROR_WANT_WRITE: + nanosleep(&tls->ts, NULL); break; default: @@ -543,6 +550,7 @@ tls_read(rdpTls * tls, char* b, int length) break; case SSL_ERROR_WANT_READ: + nanosleep(&tls->ts, NULL); break; default: |