public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Use Entersyscall when reading directories
@ 2012-06-13  5:00 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-06-13  5:00 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

This patch to libgo uses Entersyscall and Exitsyscall when reading
directory entries.  This matters when reading a directory from something
that can stall, such as NFS or a user-mounted file system.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 859 bytes --]

diff -r 4700079bacc2 libgo/go/os/dir.go
--- a/libgo/go/os/dir.go	Tue Jun 12 13:32:45 2012 -0700
+++ b/libgo/go/os/dir.go	Tue Jun 12 21:45:10 2012 -0700
@@ -42,7 +42,11 @@
 	if file.dirinfo == nil {
 		file.dirinfo = new(dirInfo)
 		file.dirinfo.buf = make([]byte, elen)
-		file.dirinfo.dir = libc_opendir(syscall.StringBytePtr(file.name))
+		p := syscall.StringBytePtr(file.name)
+		syscall.Entersyscall()
+		r := libc_opendir(p)
+		syscall.Exitsyscall()
+		file.dirinfo.dir = r
 	}
 
 	entry_dirent := unsafe.Pointer(&file.dirinfo.buf[0]).(*syscall.Dirent)
@@ -62,7 +66,10 @@
 
 	for n != 0 {
 		var result *syscall.Dirent
-		i := libc_readdir_r(dir, entry_dirent, &result)
+		pr := &result
+		syscall.Entersyscall()
+		i := libc_readdir_r(dir, entry_dirent, pr)
+		syscall.Exitsyscall()
 		if i != 0 {
 			return names, NewSyscallError("readdir_r", i)
 		}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-13  4:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13  5:00 libgo patch committed: Use Entersyscall when reading directories Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).