Skip to content

Hang when shutting down blocking concurrent queue via interrupt #411

@diehard2

Description

@diehard2

When attempting to interrupt a blocking concurrent queue that is waiting on a time out, I'm experiencing a hang (until the timeout) in this line

        do {
#ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
          rc = sem_clockwait(&m_sema, CLOCK_MONOTONIC, &ts);
#else
          rc = sem_timedwait(&m_sema, &ts);
#endif
        } while (rc == -1 && errno == EINTR);
        return rc == 0;

If I change it to respect the interrupt, the timeout doesn't work. However, I'm unable to ctrl-c in my program and shut it down cleanly. What can I do here short of implementing some sort of poll and a smaller timeout?

Also, out of curiosity, is there a benefit to using MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions