system-proxy: Release CurlSocket fd
The fd wrapped by CurlSocket is created by libcurl which expects to
close it in the cleanup handle. If the fd is not released from the
CurlSocket instance, it will be closed when the ScopedFD runs out of
scope and libcurl will throw an error at cleanup.
BUG=chromium:1042626
TEST=none
Change-Id: I7fcb1544d4f8f6bab0ebf4c5fa66cc0022ca4f66
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2144203
Tested-by: Andreea-Elena Costinas <acostinas@google.com>
Commit-Queue: Andreea-Elena Costinas <acostinas@google.com>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
diff --git a/system-proxy/curl_socket.cc b/system-proxy/curl_socket.cc
index 8182c02..5144743 100644
--- a/system-proxy/curl_socket.cc
+++ b/system-proxy/curl_socket.cc
@@ -13,6 +13,12 @@
: arc_networkd::Socket(std::move(fd)),
curl_easyhandle_(std::move(curl_easyhandle)) {}
-CurlSocket::~CurlSocket() = default;
+CurlSocket::~CurlSocket() {
+ // TODO(acostinas,https://crbug.com/1070732) Allow SocketForwarder creation
+ // with raw sockets and defer closing the socket to libcurl via a callback
+ // instead of releaing the socket in the destructor.
+ int fd = release();
+ VLOG(1) << "Released " << fd << " to be closed by the curl handler";
+}
} // namespace system_proxy