about summary refs log tree commit homepage
path: root/ext/raindrops/tcp_info.c
DateCommit message (Collapse)
2023-06-26avoid unnecessary #to_io calls
Calling `#to_io' is only necessary when we're handling an argument from user code where the user could pass a non-IO object. `#to_io' calls are a waste of time when we create the IO object ourselves (in `Raindrops::InetDiagSock.new'). This allows us to define the `my_fileno' macro for Ruby 3.1+ users to call the new `rb_io_descriptor' function directly without an extra C stack frame. This also allows us to get rid of nesting CPP directives inside C functions which (IMHO) improves readability. Furthermore, any necessary #to_io calls using `rb_convert_type' can be replaced with `rb_io_get_io' to decrease code size. `rb_io_get_io' has been in ruby/io.h since Ruby 1.9.2 and there's no expectation that it'd be deprecated since it only deals with opaque `VALUE' types.
2017-04-26tcp_info: remove unnecessary extconf.h include
ruby.h already pulls in extconf.h and has done so since Ruby 1.8.
2017-03-23doc: document Raindrops::TCP hash
This is part of the stable API, so we shall document it for others to use.
2017-03-17define Raindrops::TCP hash for TCP states freebsd
FreeBSD not only uses different values than Linux for TCP states, but different names, too. To ease writing portable code between the OSes, do more CPP metaprogramming via extconf.rb and define a common hash supported on both OSes. Putting all this in a hash allows for easy dumping and mapping in an OS-neutral way, since the actual TCP states are OS-independent.
2017-03-17tcp_info: support this struct under FreeBSD
Of course these fields are not portable between Linux and FreeBSD, but they should remain ABI-compatible for future versions of each OS. Tested on FreeBSD 10.3-RELEASE i386 TCP state names will be another problem...