boostorg / boostorg/interprocess
blocked in message_queue::timed_receive
- 主要言語
- C++
- スター
- 185
- フォーク
- 131
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I'm using boost_1_89_0 & boost::interprocess::message_queue for inter-process communication. The receiver calls timed_receive to receive messages with a timeout set to 100 milliseconds. It works correctly most of the time, but occasionally it gets blocked, meaning timed_receive does not return.
```
boost::interprocess::message_queue *msg_queue;
// ...
boost::posix_time::ptime timeout = boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(100);
bool ret = msg_queue->timed_receive(buf, 8192, recvd_size, priority, timeout);
```
I checked the call stack, and it is blocked at the following location:
boost\interprocess\sync\detail\common_algorithms.hpp
```
template
void try_based_lock(MutexType &m)
{boost::interprocess::message_queue
if(!m.try_lock()){
spin_wait swait;
do{
if(m.try_lock()){
break;
}
else{
swait.yield();
}
}
while(1);
}
}
```
I stepped through the code and found that `m.try_lock()` keeps returning false.
Thanks.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、100ミリ秒のタイムアウトを指定した報告済みの message_queue::timed_receive 呼び出しを再現し、次に boost/interprocess/sync/detail/common_algorithms.hpp を調べます。ここでは、m.try_lock() が false を返している間、try_based_lock がスピンします。ロックの所有権とタイムアウトの経路を追跡します。報告された呼び出しがブロックされたままにならずに戻れば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- cpp
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100