Performance improvement for OpenSSLSocketImpl in read and write

This change only calls SSL_get_error only in case of an error and not in any case as it does before the change.

BUG=1322058
diff --git a/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp b/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
index fd68460..8f36632 100644
--- a/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
+++ b/libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl.cpp
@@ -668,8 +668,11 @@
         
         // LOGD("Doing SSL_Read()");
         int result = SSL_read(ssl, buf, len);
-        int error = SSL_get_error(ssl, result);
-        freeSslErrorState();
+        int error = SSL_ERROR_NONE;
+        if (result <= 0) {
+            error = SSL_get_error(ssl, result);
+            freeSslErrorState();
+        }
         // LOGD("Returned from SSL_Read() with result %d, error code %d", result, error);
 
         // If we have been successful in moving data around, check whether it
@@ -783,8 +786,11 @@
         
         // LOGD("Doing SSL_write() with %d bytes to go", len);
         int result = SSL_write(ssl, buf, len);
-        int error = SSL_get_error(ssl, result);
-        freeSslErrorState();
+        int error = SSL_ERROR_NONE;
+        if (result <= 0) {
+            error = SSL_get_error(ssl, result);
+            freeSslErrorState();
+        }
         // LOGD("Returned from SSL_write() with result %d, error code %d", result, error);
 
         // If we have been successful in moving data around, check whether it