From ca456a770e835f829281dac85bd8c4f00b8624ff Mon Sep 17 00:00:00 2001 From: Oleksiy Syvokon Date: Mon, 31 Aug 2015 15:36:26 +0300 Subject: 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 --- test/functional/libgfapi-python-tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/libgfapi-python-tests.py') 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)) -- cgit