summaryrefslogtreecommitdiff
path: root/ext/socket/init.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 02:39:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 02:39:44 +0000
commitd933fb2296e4ace25c5eb558be56cd23a8fcc88f (patch)
tree597f59b7faf29ed9e5b83692495338a3cb7576fe /ext/socket/init.c
parente4283fd39d9e8c508ce5ee2dc069b6f5545cd3d8 (diff)
* ext/socket: Improve socket exception message to show socket address.
[ruby-core:45617] [Feature #6583] proposed Eric Hodel. * ext/socket/rubysocket.h (rsock_sys_fail_host_port): Declared. (rsock_sys_fail_path): Ditto. (rsock_sys_fail_sockaddr): Ditto. * ext/socket/udpsocket.c (udp_connect): Use rsock_sys_fail_host_port. (udp_bind): Ditto. (udp_send): Ditto. * ext/socket/init.c (rsock_init_sock): Specify a string for rb_sys_fail argument. (make_fd_nonblock): Ditto. (rsock_s_accept): Ditto. * ext/socket/ipsocket.c (init_inetsock_internal): Use rsock_sys_fail_host_port. * ext/socket/socket.c (rsock_sys_fail_host_port): Defined. (rsock_sys_fail_path): Ditto. (rsock_sys_fail_sockaddr): Ditto. (setup_domain_and_type): Use rsock_sys_fail_sockaddr. (sock_connect_nonblock): Ditto. (sock_bind): Ditto. (sock_gethostname): Specify a string for rb_sys_fail argument. (socket_s_ip_address_list): Ditto. * ext/socket/basicsocket.c (bsock_shutdown): Specify a string for rb_sys_fail argument. (bsock_setsockopt): Use rsock_sys_fail_path. (bsock_getsockopt): Ditto. (bsock_getpeereid): Refine the argument for rb_sys_fail. * ext/socket/unixsocket.c (rsock_init_unixsock): Use rsock_sys_fail_path. (unix_path): Ditto. (unix_send_io): Ditto. (unix_recv_io): Ditto. (unix_addr): Ditto. (unix_peeraddr): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/init.c')
-rw-r--r--ext/socket/init.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 33ddc05..3fda607 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -47,7 +47,7 @@ rsock_init_sock(VALUE sock, int fd)
struct stat sbuf;
if (fstat(fd, &sbuf) < 0)
- rb_sys_fail(0);
+ rb_sys_fail("fstat(2)");
rb_update_max_fd(fd);
if (!S_ISSOCK(sbuf.st_mode))
rb_raise(rb_eArgError, "not a socket file descriptor");
@@ -475,14 +475,14 @@ make_fd_nonblock(int fd)
#ifdef F_GETFL
flags = fcntl(fd, F_GETFL);
if (flags == -1) {
- rb_sys_fail(0);
+ rb_sys_fail("fnctl(2)");
}
#else
flags = 0;
#endif
flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1) {
- rb_sys_fail(0);
+ rb_sys_fail("fnctl(2)");
}
}
@@ -590,7 +590,7 @@ rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
retry = 0;
goto retry;
}
- rb_sys_fail(0);
+ rb_sys_fail("accept(2)");
}
rb_update_max_fd(fd2);
if (!klass) return INT2NUM(fd2);