stream-ssl: Fix ssl_recv() and ssl_send() return value semantics.
authorBen Pfaff <blp@nicira.com>
Thu, 7 Jan 2010 21:58:49 +0000 (13:58 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 7 Jan 2010 23:00:51 +0000 (15:00 -0800)
These functions' return value semantics did not match those documented
in stream-provider.h.

lib/stream-ssl.c

index 436dc7b265a389915506c8309db1ffc566948e3e..6839341c1cf56161fedfb4923c35ce50ea38b2fa 100644 (file)
@@ -549,7 +549,8 @@ ssl_recv(struct stream *stream, void *buffer, size_t n)
         if (error == SSL_ERROR_ZERO_RETURN) {
             return 0;
         } else {
-            return interpret_ssl_error("SSL_read", ret, error, &sslv->rx_want);
+            return -interpret_ssl_error("SSL_read", ret, error,
+                                        &sslv->rx_want);
         }
     }
 }
@@ -597,7 +598,7 @@ ssl_send(struct stream *stream, const void *buffer, size_t n)
     struct ssl_stream *sslv = ssl_stream_cast(stream);
 
     if (sslv->txbuf) {
-        return EAGAIN;
+        return -EAGAIN;
     } else {
         int error;
 
@@ -606,13 +607,13 @@ ssl_send(struct stream *stream, const void *buffer, size_t n)
         switch (error) {
         case 0:
             ssl_clear_txbuf(sslv);
-            return 0;
+            return n;
         case EAGAIN:
             leak_checker_claim(buffer);
-            return 0;
+            return n;
         default:
             sslv->txbuf = NULL;
-            return error;
+            return -error;
         }
     }
 }