Skip to content

Polling networking#179

Open
davidv1992 wants to merge 8 commits into
mainfrom
polling-networking
Open

Polling networking#179
davidv1992 wants to merge 8 commits into
mainfrom
polling-networking

Conversation

@davidv1992

@davidv1992 davidv1992 commented May 28, 2026

Copy link
Copy Markdown
Member

This implements changes to allow polling networking, with only shared borrows on the socket.

It also contains a number of bugfixes for compilation on MacOS, as well as changes to the CI to more proactively test that.

Finally, it smoothes over a few minor API wrinkles not directly related to polling networking.

This allows a thread to more easily wait for packets on multiple sockets
at the same time.
The new approach allows polled sending, as well as separating off send
timestamps. Unfortunately, timestamp reception still requires a future
to be created, as it is currently impossible to poll for error queue
readyness.
@davidv1992 davidv1992 force-pushed the polling-networking branch from 90b8eaa to 7f7ddf0 Compare May 28, 2026 11:44
This allows it to be kept around in datastructures for emulating poll
functionality, without running into self-referential struct problems.
This is needed as tokio's AsyncFd doesn't support poll for the Error
interest, only Read and Write.
This adds proper dealing with the padding fields for libc::cmsghdr.
@davidv1992 davidv1992 force-pushed the polling-networking branch 3 times, most recently from 6954db2 to 83c205b Compare June 30, 2026 08:19
This also updates the testing to do more thorough testing accross
platforms, as that is creating just too many issues.
@davidv1992 davidv1992 force-pushed the polling-networking branch from 83c205b to f126e41 Compare June 30, 2026 08:23

@rnijveld rnijveld left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things, but looks good overall!

Comment thread src/socket/linux.rs Outdated
}
}

pub(super) fn fetch_send_timestamp_try_read(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be pub(super) anymore? Could also just be a standalone function instead of an associated one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, keeping the caller associated even though strictly that isn't necessary, as it makes calling it easier.

Comment thread src/socket/linux.rs Outdated
}

Ok(send_ts)
Ok(counter.zip(send_ts))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it happen that the msg_errqueue contains a message that omits the timestamp control message entirely? I.e. should this function not return Result<Option<(u32, Option<FullTimestampData>)>> (or default back to a FullTimestampData that has two None values in case it is missing)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think this should never happen in a way that should make us potentially ignore future availability of the send timestamps. The example scenario is when the remote responds with an ICMP message to the sent package, which then arrives before the timestamp. The packet was still sent so the timestamp is coming, but there can occur an error message from the error queue beforehand telling us about the ICMP response.

Comment thread src/socket.rs Outdated
}
}

// This potentially drops multiple timestamps. Therefore, it isn't really supposed to be used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this a doc comment and expand a little on what conditions are required when using this function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, also added comments on the relevant call sites.

@davidv1992 davidv1992 force-pushed the polling-networking branch from 7dbc5a5 to 099e4c7 Compare July 3, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants