On Wed, Oct 26, 2022 at 05:18:00PM -0500, Eric Blake wrote:
- if (conn->sockin >= 0)
- closesocket (conn->sockin);
- if (conn->sockout >= 0 && conn->sockin != conn->sockout)
- closesocket (conn->sockout);
+ if (conn->sockout >= 0 && how == SHUT_WR) {
+ if (conn->sockin == conn->sockout)
+ shutdown (conn->sockout, how);
+ else
+ closesocket (conn->sockout);
+ conn->sockout = -1;
Don't we leak conn->sockin, if how == SHUT_WR && conn->sockin ==
conn->sockout?
Rich.
+ }
+ else {
+ if (conn->sockin >= 0)
+ closesocket (conn->sockin);
+ if (conn->sockout >= 0 && conn->sockin != conn->sockout)
+ closesocket (conn->sockout);
+ }
}
diff --git a/server/crypto.c b/server/crypto.c
index 1f605083..72486bf8 100644
--- a/server/crypto.c
+++ b/server/crypto.c
@@ -412,7 +412,7 @@ crypto_send (const void *vbuf, size_t len, int flags)
* close, so this function ignores errors.
*/
static void
-crypto_close (void)
+crypto_close (int how)
{
GET_CONN;
gnutls_session_t session = conn->crypto_session;
@@ -420,17 +420,21 @@ crypto_close (void)
assert (session != NULL);
- gnutls_transport_get_int2 (session, &sockin, &sockout);
+ if (how == SHUT_WR)
+ gnutls_bye (session, GNUTLS_SHUT_WR);
+ else {
+ gnutls_transport_get_int2 (session, &sockin, &sockout);
- gnutls_bye (session, GNUTLS_SHUT_RDWR);
+ gnutls_bye (session, GNUTLS_SHUT_RDWR);
- if (sockin >= 0)
- closesocket (sockin);
- if (sockout >= 0 && sockin != sockout)
- closesocket (sockout);
+ if (sockin >= 0)
+ closesocket (sockin);
+ if (sockout >= 0 && sockin != sockout)
+ closesocket (sockout);
- gnutls_deinit (session);
- conn->crypto_session = NULL;
+ gnutls_deinit (session);
+ conn->crypto_session = NULL;
+ }
}
#ifdef WIN32
--
2.37.3
_______________________________________________
Libguestfs mailing list
Libguestfs(a)redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top