[前][次][番号順一覧][スレッド一覧]

ruby-changes:40094

From: nobu <ko1@a...>
Date: Sun, 18 Oct 2015 13:22:49 +0900 (JST)
Subject: [ruby-changes:40094] nobu:r52175 (trunk): ruby.c: disable nonblock only if nonblocking mode

nobu	2015-10-18 13:22:44 +0900 (Sun, 18 Oct 2015)

  New Revision: 52175

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52175

  Log:
    ruby.c: disable nonblock only if nonblocking mode
    
    * ruby.c (open_load_file): disable O_NONBLOCK only when opened in
      non-blocking mode, to get rid of LoadError on Windows.

  Modified files:
    trunk/ruby.c
Index: ruby.c
===================================================================
--- ruby.c	(revision 52174)
+++ ruby.c	(revision 52175)
@@ -1738,13 +1738,15 @@ open_load_file(VALUE fname_v, int *xflag https://github.com/ruby/ruby/blob/trunk/ruby.c#L1738
 	int fd;
 	/* open(2) may block if fname is point to FIFO and it's empty. Let's
 	   use O_NONBLOCK. */
-	int mode = O_RDONLY;
 #if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE)
 	/* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */
-	mode |= O_NONBLOCK;
+# define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK)
 #elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE)
-	mod |= O_NDELAY;
+# define MODE_TO_LOAD (O_RDONLY | O_NDELAY)
+#else
+# define MODE_TO_LOAD (O_RDONLY)
 #endif
+	int mode = MODE_TO_LOAD;
 #if defined DOSISH || defined __CYGWIN__
 	{
 	    const char *ext = strrchr(fname, '.');
@@ -1760,7 +1762,7 @@ open_load_file(VALUE fname_v, int *xflag https://github.com/ruby/ruby/blob/trunk/ruby.c#L1762
 	}
 	rb_update_max_fd(fd);
 
-#ifdef HAVE_FCNTL
+#if defined HAVE_FCNTL && MODE_TO_LOAD != O_RDONLY
 	/* disabling O_NONBLOCK */
 	if (fcntl(fd, F_SETFL, 0) < 0) {
 	    e = errno;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]