JNI/JSSE: Add support for poll(), fix for EAGAIN and select() #201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addition of
poll()
Support:This PR adds support for using
poll()
by default instead ofselect()
on native file descriptors. The previousselect()
behavior was left in tact and used as a default for Windows builds still.select()
can also be used by building the native JNI library withWOLFJNI_USE_IO_SELECT
defined. Seejava.sh
cflags
section for where that could be added.We do not monitor lots of file descriptors at once ourselves inside wolfSSL JNI/JSSE, but one disadvantage to using
select()
is that for file descriptor numbers larger thanFD_SETSIZE
, theFD_ISSET
and related macros result in undefined behavior.FD_SETSIZE
defaults to1024
on most systems, so is not very scalable for consumers using wolfSSL JNI/JSSE in processes that are opening and using lots of file descriptors.Changes to
select()
Support:Native JNI
socketSelect()
loops around callingselect()
if it returns-1
anderrno == EINTR
. According to theselect(2)
man page, some variants of Unix may returnEAGAIN
fromselect()
. This PR adjusts oursocketSelect()
to also loop onEAGAIN
.Man page for
select()
from OSX also shows a potential return ofEAGAIN
from select():Related to ZD 17962 (and 17385) - customer confirmed fix seems to be working well so far.