mirror of
https://github.com/ceph/ceph
synced 2025-03-06 00:10:04 +00:00
PipeConnection: Avoid deadlock when calling is_connected
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
This commit is contained in:
parent
9783a5cb64
commit
20ea086722
@ -92,6 +92,13 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to judge whether this connection is ready to send. Usually, the
|
||||
* implementation need to build a own shakehand or sesson then it can be
|
||||
* ready to send.
|
||||
*
|
||||
* @return true if ready to send, or false otherwise
|
||||
*/
|
||||
virtual bool is_connected() = 0;
|
||||
|
||||
Messenger *get_messenger() {
|
||||
|
@ -67,11 +67,9 @@ void PipeConnection::reset_pipe(Pipe *p)
|
||||
pipe = p->get();
|
||||
}
|
||||
|
||||
bool PipeConnection::is_connected() {
|
||||
Mutex::Locker l(lock);
|
||||
if (pipe)
|
||||
return pipe->is_connected();
|
||||
return false;
|
||||
bool PipeConnection::is_connected()
|
||||
{
|
||||
return static_cast<SimpleMessenger*>(msgr)->is_connected(this);
|
||||
}
|
||||
|
||||
int PipeConnection::send_message(Message *m)
|
||||
|
@ -266,7 +266,19 @@ void SimpleMessenger::queue_reap(Pipe *pipe)
|
||||
lock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
bool SimpleMessenger::is_connected(Connection *con)
|
||||
{
|
||||
bool r = false;
|
||||
if (con) {
|
||||
Pipe *p = static_cast<Pipe *>(static_cast<PipeConnection*>(con)->get_pipe());
|
||||
if (p) {
|
||||
assert(p->msgr == this);
|
||||
r = p->is_connected();
|
||||
p->put();
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int SimpleMessenger::bind(const entity_addr_t &bind_addr)
|
||||
{
|
||||
|
@ -409,6 +409,11 @@ public:
|
||||
* ready to be torn down.
|
||||
*/
|
||||
void queue_reap(Pipe *pipe);
|
||||
|
||||
/**
|
||||
* Used to get whether this connection ready to send
|
||||
*/
|
||||
bool is_connected(Connection *con);
|
||||
/**
|
||||
* @} // SimpleMessenger Internals
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user