diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/socket/init.c | 5 |
2 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,9 @@ +Thu Oct 15 09:25:07 2009 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/socket/init.c (rsock_init_sock): mswin doesn't have S_IFSOCK + flag in st_mode of struct stat. so, use rb_w32_issocket() function + instead of S_ISSOCK macro. + Thu Oct 15 00:47:42 2009 NARUSE, Yui <naruse@ruby-lang.org> * tool/enc-unicode.rb, diff --git a/ext/socket/init.c b/ext/socket/init.c index 85cc3de4f9..b143dccd5f 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -45,10 +45,15 @@ rsock_init_sock(VALUE sock, int fd) rb_io_t *fp; struct stat sbuf; +#ifndef _WIN32 if (fstat(fd, &sbuf) < 0) rb_sys_fail(0); if (!S_ISSOCK(sbuf.st_mode)) rb_raise(rb_eArgError, "not a socket file descriptor"); +#else + if (!rb_w32_is_socket(fd)) + rb_raise(rb_eArgError, "not a socket file descriptor"); +#endif MakeOpenFile(sock, fp); fp->fd = fd; |