Skip to content

gloo: fix error what #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
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
2 changes: 1 addition & 1 deletion gloo/transport/tcp/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Device : public ::gloo::transport::Device,
// connection is cached in a map, using the sequence number.
//
using connect_callback_t =
std::function<void(std::shared_ptr<Socket> socket, Error error)>;
std::function<void(std::shared_ptr<Socket> socket, const Error& error)>;

void connect(
const Address& local,
Expand Down
4 changes: 4 additions & 0 deletions gloo/transport/tcp/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Error {

virtual ~Error() = default;

// Don't allow Error to be copied or moved to avoid losing the error message.
Error(const Error&) = delete;
Error& operator=(const Error&) = delete;

// Converting to boolean means checking if there is an error. This
// means we don't need to use an `std::optional` and allows for a
// snippet like the following:
Expand Down
2 changes: 1 addition & 1 deletion gloo/transport/tcp/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace tcp {
class Listener final : public Handler {
public:
using connect_callback_t =
std::function<void(std::shared_ptr<Socket> socket, Error error)>;
std::function<void(std::shared_ptr<Socket> socket, const Error& error)>;

static constexpr int kBacklog = -1; // allow somaxconn

Expand Down
2 changes: 1 addition & 1 deletion gloo/transport/tcp/pair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void Pair::connect(const std::vector<char>& bytes) {
waitUntilConnected(lock, true);
}

void Pair::connectCallback(std::shared_ptr<Socket> socket, Error error) {
void Pair::connectCallback(std::shared_ptr<Socket> socket, const Error& error) {
std::lock_guard<std::mutex> lock(m_);
if (error) {
signalException(GLOO_ERROR_MSG(error.what()));
Expand Down
2 changes: 1 addition & 1 deletion gloo/transport/tcp/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Pair : public ::gloo::transport::Pair, public Handler {
void sendNotifyRecvReady(uint64_t slot, size_t nbytes);
void sendNotifySendReady(uint64_t slot, size_t nbytes);

void connectCallback(std::shared_ptr<Socket> socket, Error error);
void connectCallback(std::shared_ptr<Socket> socket, const Error& error);

Buffer* getBuffer(int slot);
void registerBuffer(Buffer* buf);
Expand Down
Loading