boostorg / boostorg/interprocess

named_condition_any does not appear to notify

Offen
#73 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
185
Forks
131
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I haven't been able to get named_condition_any objects to work on Linux with Boost 1.68.0. Below is code to replicate. When using a named_condition_any the child process will never receive the notification, when using just a named_condition the child process receives the notifications.

```c++
#include
#include
#include
#include

#include

#include
#include
#include

namespace ip = boost::interprocess;

int main()
{
typedef ip::named_mutex mutex_type;
//typedef ip::named_condition condition_type;
typedef ip::named_condition_any condition_type;

mutex_type::remove("test_mutex");
condition_type::remove("test_condition");

pid_t pid = fork();
if(pid == 0)
{ // parent process
mutex_type mutex(ip::open_or_create, "test_mutex");
condition_type condition(ip::open_or_create, "test_condition");

while(true)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "signaling children" << std::endl;
condition.notify_all();
}
}
else if(pid > 0)
{ // child process
mutex_type mutex(ip::open_or_create, "test_mutex");
condition_type condition(ip::open_or_create, "test_condition");

while(true)
{
boost::posix_time::ptime wait_time(boost::get_system_time() +
boost::posix_time::seconds(10));
ip::scoped_lock lock(mutex);
if(condition.timed_wait(lock, wait_time))
std::cout << "got signal from parent" << std::endl;
else
std::cout << "timeout" << std::endl;
}
}
else
{
std::cout << "failed to fork: " << pid << std::endl;
return 1;
}

return 0;
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginnen Sie mit dem Reproducer und kompilieren Sie ihn unter Linux gegen Boost 1.68.0. Vergleichen Sie das Verhalten und die Implementierungspfade für boost/interprocess/sync/named_condition_any.hpp und named_condition.hpp und überprüfen Sie anschließend, dass das Kind Benachrichtigungen empfängt, wenn named_condition_any verwendet wird, einschließlich zeitgesteuerter Warteaufrufe.

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
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.