2 commits - func/forkbomb.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 func/forkbomb.py |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 1070b5929645de5b10a8a7202fffe1cf2ff00ff4
Merge: fe2f4db a5f9e1d
Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx>
Date:   Wed Jan 11 12:57:25 2012 -0500

    Merge branch 'master' of ssh://git.fedorahosted.org/git/func
    
    * 'master' of ssh://git.fedorahosted.org/git/func: (7 commits)
      Allowed the location of snmpget to be set in config file.
      ...



commit fe2f4db9ee3f2c6e4c4dcd13199ea62a62f796ed
Author: Kristian Kostecky <kris@xxxxxxxxxxx>
Date:   Wed Jan 11 12:56:29 2012 -0500

    Keep forkbomb.py from leaking tempfiles.

diff --git a/func/forkbomb.py b/func/forkbomb.py
index c00c710..f5c545a 100644
--- a/func/forkbomb.py
+++ b/func/forkbomb.py
@@ -32,7 +32,7 @@ def __get_storage(dir):
     dir = os.path.expanduser(dir)
     if not os.path.exists(dir):
         os.makedirs(dir)
-    return tempfile.mkstemp(suffix='', prefix='asynctmp', dir=dir)[1]
+    return tempfile.mkstemp(suffix='', prefix='asynctmp', dir=dir)
 
 def __access_buckets(filename,clear,new_key=None,new_value=None):
     """
@@ -48,7 +48,9 @@ def __access_buckets(filename,clear,new_key=None,new_value=None):
     if clear:
         storage.clear()
         storage.close()
+        internal_db.close()
         fcntl.flock(handle.fileno(), fcntl.LOCK_UN)
+        handle.close()
         return {}
 
     if not storage.has_key("data"):
@@ -64,7 +66,9 @@ def __access_buckets(filename,clear,new_key=None,new_value=None):
 
     rc = storage["data"].copy()
     storage.close()
+    internal_db.close()
     fcntl.flock(handle.fileno(), fcntl.LOCK_UN)
+    handle.close()
 
     return rc
 
@@ -135,13 +139,15 @@ def batch_run(pool,callback,nforks=DEFAULT_FORKS,cachedir=DEFAULT_CACHE_DIR):
     if nforks < 1:
         # modulus voodoo gets crazy otherwise and bad things happen
         nforks = 1
-    shelf_file = __get_storage(cachedir)
+    shelf_file_obj = __get_storage(cachedir)
+    shelf_file = shelf_file_obj[1]
     __access_buckets(shelf_file,True,None)
     buckets = __bucketize(pool, nforks)
     __forkbomb(0,buckets,callback,shelf_file)
     rc = __access_buckets(shelf_file,False,None)
 
     try: #it's only cleanup so don't care if the files disapeared
+        os.close(shelf_file_obj[0])
         os.remove(shelf_file)
         os.remove(shelf_file+".pag")
         os.remove(shelf_file+".dir")


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux