summaryrefslogtreecommitdiff
path: root/ext/socket
AgeCommit message (Collapse)Author
2017-05-08separate constdefs.c and constdefs.hnobu
* ext/socket/depend: separate constdefs.c and constdefs.h so that only one process will run when parallel building. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-19socket: avoid fcntl for read/write_nonblock on Linuxnormal
On platforms where MSG_DONTWAIT works reliably on all sockets (so far, I know of Linux), we can avoid fcntl syscalls and implement IO#write_nonblock and IO#read_nonblock in terms of the socket-specific send and recv family of syscalls. This avoids side effects on the socket, and also encourages generic code to be written in cases where IO wrappers like OpenSSL::SSL::SSLSocket are used. Perhaps in the future, side-effect-free non-blocking I/O can be standard on all files and OSes: https://cr.yp.to/unix/nonblock.html * ext/socket/lib/socket.rb (read_nonblock, write_nonblock): Linux-specific wrapper without side effects [ruby-core:80780] [Feature #13362] * test/socket/test_basicsocket.rb (test_read_write_nonblock): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14IPSocket#inspectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-11Socket.udp_server_sockets: use symbol procnormal
Symbol proc is shorter human and machine code; and also avoids needing to name variables. * ext/socket/lib/socket.rb (Socket.udp_server_sockets): use symbol proc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09Get rid of inifinity retry loop in Socket.udp_server_socketsusa
* ext/socket/lib/socket.rb (Socket.udp_server_sockets): remove duplicated addresses before passing it to ip_sockets_port0 because it causes Errno::EADDRINUSE and retry forever. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-08basicsocket.c: proper system call namenobu
* ext/socket/basicsocket.c (rsock_bsock_send): show proper system call name in the exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22ruby tool/update-deps --fixshyouhei
Onigumo 6 (r57045) introduced new onigumo.h header file, which is required from quite much everywhere. This commit adds necessary dependencies. Note: ruby/oniguruma.h now includes onigumo.h, ruby/io.h includes oniguruma.h, ruby/encoding.h also includes oniguruma.h, and internal.h includes encoding.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09ext/socket/raddrinfo.c (addrinfo_mark): avoid needless branchnormal
gc.c (gc_mark_children, case T_DATA) does not use the dmark function pointer if DATA_PTR is NULL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27ext/socket/extconf.rb: fix a typonobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23Revert r57690 except for read_nonblocknobu
https://github.com/ruby/ruby/pull/1527#issuecomment-281867551 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] mark up literalsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] keyword argument _exception_nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23socket.rb: [DOC] fix nonblock methodsnobu
* ext/socket/lib/socket.rb (BasicSocket#recv_nonblock): fix exception class and symbol. * ext/socket/lib/socket.rb (BasicSocket#recvmsg_nonblock): ditto. * ext/socket/lib/socket.rb (Socket#recvfrom_nonblock): fix the method name. * ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): both. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23[DOC] {read,write}_nonblock with exception: falsenobu
Update docs to reflect EOF behavior change of read_nonblock and write_nonblock when using `exception: false`. [Fix GH-1527] Author: Russell Davis <russell-stripe@users.noreply.github.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-16basicsocket (rsock_bsock_send): do not truncate return valuenormal
send(2) and sendto(2) syscalls return `ssize_t', use the proper type and macro for converting to a Numeric VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-21socket: use symbol proc for IO#close loopsnormal
Made possible by r56795, this reduces human and byte code size. * ext/socket/lib/socket.rb (self.ip_sockets_port0, self.tcp_server_sockets_port0, self.tcp_server_sockets, self.udp_server_sockets): use symbol proc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-15socket.rb: remove closed checksnobu
* ext/socket/lib/socket.rb: remove unnecessary closed checks, close on closed socket no longer raises an exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-14socket.rb: kwargsnobu
* ext/socket/lib/socket.rb (connect_{from,to}, connect): let use keyword arguments. * ext/socket/lib/socket.rb (Socket.tcp): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-27socket: fix rdoc of UDPSocket#recvfrom_nonblockrhe
* ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): [DOC] Remove a false statement "If _maxlen_ is omitted, its default value is 65536." maxlen, the first parameter, cannot be omitted as the method signature indicates. This hasn't changed ever since it was first implemented. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05* ext/socket/*.c: Add proper require for example to work.hsbt
[fix GH-1378][ci skip] Patch by @schneems git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-24fid typos [ci skip]nobu
* fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-13Use PRIuSIZE format specifier for size_t valuesrhe
Use PRIuSIZE instead of PRIdSIZE. This fixes the exception message shown on too large xmalloc2. This commit also fixes other incorrect use of PRIdSIZE in other functions; though most of them are debug print. * gc.c (heap_extend_pages, get_envparam_size, ruby_malloc_size_overflow, gc_profile_dump_on): Use PRIuSIZE instead of PRIdSIZE as the passed value is size_t, not ssize_t. * iseq.c (get_line_info, rb_iseq_disasm_insn): Ditto. * sprintf.c (rb_str_format): Ditto. * thread_win32.c (native_thread_create): Ditto. * vm.c (get_param): Ditto. * ext/objspace/objspace_dump.c (dump_append_string_content, dump_object): Ditto. * ext/socket/raddrinfo.c (host_str, port_str): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-06socket/depend: add srcs [ci skip]nobu
* ext/socket/depend (srcs): phony target to update confdefs source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-13getnameinfo.c: rubysocket.h for inet_ntopnobu
* ext/socket/getnameinfo.c: needs rubysocket.h for fallback definition of inet_ntop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-02socket/option.c: inet_ntopnobu
* ext/socket/option.c, ext/socket/rubysocket.h (inet_ntop): share the fallback definition. [ruby-core:76646] [Bug #12645] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29rb_funcallvnobu
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30* ext/socket/raddrinfo.c (host_str, port_str): Use StringValueCStrusa
instead of (Safe)StringValue, to detect NUL byte in the string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30raddrinfo.c: fix modifiernobu
* ext/socket/raddrinfo.c (host_str, port_str): fix length modifier to size_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30raddrinfo.c: fix for SHARABLE_MIDDLE_SUBSTRINGnobu
* ext/socket/raddrinfo.c (host_str, port_str): use RSTRING_LEN instead of strlen, since RSTRING_PTR StringValueCStr may not be NUL-terminated when SHARABLE_MIDDLE_SUBSTRING=1. reported by @tmtms, http://twitter.com/tmtms/status/736910516229005312 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11Update dependencies.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17socket/option.c: accurate conditionnobu
* ext/socket/option.c (inspect_tcpi_msec): more accurate condition for TCPI msec member inspection function. [ruby-core:74388] [Bug #12185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-28socket.c: unlimited size hostnamenobu
* ext/socket/socket.c (sock_gethostname): support unlimited size hostname. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-17option.c: single byte booleannobu
* ext/socket/option.c (sockopt_bool): relax boolean size to be one too not only sizeof(int). Winsock getsockopt() returns a single byte as a boolean socket option. [ruby-core:72730] [Bug #11958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-17option.c: make error messages consistentnobu
* ext/socket/option.c (check_size): extract a macro to check binary data size, with a consistent message. * ext/socket/option.c (sockopt_byte): fix error message, sizeof(int) differs from sizeof(unsigned char) in general. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23rb_readwrite_syserr_failnobu
* io.c (rb_readwrite_syserr_fail): works with the given errno than thread local errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23prefer rb_syserr_failnobu
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22ext/socket/init.c (rsock_init_sock): reject reserved FDsnormal
[ruby-core:72445] [Bug #11862] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22fix r53231: raise Errno::EBADF like other OSesnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21avoid rb_bug on BasicSocket.for_fd(-1)normal
* ext/socket/init.c (rsock_init_sock): check FD after validating * test/socket/test_basicsocket.rb (test_for_fd): new [ruby-core:72418] [Bug #11854] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16handle ext/ as r53141naruse
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* ext/socket/lib/socket.rb: use safe navigation operator.hsbt
[fix GH-1142] Patch by @mlarraz * lib/drb/extservm.rb: ditto. * lib/net/http.rb: ditto. * lib/net/http/response.rb: ditto. * lib/scanf.rb: ditto. * lib/uri/generic.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09ext/socket/ifaddr.c: remove empty ifaddr_marknormal
We do not need to maintain empty functions for GC, gc_mark_children will not attempt to dereference NULL dmark callbacks. * ext/socket/ifaddr.c (ifaddr_mark): remove empty function (ifaddr_type): pass zero to rb_data_type_t.function.dmark git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09* ext/**/*.c (*_memsize): same as r52986 for extensions.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07socket: expand docs+tests for recv_io/send_ionormal
* ext/socket/unixsocket.c (unix_send_io): document args (unix_recv_io): ditto * test/socket/test_unix.rb (test_fd_passing_class_mode): added I was working on these when I encountered the problem in with BasicSocket.for_fd not handling mode args: https://bugs.ruby-lang.org/issues/11778 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-24Drop support for BeOSnobu
* beos: Drop support for BeOS now that Haiku is stable. [Fix GH-1112] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23ext/socket/init.c (rsock_accept): handle ENOMEMnormal
accept(2) documents ENOMEM as a possible error, handle it consistent with all of our other FD-allocating wrappers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23use rb_gc_for_fd for more callersnormal
* dir.c (dir_initialize): use rb_gc_for_fd for ENOMEM * ext/socket/init.c (rsock_socket): ditto * ext/socket/socket.c (rsock_socketpair): ditto * internal.h (rb_gc_for_fd): prototype * io.c (rb_gc_for_fd): remove static [ruby-core:71623] [Feature #11727] Manpages for opendir(2), socket(2), and socketpair(3posix) describe ENOMEM as a possible error for each of these; handle it consistently with our existing wrappers for open(2)/pipe(2) etc... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23Haiku now best effort supportnobu
* configure.in: remove obsolete workarounds for Haiku. * dln.c, file.c, io.c: remove obsolete Haiku workarounds. * thread_pthread.c: add stack bounds detection for Haiku. * signal.c: get stack pointer from signal context on Haiku. [ruby-core:67923] [Bug #10811] [Fix GH-1109] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-20* ext/socket/socket.c: remove mention of :UNIX in getaddrinfo().hsbt
It's typically not a support option. [ci skip][fix GH-990] Patch by @eam git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e