From 895fd7ec5e03c51c5ebc1424312967852703de38 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 23 Aug 2008 00:47:54 +0000 Subject: * include/ruby/io.h (rb_io_t): remove path field and add pathv field. (MakeOpenFile): initialize pathv as Qnil. * gc.c: mark pathv field in T_FILE. * io.c: follow the rb_io_t field change. * file.c: ditto. * ext/socket/socket.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/socket.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 19f9d2a38d..b3d21f2230 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -403,9 +403,11 @@ bsock_setsockopt(VALUE sock, VALUE lev, VALUE optname, VALUE val) break; } +#define rb_sys_fail_path(path) rb_sys_fail(NIL_P(path) ? 0 : RSTRING_PTR(path)) + GetOpenFile(sock, fptr); if (setsockopt(fptr->fd, level, option, v, vlen) < 0) - rb_sys_fail(fptr->path); + rb_sys_fail_path(fptr->pathv); return INT2FIX(0); } @@ -466,7 +468,7 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname) GetOpenFile(sock, fptr); if (getsockopt(fptr->fd, level, option, buf, &len) < 0) - rb_sys_fail(fptr->path); + rb_sys_fail_path(fptr->pathv); return rb_str_new(buf, len); #else @@ -1700,7 +1702,7 @@ init_unixsock(VALUE sock, VALUE path, int server) init_sock(sock, fd); if (server) { GetOpenFile(sock, fptr); - fptr->path = strdup(RSTRING_PTR(path)); + fptr->pathv = rb_str_new_frozen(path); } return sock; @@ -1938,14 +1940,14 @@ unix_path(VALUE sock) rb_io_t *fptr; GetOpenFile(sock, fptr); - if (fptr->path == 0) { + if (NIL_P(fptr->pathv)) { struct sockaddr_un addr; socklen_t len = sizeof(addr); if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rb_sys_fail(0); - fptr->path = strdup(unixpath(&addr, len)); + fptr->pathv = rb_obj_freeze(rb_str_new_cstr(unixpath(&addr, len))); } - return rb_str_new2(fptr->path); + return rb_str_dup(fptr->pathv); } static VALUE -- cgit v1.2.3