Let's add a comment in vmci_sockets.h explaining why we intentionally "leak"
a file handle in VMCISock_GetAFValueFd.
fd is intentionally left open when outFd is NULL. Closing it
will break applications running on Linux without a fixed AF for
vSockets. In such cases, the fd will be closed during cleanup when
the application exits.
/*********************************************************
- * Copyright (C) 2007-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2017, 2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
family = -1;
}
+ /*
+ * fd is intentionally left open when outFd is NULL. Closing it here
+ * will break applications running on Linux without a fixed AF for
+ * vSockets. In such cases, the fd will be closed during cleanup when
+ * the application exits. Refer to the description of
+ * VMCISock_GetAFValue.
+ */
if (family < 0) {
close(fd);
} else if (outFd) {