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

ruby-changes:65423

From: Nobuyoshi <ko1@a...>
Date: Mon, 8 Mar 2021 21:45:23 +0900 (JST)
Subject: [ruby-changes:65423] e85bffc324 (master): Increment global variables atomically

https://git.ruby-lang.org/ruby.git/commit/?id=e85bffc324

From e85bffc32473968b2e3736ad712f5e0d6e9aebc9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 23 Feb 2021 22:48:11 +0900
Subject: Increment global variables atomically

---
 win32/win32.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/win32/win32.c b/win32/win32.c
index e2d4cce..940a85a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2346,7 +2346,7 @@ ruby_direct_conv(const WCHAR *file, const WCHAR *alt, struct direct *entry, cons https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L2346
 static struct direct *
 readdir_internal(DIR *dirp, BOOL (*conv)(const WCHAR *, const WCHAR *, struct direct *, const void *), const void *enc)
 {
-    static int dummy = 0;
+    static long dummy_ino = 0;
 
     if (dirp->curr) {
 
@@ -2364,7 +2364,7 @@ readdir_internal(DIR *dirp, BOOL (*conv)(const WCHAR *, const WCHAR *, struct di https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L2364
 	//
 	// Fake inode
 	//
-	dirp->dirstr.d_ino = dummy++;
+	dirp->dirstr.d_ino = (ino_t)(InterlockedIncrement(&dummy_ino) - 1);
 
 	//
 	// Attributes
@@ -6497,7 +6497,7 @@ rb_w32_fclose(FILE *fp) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6497
 int
 rb_w32_pipe(int fds[2])
 {
-    static DWORD serial = 0;
+    static long serial = 0;
     static const char prefix[] = "\\\\.\\pipe\\ruby";
     enum {
 	width_of_prefix = (int)sizeof(prefix) - 1,
@@ -6513,7 +6513,7 @@ rb_w32_pipe(int fds[2]) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6513
 
     memcpy(name, prefix, width_of_prefix);
     snprintf(name + width_of_prefix, width_of_ids, "%.*"PRI_PIDT_PREFIX"x-%.*lx",
-	     width_of_pid, rb_w32_getpid(), width_of_serial, serial++);
+	     width_of_pid, rb_w32_getpid(), width_of_serial, InterlockedIncrement(&serial)-1);
 
     sec.nLength = sizeof(sec);
     sec.lpSecurityDescriptor = NULL;
-- 
cgit v1.1


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

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