Date | Commit message (Collapse) |
|
We don't want to clutter up logs with warnings for cross-thread
IO#close
|
|
|
|
Newer Rubies warn about more things...
|
|
|
|
Some Debian build machines use insanely large socket
buffers, so increase our test buffers to large values to
force EAGAIN: https://bugs.debian.org/830353
In my experience, using setsockopt to clamp buffers to small sizes
can lead to unpredictable stalls, too, so it might not be good
to do in a test case, either.
|
|
The regression for existing users was unnacceptable and
completely poor judgement on my part. This change brings
us back to potentially not-future-compatible code which
will impose maintenance burdens on us in the face of
future Ruby changes.
But TODAY, it is the most performant option for folks who
need to use autopush.
Revert "resurrect Kgio.autopush support in pure Ruby"
and "remove autopush support and make it a no-op"
This reverts commits 64dc570f4b99f68b5ed792b36e7e8abc3df74927
and 4347980fa66115425fa8b765353c8b1bfe5dec24.
|
|
This avoids breaking compatibility for existing apps, but
is less performant (although safer and more resilient to future
changes in Ruby) than the previous C version.
|
|
Maintaining global state in a library like kgio is ugly, and it
is not optimal from a performance standpoint compared to using
MSG_MORE.
TCP_CORK and TCP_NOPUSH require extra syscalls so it still offers
sub-optimal performance compared to MSG_MORE.
Instead, server developers should use MSG_MORE if their OS supports
it (and should add MSG_MORE to their OS if lacking it).
|
|
penultimate return value may be a subarray for writev-related
routines, not a string.
Caught by a pre-upload check by Christian Hofstaedtler
on the debian-ruby list for kgio 2.9.1
Tested-by: Christian Hofstaedtler <zeha@debian.org>
Cc: Hleb Valoshka <375gnu@gmail.com>
Cc: <debian-ruby@lists.debian.org>
Cc: Yura Sokolov <funny.falcon@gmail.com>
|
|
Reported-by: Christopher Rigor <crigor@gmail.com>
|
|
This behaves like kgio_trywrite on GNU/Linux, but allows extra flags
to be specified. The main purpose of this is to support use of the
MSG_MORE flag on GNU/Linux.
|
|
We haven't figured out a way to reliably test this w/o races, so lets
just remove it for now and trust it works by reading the C code.
ref: <CAAB-KcnpvcG6=OZNsBmvv440OHfCWs6-eDD7L6oD=ziCRXPHLA@mail.gmail.com>
|
|
When a Tempfile object is garbage collected, or when the Ruby interpreter
exits, its associated temporary file is automatically deleted. This may
lead to race condition when Tempfile is used like in these tests.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Just spam the thread several times to force the wakeup to happen
and not be as dependent on signal handler execution ordering of
different Ruby VMs.
Tested-by: Hleb Valoshka <375gnu@gmail.com>
|
|
[ew: this avoids a TOCTOU issue for multiple test invocations]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
The existing SIGUSR1 handler may not always be "DEFAULT",
so restore the original one.
|
|
Modifying pollset in a different pollset is thread-unsafe,
so just do that inside the signal handler as that should
fire before restarting poll().
|
|
Linux pipe buffers may use larger pages and increase the
capacity of pipes. Thus the 10000 write attempt is not
sufficient; just infinite loop until we hit :wait_writable.
|
|
This fails when the test is run as root (which may be the case
of some Ruby installations) or fakeroot (which is the case of
Debian build systems).
|
|
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Note: this is an incomplete fix and the race can still happen.
A proper fix would involve using a temporary directory for each
test and placing the Unix socket in there.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
In the unlikely case the Ruby Socket class implements its
own "fastopen" method, we will avoid conflicting.
|
|
Server support just requires exposing one constant for
setsockopt: Kgio::TCP_FASTOPEN
Client support implements a new Kgio::Socket#fastopen method.
This new method wraps the the sendto() syscall. With TCP Fast
Open, the sendto() syscall is overloaded for stream sockets to
implement the functionality of both connect() + write()
Since it only makes sense to use _blocking_ I/O for sendto(),
TFO clients are only supported in Ruby implementations with
native threads.
|
|
This allows us to create an unconnected socket, just like
the normal Socket class it inherits from.
|
|
Ruby may not respond well to signals on all platforms, especially not
after fork()-ing in the face of a running pthread (timer thread on
1.9.2). SIGKILL bypasses Ruby (and all userspace) signal handling on
Debian GNU/kFreeBSD.
|
|
On FreeBSD, writing to a loopback TCP socket does not guarantee
immediate readability on the other end.
Tested on Debian GNU/kFreeBSD 6.0
|
|
This cascades test failures on a platform with questionable
signal/fork handling.
Tested on: Debian GNU/kFreeBSD 6.0
|
|
Add methods for using writev(2) syscall for sending array of string in
a single syscall. This is more efficient than concatenating strings on
Ruby side or sending them one by one.
`#kgio_trywritev` returns array of strings which are not sent to the
socket. If there were objects other than string, they could be converted
using `#to_s` method, but this is not strictly applied, cause
`#kgio_*writev` tries to write at most `sysconf(_SC_IOV_MAX)` items
at once (for Linux its value is 1024). First string of returned array
could be part of string from array, so that you should assume it is not
in consistent state.
`#kgio_writev` semantic differs a bit from `#kgio_write` in term of
buffers mutability: currently `#kgio_write` tries to follow string changes
made concurrently, but `#kgio_writev` works with array's lightweight copy.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Followup-to: e26358413c9d87e1ce8f6cda5cf0b8dd53979ed2
|
|
Under load, TCP sockets may not register as readable right away
after the writer finishes. This can be expected for
implementations where loopback TCP is a closer simulation of
non-local TCP traffic.
These test failures were noticed under FreeBSD 9.0.
|
|
We can't actually test for EPERM without changing
permissions/ownership, and we can't do that without root...
|
|
IO#readpartial may not drain the socket buffers enough for
kgio_write to succeed on some platforms. So use IO#read for
read-in-full behavior.
|
|
It makes test failures hard to track down, tests will
already fail if exceptions are thrown and we'll get
nice backtraces.
|
|
poll(2) may return successfully before it gets interrupted
by the signal.
Found and fix confirmed by 375gnu on the kgio mailing list.
ref: <CAAB-Kcm=_CRa4UoSQt+C4cHk6z2Rpfsv6_KXPHV3R34Gt6sLiQ@mail.gmail.com>
|
|
This appears to be needed for Debian GNU/kFreeBSD under KVM.
|
|
It seems autopush support in our autopush code has
always been broken outside of Linux-based systems,
as we never marked the socket as having pending data.
|
|
No need to completely fail on a test.
|
|
All IO objects created by Kgio will have FD_CLOEXEC descriptor
flag set on it when run under Ruby 2.0.0dev. This matches the
upcoming behavior of Ruby 2.0.0dev for IO objects in the core
and standard library. This change does not affect users on Ruby
1.9.3 and earlier.
accept()-ed sockets in kgio have _always_ had FD_CLOEXEC
set by default.
|
|
There's no point in testing a Ruby implementation detail and
these tests fail under OpenBSD where the accept()-ed socket
inherits the O_NONBLOCK flag from the parent.
|
|
This needs to work similarly to IO.select.
|
|
It's more reliable than relying on IO::NONBLOCK and
Fcntl::FD_CLOEXEC constants. The existing constants are not
guaranteed to be equivalent to what accept4() takes even
though the current Linux implementation does it this way.
|
|
Kgio::File may be used to open FIFOs, so non-blocking
I/O is still useful in that context.
|
|
io/wait doesn't have an IO#wait_writable method, yet[1]
and IO#wait checks FIONREAD which makes it unsuitable
for certain descriptors.
This method uses the new rb_wait_for_single_fd() function in
Ruby 1.9.r. This internally uses ppoll() under Linux, meaning
it performs the same regardless of the FD used.
[1] http://redmine.ruby-lang.org/issues/4647
[2] http://redmine.ruby-lang.org/issues/4849
|
|
Retry on a zero timeout if we get interrupted
even if the timeout expired. This is also what
IO.select does in Ruby itself.
|
|
This will allow users to subclass Kgio::File and
override certain behavior (e.g. overriding "#each").
|
|
This also allows us to return/override #to_path and #path if
necessary, but so far everything works with MRI 1.8, MRI 1.9,
and Rubinius.
|
|
For the case where a file is readable, it's faster to
just call open() instead of stat()-ing and then calling
open().
open() failures are still relatively cheap, too, they're still
more expensive than a failed stat() but cheaper than raising
an exception.
|
|
These aren't well-defined semantics...
|
|
This is needed under Ruby trunk if the string is not actually
resized.
|