aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-06-09 19:18:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 22:56:48 +0200
commit9e28495cb7309ea07431a02838eccbbb46841daa (patch)
tree210961b934d8da300232d25da9c66cecfcce3055 /src
parent2f1058dc171ef8dc4035f5cd9135de7535ab6a80 (diff)
Fix send not working, allow sending 0 bytes
Diffstat (limited to 'src')
-rw-r--r--src/BootstrapConnection.cpp2
-rw-r--r--src/DirectConnection.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp
index fffb332..361f13a 100644
--- a/src/BootstrapConnection.cpp
+++ b/src/BootstrapConnection.cpp
@@ -91,7 +91,7 @@ namespace sibs
throw PubsubKeyAlreadyListeningException("");
listenCallbackFuncs[pubsubKey] = callbackFunc;
}
- connections.send(serverPeer, std::make_shared<std::vector<u8>>(pubsubKey.data.data(), pubsubKey.data.data()),
+ connections.send(serverPeer, std::make_shared<std::vector<u8>>(pubsubKey.data.begin(), pubsubKey.data.end()),
[](PubSubResult result, const std::string &resultStr)
{
Log::debug("BootstrapConnection::listen: PubSubResult: %d, result string: %s", result, resultStr.c_str());
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp
index 713b3ac..8e60c47 100644
--- a/src/DirectConnection.cpp
+++ b/src/DirectConnection.cpp
@@ -126,7 +126,7 @@ namespace sibs
std::thread([peer, data, sendDataCallbackFunc]()
{
usize sentSizeTotal = 0;
- while(sentSizeTotal < data->size())
+ while(sentSizeTotal < data->size() || data->size() == 0)
{
int sentSize = UDT::send(peer->socket, (char*)data->data() + sentSizeTotal, data->size() - sentSizeTotal, 0);
if(sentSize == UDT::ERROR)
@@ -135,6 +135,8 @@ namespace sibs
sendDataCallbackFunc(PubSubResult::ERROR, UDT::getlasterror_desc());
}
sentSizeTotal += sentSize;
+ if(data->size() == 0)
+ break;
}
if(sendDataCallbackFunc)
sendDataCallbackFunc(PubSubResult::OK, "");