X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstream-ssl.c;h=e501b995da8edc77713e216f7cbe1eead07bc873;hb=3ef917b5699874c46131c1d8731fafc5246c0dd1;hp=11bbf4adae73460427c7a6272ad5ecf2b31a6e6c;hpb=42967038cbbb56b894e99eb17e5de7cfb11de9cf;p=openvswitch diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 11bbf4ad..e501b995 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -437,6 +437,14 @@ ssl_close(struct stream *stream) { struct ssl_stream *sslv = ssl_stream_cast(stream); ssl_clear_txbuf(sslv); + + /* Attempt clean shutdown of the SSL connection. This will work most of + * the time, as long as the kernel send buffer has some free space and the + * SSL connection isn't renegotiating, etc. That has to be good enough, + * since we don't have any way to continue the close operation in the + * background. */ + SSL_shutdown(sslv->ssl); + SSL_free(sslv->ssl); close(sslv->fd); free(sslv); @@ -541,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); } } } @@ -589,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; @@ -598,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; } } } @@ -723,7 +732,7 @@ pssl_open(const char *name UNUSED, char *suffix, struct pstream **pstreamp) return retval; } - fd = inet_open_passive(SOCK_STREAM, suffix, OFP_SSL_PORT, NULL); + fd = inet_open_passive(SOCK_STREAM, suffix, OFP_SSL_PORT, &sin); if (fd < 0) { return -fd; }