Git Product home page Git Product logo

Comments (7)

Thomasdezeeuw avatar Thomasdezeeuw commented on June 14, 2024

EPOLLPRI is enable by default when using readable interest.

from mio.

poeschel avatar poeschel commented on June 14, 2024

EPOLLPRI is enable by default when using readable interest.

Really? I don't see this backed by the code and I do not get any EPOLLPRI events from the kernel.
Have a look here:

fn interests_to_epoll(interests: Interest) -> u32 {
let mut kind = EPOLLET;
if interests.is_readable() {
kind = kind | EPOLLIN | EPOLLRDHUP;
}
if interests.is_writable() {
kind |= EPOLLOUT;
}
kind as u32
}

This sets the event type flags up for the syscall. And it does not set EPOLLPRI.

I made a "horrible hack" here: poeschel@538970c
With this change I do receive the EPOLLPRI events.

from mio.

Thomasdezeeuw avatar Thomasdezeeuw commented on June 14, 2024

EPOLLPRI is an output flags only if I recall correctly, so you should see it when use register readable interest. If you want to test this for yourself you can send some Out-Of-Bound (MSG_OOB) data to a TcpStream and you should see an event with EPOLLPRI.

from mio.

Urist-McGit avatar Urist-McGit commented on June 14, 2024

Hello, I am working with @poeschel on this problem. We have created a small test project which can be found here: https://github.com/poeschel/mio-pollpri-test

The program sends messages over a TCP socket and checks the received events. We also send a MSG_OOB message. There you can see that the MSG_OOB is in fact received, but does not contain the EPOLLPRI flag, and does not have the priority set to true. Output from the program (only the second message to keep it brief) in this case:

[src/main.rs:43] event = Event {
    token: Token(
        1,
    ),
    readable: true,
    writable: false,
    error: false,
    read_closed: false,
    write_closed: false,
    priority: false,           <<<<<
    aio: false,
    lio: false,
    details: epoll_event {
        events: EPOLLIN,       <<<<<
        u64: 1,
    },
}

With the "horrible hack" posted above, the output changes to:

[src/main.rs:43] event = Event {
    token: Token(
        1,
    ),
    readable: true,
    writable: false,
    error: false,
    read_closed: false,
    write_closed: false,
    priority: true,                   <<<<<
    aio: false,
    lio: false,
    details: epoll_event {
        events: EPOLLIN|EPOLLPRI,     <<<<<
        u64: 1,
    },
}

You can see that the flags contains EPOLLPRI and the priority field is set to true. That likely means MSG_OOB was received only because it also contains the EPOLLIN flag.

As mentioned above, we work with V4L2, and our events do only contain EPOLLPRI. Changing the selector to generally also accept EPOLLPRI events like in our hack, seems like a big breaking change, so we are not quite sure how to proceed.

from mio.

Thomasdezeeuw avatar Thomasdezeeuw commented on June 14, 2024

Hello, I am working with @poeschel on this problem. We have created a small test project which can be found here: https://github.com/poeschel/mio-pollpri-test

This program is incorrect. You should get only a single event for the send on line 20. You should drain the readiness, see https://docs.rs/mio/latest/mio/struct.Poll.html#readiness-operations, to get another event.

from mio.

poeschel avatar poeschel commented on June 14, 2024

I created pull-request #1646 that demonstrates the issue a bit better.

from mio.

poeschel avatar poeschel commented on June 14, 2024

... and I would suggest something like this as a possible solution: poeschel@282edd3

from mio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.