Date | Commit message (Collapse) |
|
In the unlikely case the Ruby Socket class implements its
own "fastopen" method, we will avoid conflicting.
|
|
This is prone to race conditions in multiprocess situations
where one process is relying on non-blocking operation while
another (likely newer process) relies on blocking operation.
Since the blocking process can always fall back to calling
rb_io_wait_readable(), use that instead and give up some
scalability for higher reliability.
Those interested in avoiding thundering herds will have to
stop/start their processes using blocking sockets (and tolerate
some downtime).
|
|
Oops :x
|
|
|
|
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.
|
|
This will be reused for TCP fast open support.
|
|
This makes the retry logic for mismatched libc headers/kernel
versions easier to understand and follow.
|
|
errno.h is not guaranteed to be included in existing headers,
so we need to #include it to ensure errno and friends are
usable.
Thanks to stuart on the kgio mailing list for noticing
ref: <062571308.133355.1353536890665.JavaMail.sas1@172.29.251.236>
|
|
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>
|
|
Define rb_thread_blocking_region as a macro for MRI 1.8
to prevent confusing output in tools such as valgrind/gdb.
|
|
Use rb_str_subseq for taking string's tail. rb_str_subseq do not allocate
additional memory in this case. And although it prevents from collecting
original string, it seems that tests wins both in performance and in memory
usage.
Use fallback to rb_str_substr on ruby1.8
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Signed-off-by: Eric Wong <normalperson@yhbt.net>
|
|
Fix build for platforms lacking both TCP_CORK _and_ TCP_NOPUSH
There are many test case fixes and cleanups, too.
|
|
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.
|
|
We don't need to care for TCP_NOPUSH in read_write.c, it's
entirely in autopush.c and no-op on platforms without
TCP_CORK/TCP_NOPUSH. TCP_CORK/TCP_NOPUSH are non-POSIX, so
it's entirely possible some Free systems will lack them.
Reported-by: Edho Arief <edho@myconan.net>
|
|
Fixed build and autopush support under Debian GNU/kFreeBSD.
Test case fixes for timing-sensitive tests.
|
|
Unlike most Rubyists, I prefer GNU make to Rake.
|
|
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.
|
|
The check for the accept4() function actually succeeds on a
stock installation of Debian GNU/kFreeBSD 6.0, but the
eglibc headers fail to define the necessary flags.
|
|
Fix a missing #include for Ruby 1.8.5 users. No need to
upgrade to this (nor 2.7.1) if you're on a modern version
of Ruby.
|
|
Apparently the old Ruby 1.8.6 installation lying around isn't
old enough.
|
|
This release fixes some compatibility issues with people
stuck on older versions of Ruby/RubyGems.
* define RARRAY_PTR/RARRAY_LEN macros for Ruby 1.8.6
* test/test_autopush: skip strace tests if not available
* gemspec: disable development dependencies for old systems
|
|
"Enterprise" users are sometimes stuck on older Rubies/RubyGems
and this is still required for them.
|
|
No need to completely fail on a test.
|
|
Apparently Ruby 1.8.6 is still in use...
|
|
When running under Ruby trunk/2.0.0dev, all IO objects created
by kgio will be close-on-exec by default to match the (future)
2.0.0 behavior. accept()ed sockets in kgio have always been
close-on-exec by default..
Singleton Kgio.accept_* methods are deprecated as the
kgio_accept/kgio_tryaccept methods all take an additional
flags argument.
There are various, test, documentation, and error message
improvements.
|
|
There's no reason for SOCK_NONBLOCK with Ruby, and SOCK_CLOEXEC
has always been on-by-default with accept() wrappers.
|
|
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.
|
|
The kgio_accept and kgio_tryaccept methods now take an
additional flags argument, so there's no reason to set
global flags anywhere.
|
|
This is mostly an implementation detail, but it's already
true on OpenBSD (and maybe other BSDs), and also requires
no additional syscalls on newer Linux systems.
|
|
This needs to work similarly to IO.select.
|
|
We want feedback!
|
|
eye kan spel!
|
|
This is not glibc and I'm not Ulrich Drepper.
|
|
Monkeys!
|
|
This helps exec() and similar methods close descriptors on
shutdown.
|
|
We want more descriptive error messages and don't want
crazy stuff like floats.
|
|
We now export SOCK_NONBLOCK, SOCK_CLOEXEC constants in the Kgio
namespace to make kgio_tryaccept/kgio_accept easier-to-use.
There are also some minor internal cleanups.
|
|
It's no in the public headers, but Ruby 1.9.3 will have it and
it's still superior to rb_thread_blocking_region() even though
it's not ideal.
|