Bug fixes

Fixed not setting output int to 0 to specify zero connections when
returning connection IDs.
This commit is contained in:
Stephen Seo 2019-12-17 20:58:44 +09:00
parent dbdade3b00
commit 62ac6e779f
2 changed files with 8 additions and 3 deletions

View file

@ -1490,7 +1490,8 @@ void UDPC::Context::update_impl() {
ntohs(receivedData.sin6_port),
", packet id = ", seqID,
", good mode = ", iter->second.flags.test(1) ? "yes" : "no",
isPing ? ", ping" : "");
isPing && !isConnect ? ", ping"
: (isPing && isConnect ? ", disc" : ""));
// check if is delete
if(isConnect && isPing) {
@ -2167,6 +2168,9 @@ UDPC_ConnectionId* UDPC_get_list_connected(UDPC_HContext ctx, unsigned int *size
std::lock_guard<std::mutex> lock(c->mutex);
if(c->conMap.empty()) {
if(size) {
*size = 0;
}
return nullptr;
}
if(size) {

View file

@ -308,11 +308,12 @@ int main(int argc, char **argv) {
UDPC_set_accept_new_connections(context, 0);
puts("Dropping all connections...");
UDPC_ConnectionId *ids = UDPC_get_list_connected(context, NULL);
UDPC_ConnectionId *ids = UDPC_get_list_connected(context, &temp);
UDPC_ConnectionId *current = ids;
while(current->scope_id != 0 && current->port != 0) {
while(temp > 0) {
UDPC_drop_connection(context, *current, 0);
++current;
--temp;
}
UDPC_free_list_connected(ids);