Skip to content

Peeking at a port that is used after a sleep rarely terminates #9396

Closed
@jdm

Description

@jdm
use std::comm;
use std::rt::io::timer::Timer;

fn main() {
    let (port, chan) = comm::stream();
    do spawn {
        let mut timer = Timer::new().unwrap();
        timer.sleep(10);
        chan.send(());
    }
    loop {
        if port.peek() {
            break;
        }
    }
    port.recv();
}

This will often never leave the loop. If the timer is removed, it always succeeds instantly. If the peek is removed (so we block on receiving), it always succeeds once the sleep terminates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions