From dff4ce0c1524433923344e985e6d7aa54bba87ce Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 15 Aug 2019 10:40:41 +0300
Subject: [PATCH] Check for send errors on windows

---
 components/net/cpp/src/peer.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp
index 264a22a7b..ef48cb8a4 100644
--- a/components/net/cpp/src/peer.cpp
+++ b/components/net/cpp/src/peer.cpp
@@ -678,12 +678,19 @@ int Peer::_send() {
 		//c += ftl::net::internal::send(sock_, (char*)send_vec[i].iov_base, (int)send_vec[i].iov_len, 0);
 	}
 
-	DWORD bytessent;
+	DWORD bytessent = 0;
 	WSAOVERLAPPED ovl;
 	ovl.hEvent = NULL;
 	int c = WSASend(sock_, wsabuf.data(), send_size, (LPDWORD)&bytessent, 0, &ovl, NULL);
 
-	// Could do work here.
+	if (c == 0) {
+		send_buf_.clear();
+		return true;
+	}
+
+	// Could do work here if send did not finish...
+	// Must unlock send_mtx_
+	LOG(INFO) << "Could do work...";
 
 	DWORD flags = 0;
 	c = WSAGetOverlappedResult(sock_, &ovl, (LPDWORD)&bytessent, TRUE, (LPDWORD)&flags);
-- 
GitLab