Skip to content

[WIP] bpo-28708: Add setsize keywoard-only parameter to select.select() #13845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[WIP] bpo-28708: Add setsize keywoard-only parameter to select.select() #13845

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 5, 2019

It becomes possible to configure the set size used internally by
select.select() at runtime.

https://bugs.python.org/issue28708

It becomes possible to configure the set size used internally by
select.select() at runtime.
@vstinner
Copy link
Member Author

vstinner commented Jun 5, 2019

I have no idea if this PR works :-) Is it really possible to change FD_SETSIZE at runtime?

pylist rfd2obj[FD_SETSIZE + 1];
pylist wfd2obj[FD_SETSIZE + 1];
pylist efd2obj[FD_SETSIZE + 1];
#endif /* SELECT_USES_HEAP */
PyObject *ret = NULL;
fd_set ifdset, ofdset, efdset;
Copy link

Choose a reason for hiding this comment

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

I think these three sets will need to be allocated differently. We'll probably need a different fd_set structure something like:

typedef struct fd_set_2
{
    u_int fd_count
    SOCKET *fd_array;
} fd_set_2;

and then dynamically allocate the fd_array to be a SOCKET* array of size set_size.
Knowing that the select implementation only looks at the fd_count for the size of the array (and doesn't do any boundary checking), we can cast those sets to fd_set and then pass them to the select call.

Copy link

Choose a reason for hiding this comment

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

Actually that struct type isn't going to work, because that adds a level of indirection that the select implementation doesn't expect.
We'll need to allocate a continuous area of memory of size (sizeof(u_int) + setsize*sizeof(SOCKET))

@vstinner
Copy link
Member Author

It seems like @andzn went further than me in PR #13842, I close my WIP PR.

@vstinner vstinner closed this Jun 14, 2019
@vstinner vstinner deleted the select_setsize branch June 14, 2019 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants