boostorg / boostorg/interprocess
blocked in message_queue::timed_receive
- Vorherrschende Sprache
- C++
- Sterne
- 185
- Forks
- 131
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne damit, den gemeldeten Aufruf von message_queue::timed_receive mit dem 100-Millisekunden-Timeout zu reproduzieren, und untersuche anschließend boost/interprocess/sync/detail/common_algorithms.hpp, wo try_based_lock aktiv wartet, solange m.try_lock() false zurückgibt. Verfolge den Besitz des Locks und den Timeout-Pfad; fertig ist die Arbeit, wenn der gemeldete Aufruf zurückkehrt, statt weiterhin blockiert zu bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100