Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Common/Cpp/Sockets/AbstractServerSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ class AbstractServerSocket{
// State::LISTENING on success or State::NOT_RUNNING on failure.
virtual void start(const std::string& address, uint16_t port) = 0;

// Closes the active connection, if any, and keeps listening.
// Closes the active connection, if any, and keeps listening. Unlike
// "close()", this does not wait for the worker threads, so it is safe
// to call from within a listener callback. "Listener::on_disconnect"
// is not called for the connection closed this way.
virtual void close_connection() = 0;

// Stops the server: it stops accepting new connections, closes the
Expand Down
7 changes: 4 additions & 3 deletions Common/Cpp/Sockets/ClientSocket_POSIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ size_t ClientSocket_POSIX::send(const void* data, size_t bytes){
size_t current = std::min<size_t>(bytes, BLOCK_SIZE);
ssize_t current_sent = ::send(socket, ptr, (int)current, MSG_DONTWAIT | MSG_NOSIGNAL);
if (current_sent != -1){
// send() may return after writing only part of the
// buffer (macOS does this when the kernel's send
// buffer is full); loop until everything has been
// written, the same way the Qt backend does.
sent += current_sent;
if ((size_t)current_sent < current){
return sent;
}
ptr += current_sent;
bytes -= current_sent;
continue;
Expand Down
3 changes: 1 addition & 2 deletions Common/Cpp/Sockets/ClientSocket_Qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <string>
#include <atomic>
#include <condition_variable>
#include <QObject>
#include "Common/Cpp/Concurrency/Mutex.h"
#include "Common/Cpp/Concurrency/ConditionVariable.h"
Expand All @@ -32,7 +31,7 @@ class ClientSocket_Qt final : public QObject, public AbstractClientSocket{
bool done = false;

Mutex lock;
std::condition_variable cv;
ConditionVariable cv;
};


Expand Down
Loading
Loading