diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 264a22a7bfa9d84cc1ff6235bfff445479383c26..ef48cb8a461bca000b0ff5b02c52128faa687d4f 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);