Skip to content

Commit 5ca057d

Browse files
authored
gloo: fix error what
Differential Revision: D70212634 Pull Request resolved: #412
1 parent 80a6f33 commit 5ca057d

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

gloo/transport/tcp/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Device : public ::gloo::transport::Device,
9191
// connection is cached in a map, using the sequence number.
9292
//
9393
using connect_callback_t =
94-
std::function<void(std::shared_ptr<Socket> socket, Error error)>;
94+
std::function<void(std::shared_ptr<Socket> socket, const Error& error)>;
9595

9696
void connect(
9797
const Address& local,

gloo/transport/tcp/error.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class Error {
2323

2424
virtual ~Error() = default;
2525

26+
// Don't allow Error to be copied or moved to avoid losing the error message.
27+
Error(const Error&) = delete;
28+
Error& operator=(const Error&) = delete;
29+
2630
// Converting to boolean means checking if there is an error. This
2731
// means we don't need to use an `std::optional` and allows for a
2832
// snippet like the following:

gloo/transport/tcp/listener.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace tcp {
3030
class Listener final : public Handler {
3131
public:
3232
using connect_callback_t =
33-
std::function<void(std::shared_ptr<Socket> socket, Error error)>;
33+
std::function<void(std::shared_ptr<Socket> socket, const Error& error)>;
3434

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

gloo/transport/tcp/pair.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void Pair::connect(const std::vector<char>& bytes) {
141141
waitUntilConnected(lock, true);
142142
}
143143

144-
void Pair::connectCallback(std::shared_ptr<Socket> socket, Error error) {
144+
void Pair::connectCallback(std::shared_ptr<Socket> socket, const Error& error) {
145145
std::lock_guard<std::mutex> lock(m_);
146146
if (error) {
147147
signalException(GLOO_ERROR_MSG(error.what()));

gloo/transport/tcp/pair.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class Pair : public ::gloo::transport::Pair, public Handler {
190190
void sendNotifyRecvReady(uint64_t slot, size_t nbytes);
191191
void sendNotifySendReady(uint64_t slot, size_t nbytes);
192192

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

195195
Buffer* getBuffer(int slot);
196196
void registerBuffer(Buffer* buf);

0 commit comments

Comments
 (0)