boostorg / boostorg/interprocess
blocked in message_queue::timed_receive
- Lingua principale
- C++
- Stelle
- 185
- Fork
- 131
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia riproducendo la chiamata segnalata a message_queue::timed_receive con il timeout di 100 millisecondi, quindi esamina boost/interprocess/sync/detail/common_algorithms.hpp, dove try_based_lock esegue uno spin mentre m.try_lock() restituisce false. Traccia la proprietà del lock e il percorso del timeout; il lavoro è completato quando la chiamata segnalata ritorna invece di rimanere bloccata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100