19146643 pciaccess leaks fds until Xorg says: can not open /dev/xsvc: Too many open files s12_53
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Thu, 03 Jul 2014 13:48:11 -0700
changeset 1460 673a2aa99760
parent 1459 6010b59bc28e
child 1461 3825f29eef88
19146643 pciaccess leaks fds until Xorg says: can not open /dev/xsvc: Too many open files
open-src/lib/libpciaccess/Makefile
open-src/lib/libpciaccess/fd-leak.patch
--- a/open-src/lib/libpciaccess/Makefile	Wed Jul 02 11:13:31 2014 -0700
+++ b/open-src/lib/libpciaccess/Makefile	Thu Jul 03 13:48:11 2014 -0700
@@ -2,7 +2,7 @@
 #
 # libpciaccess - generic PCI access software library & scanpci utility
 #
-# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -37,6 +37,7 @@
 
 # Patches to apply to source after unpacking, in order
 SOURCE_PATCHES = scanpci.man.patch 
+SOURCE_PATCHES += fd-leak.patch,-p1
 
 # Library name
 LIBNAME=libpciaccess
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/lib/libpciaccess/fd-leak.patch	Thu Jul 03 13:48:11 2014 -0700
@@ -0,0 +1,35 @@
+From 1654a0462723b3b75d7a4a20bedfc653cc3e1f1a Mon Sep 17 00:00:00 2001
+From: Alan Coopersmith <[email protected]>
+Date: Wed, 2 Jul 2014 16:41:10 -0700
+Subject: [PATCH:libpciaccess] Solaris: Fix fd leak in
+ pci_device_solx_devfs_map_range()
+
+Caching fd's for reuse is most effective when you actually stick the
+newly opened fd in the cache, instead of letting it leak at the end
+of the function.
+
+Regression introduced by yours truly in commit 9f2d95e61896f41adb.
+
+Signed-off-by: Alan Coopersmith <[email protected]>
+Reviewed-by: Randy Fishel <[email protected]>
+---
+ src/solx_devfs.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/solx_devfs.c b/src/solx_devfs.c
+index 8e7ea9b..f572393 100644
+--- a/src/solx_devfs.c
++++ b/src/solx_devfs.c
+@@ -724,6 +724,9 @@ pci_device_solx_devfs_map_range(struct pci_device *dev,
+ 			   strerror(errno));
+ 	    return err;
+ 	}
++#ifndef __sparc
++        xsvc_fd = map_fd;
++#endif
+     }
+ 
+     map->memory = mmap(NULL, map->size, prot, MAP_SHARED, map_fd, map->base);
+-- 
+1.7.9.2
+