select.c: Clarify osmo_fd_(un)register() API expectations of registered fd

Those restrictions were implicitly required for a while and most of the
users of this API already followed them, but just a few didn't. All
known users have now been fixed. Let's explicitly document the
restrictions imposed by the API to ease avoiding similar issues in the
future.

Change-Id: I53d95aad15b33dd66aa5c7dd11745a35c4481f33
This commit is contained in:
Pau Espin 2023-03-14 12:01:37 +01:00
parent c46a15d876
commit 153519f5fb
1 changed files with 6 additions and 0 deletions

View File

@ -151,6 +151,9 @@ bool osmo_fd_is_registered(struct osmo_fd *fd)
/*! Register a new file descriptor with select loop abstraction
* \param[in] fd osmocom file descriptor to be registered
* \returns 0 on success; negative in case of error
*
* The API expects fd field of the struct osmo_fd to remain unchanged while
* registered, ie until osmo_fd_unregister() is called on it.
*/
int osmo_fd_register(struct osmo_fd *fd)
{
@ -208,6 +211,9 @@ int osmo_fd_register(struct osmo_fd *fd)
/*! Unregister a file descriptor from select loop abstraction
* \param[in] fd osmocom file descriptor to be unregistered
*
* This function must be called before changing the value of the fd field in
* the struct osmo_fd.
*/
void osmo_fd_unregister(struct osmo_fd *fd)
{