diff options
author | Oleksiy Syvokon <oleksiy.syvokon@gmail.com> | 2015-08-31 15:36:26 +0300 |
---|---|---|
committer | Oleksiy Syvokon <oleksiy.syvokon@gmail.com> | 2015-08-31 15:36:26 +0300 |
commit | ca456a770e835f829281dac85bd8c4f00b8624ff (patch) | |
tree | 62757f39d8d281218c6b9f206b139cbacc204f2a /test/functional/libgfapi-python-tests.py | |
parent | 1ec40d0753e7d5185a7fc810df33370330fc6f90 (diff) |
Fix open/fopen in thread other than main
Before this patch, calling Volume.{f}open in a thread other than main
thread was causing segmentation fault (test included). The reason is
missing ctypes declarations.
Also, this patch fixes errno handling for these two functions, making
couple of FIXME/TODO notes go away.
Change-Id: Iae9638b7d16cc0e0c587fd21a94be677f2d4af59
Signed-off-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
Diffstat (limited to 'test/functional/libgfapi-python-tests.py')
-rw-r--r-- | test/functional/libgfapi-python-tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/libgfapi-python-tests.py b/test/functional/libgfapi-python-tests.py index 13ae54d..87dbfe0 100644 --- a/test/functional/libgfapi-python-tests.py +++ b/test/functional/libgfapi-python-tests.py @@ -13,6 +13,7 @@ import unittest import os import types import errno +import threading from gluster.gfapi import File, Volume from gluster.exceptions import LibgfapiException @@ -197,6 +198,17 @@ class FileOpsTest(unittest.TestCase): f.lseek(0, os.SEEK_SET) self.assertEqual(f.read(), data + "hello world") + def test_fopen_in_thread(self): + def gluster_fopen(): + name = uuid4().hex + with self.vol.fopen(name, 'w') as f: + f.write('hello world') + + # the following caused segfault before the fix + thread = threading.Thread(target=gluster_fopen) + thread.start() + thread.join() + def test_create_file_already_exists(self): try: f = File(self.vol.open("newfile", os.O_CREAT)) |