about summary refs log tree commit homepage
DateCommit message (Collapse)
2013-11-21split read_write.c into {read,write,writev}.c rbx-wip
This helps make our code more manageable, as well as isolating RSTRING_MODIFIED usage to files which actually need it. writev.c can eventually be fixed to avoid modifying RSTRING pointers, but write.c can already benefit from const RSTRING_PTR values right away.
2013-11-21set RSTRING_MODIFIED where appropriate for Rubinius
Not yet tested, but it makes sense to do this.
2013-11-21connect: constify RSTRING-related things
This should enforce correctness with our non-use of RSTRING_MODIFIED in this file, hopefully allowing Rubinius to optimize better.
2013-09-30Rakefile: kill raa_update task
RAA is dead
2013-09-25my_writev: stylistic fixes
Rename 'str' to 'ary', as that's the whole point of supporting writev... Also, long lines need to be wrapped at 80 columns
2013-09-25read_write: remove the rest of RARRAY_PTR usage
I have not benchmarked this, but this should not make a difference as far as performance goes. This should also allow better performance of better GCs in Ruby 2.1.0 and Rubinius.
2013-09-25tryopen: remove RARRAY_PTR usage in init
This is trivially non-performance-critical, and can only help with advanced GCs in Ruby 2.1.0 and Rubinius
2013-09-25test_poll: remove race prone test_poll_EINTR_changed test
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>
2013-09-11kgio 2.8.1 - minor improvements and test fixes v2.8.1
Improved error reporting for kgio_accept/kgio_tryaccept. Minor size reduction throughout. There are also several test case fixes for race conditions. Thanks to Hleb Valoshka and the Debian project for all the help with this release! Eric Wong (7): check syscall returns against < 0 instead of == -1 accept: more informative exception on unknown family test_tryopen: skip EACCES test when euid == 0 test/lib_read_write: account for larger-than-normal pipes test_poll: avoid potentially thread-unsafe test test_poll: preserve original trap(:USR1) handler test_poll: be less dependent on signal handler ordering Hleb Valoshka (4): Change prefix of temporary sockets to prevent races Don't dump 20M in case of failure Create own directory for every unix socket in unit tests Close tempfile and unlink it immediately.
2013-09-07Close tempfile and unlink it immediately.
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>
2013-09-05test_poll: be less dependent on signal handler ordering
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>
2013-09-04Create own directory for every unix socket in unit tests
[ew: this avoids a TOCTOU issue for multiple test invocations] Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-09-03test_poll: preserve original trap(:USR1) handler
The existing SIGUSR1 handler may not always be "DEFAULT", so restore the original one.
2013-09-03test_poll: avoid potentially thread-unsafe test
Modifying pollset in a different pollset is thread-unsafe, so just do that inside the signal handler as that should fire before restarting poll().
2013-09-03test/lib_read_write: account for larger-than-normal pipes
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.
2013-09-03test_tryopen: skip EACCES test when euid == 0
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).
2013-09-02Don't dump 20M in case of failure
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-09-02Change prefix of temporary sockets to prevent races
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>
2013-08-16accept: more informative exception on unknown family
This may help us diagnose issues on strange OSes.
2013-08-16check syscall returns against < 0 instead of == -1
This may help us avoid errors in case of C library bugs, and also results in smaller code: $ ~/linux/scripts/bloat-o-meter before.so after.so add/remove: 0/0 grow/shrink: 0/9 up/down: 0/-66 (-66) function old new delta s_trywrite 160 159 -1 kgio_write 160 159 -1 kgio_trywrite 160 159 -1 my_recv 616 610 -6 my_peek 616 610 -6 stream_connect 456 448 -8 my_socket 222 213 -9 my_writev 1703 1687 -16 write_check 427 409 -18
2013-01-18kgio 2.8.0 - TCP Fast Open, writev/trywritev v2.8.0
TCP Fast Open in Linux 3.7 and later is now supported in the client via Kgio::Socket#kgio_fastopen. This release also adds the kgio_writev and kgio_trywritev methods, thanks to funny-falcon
2013-01-18rename fastopen => kgio_fastopen in Kgio::Socket
In the unlikely case the Ruby Socket class implements its own "fastopen" method, we will avoid conflicting.
2012-12-30accept: do not set blocking if non-blocking is set
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).
2012-12-27fastopen: fix argument order in RDoc example
Oops :x
2012-12-27read_write: remove unused variable
2012-12-27implement TCP Fast Open support (client + server)
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.
2012-12-13Kgio::Socket.new retains compatibility with Socket.new
This allows us to create an unconnected socket, just like the normal Socket class it inherits from.
2012-12-12connect: factor out tcp_getaddr() function
This will be reused for TCP fast open support.
2012-12-12connect: split out my_socket() function
This makes the retry logic for mismatched libc headers/kernel versions easier to understand and follow.
2012-11-21tryopen: include errno.h header just in case
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>
2012-07-11test workaround for platforms with unreliable signals
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.
2012-07-11test/lib_read_write: wait for readability before tryread
On FreeBSD, writing to a loopback TCP socket does not guarantee immediate readability on the other end. Tested on Debian GNU/kFreeBSD 6.0
2012-07-11test_poll: skip signal torture on Debian GNU/kfreebsd
This cascades test failures on a platform with questionable signal/fork handling. Tested on: Debian GNU/kFreeBSD 6.0
2012-06-01add `#kgio_writev` and `#kgio_trywritev`
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>
2012-05-30tryopen: avoid ambiguous name for subst function
Define rb_thread_blocking_region as a macro for MRI 1.8 to prevent confusing output in tools such as valgrind/gdb.
2012-05-30use rb_str_subseq for tail string on write
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>
2012-05-30Fix UnixClientReadServerWrite test class name
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-03-24kgio 2.7.4 - small fixes and cleanups v2.7.4
Fix build for platforms lacking both TCP_CORK _and_ TCP_NOPUSH There are many test case fixes and cleanups, too.
2012-03-24test: more workaround for FreeBSD 9.0
Followup-to: e26358413c9d87e1ce8f6cda5cf0b8dd53979ed2
2012-03-23test/lib_read_write: test workarounds for TCP in FreeBSD 9.0
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.
2012-03-23test_tryopen: fix horribly-named test for EACCES
We can't actually test for EPERM without changing permissions/ownership, and we can't do that without root...
2012-03-22test/lib_read_write: increase test reliability
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.
2012-03-19test/*: remove assert_nothing_raised
It makes test failures hard to track down, tests will already fail if exceptions are thrown and we'll get nice backtraces.
2012-03-19fix for non-Linux, non-TCP_NOPUSH platforms
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>
2012-03-15kgio 2.7.3 - compatibility fixes v2.7.3
Fixed build and autopush support under Debian GNU/kFreeBSD. Test case fixes for timing-sensitive tests.
2012-03-07HACKING: add instructions for running tests
Unlike most Rubyists, I prefer GNU make to Rake.
2012-03-07test_poll: workaround for timing-sensitive test on slow hosts
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>
2012-03-05test: increase delta range for timing-sensitive test
This appears to be needed for Debian GNU/kFreeBSD under KVM.
2012-03-05autopush: fix/enable under Debian GNU/kFreeBSD
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.
2012-03-05accept4: require SOCK_NONBLOCK/SOCK_CLOEXEC macros
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.