summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2011-04-17 23:47:23 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2011-04-17 23:47:23 +0000
commit39f484a042e0b4bbd8ded39becda1a48e5ad46aa (patch)
treeb17df752405023c563c492797d530a1696bf407a
parent92fa2ba908ce870442f9629f8d2784a7fd97660a (diff)
downloadpysendfile-39f484a042e0b4bbd8ded39becda1a48e5ad46aa.tar.gz
SunOS - PyPargseArg: use #l or #L depending on large file support
-rw-r--r--sendfilemodule.c9
-rw-r--r--test/test_sendfile.py18
2 files changed, 19 insertions, 8 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c
index 7e70dcd..68ac4cb 100644
--- a/sendfilemodule.c
+++ b/sendfilemodule.c
@@ -325,8 +325,15 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict)
size_t nbytes;
ssize_t sent;
- if (!PyArg_ParseTuple(args, "iill", &out_fd, &in_fd, &offset, &nbytes))
+ if (!PyArg_ParseTuple(args,
+#if defined(HAVE_LARGEFILE_SUPPORT)
+ "iiLL",
+#else
+ "iill",
+#endif
+ &out_fd, &in_fd, &offset, &nbytes)) {
return NULL;
+ }
sent = sendfile(out_fd, in_fd, &offset, nbytes);
if (sent == -1)
return PyErr_SetFromErrno(PyExc_OSError);
diff --git a/test/test_sendfile.py b/test/test_sendfile.py
index dd4fab1..dc88d25 100644
--- a/test/test_sendfile.py
+++ b/test/test_sendfile.py
@@ -26,6 +26,7 @@ def _bytes(x):
TESTFN = "$testfile"
TESTFN2 = TESTFN + "2"
+TESTFN3 = TESTFN + "3"
DATA = _bytes("12345abcde" * 1024 * 1024) # 10 Mb
HOST = '127.0.0.1'
BIGFILE_SIZE = 2500000000 # > 2GB file (2GB = 2147483648 bytes)
@@ -388,14 +389,14 @@ class TestLargeFile(unittest.TestCase):
sys.stdout.write("\ncreating file:\n")
sys.stdout.flush()
self.create_file()
- self.file = open(TESTFN2, 'rb')
+ self.file = open(TESTFN3, 'rb')
self.fileno = self.file.fileno()
sys.stdout.write("\starting transfer:\n")
sys.stdout.flush()
def tearDown(self):
- if os.path.isfile(TESTFN2):
- os.remove(TESTFN2)
+ #if os.path.isfile(TESTFN3):
+ # os.remove(TESTFN3)
if hasattr(self, 'file'):
self.file.close()
self.client.close()
@@ -408,7 +409,10 @@ class TestLargeFile(unittest.TestCase):
sys.stdout.flush()
def create_file(self):
- f = open(TESTFN2, 'wb')
+ # XXX - temporary
+ if os.path.isfile(TESTFN3):
+ return
+ f = open(TESTFN3, 'wb')
chunk_len = 65536
chunk = _bytes('x' * chunk_len)
total = 0
@@ -431,7 +435,7 @@ class TestLargeFile(unittest.TestCase):
total_sent = 0
offset = 0
nbytes = 65536
- file_size = os.path.getsize(TESTFN2)
+ file_size = os.path.getsize(TESTFN3)
timer = RepeatedTimer(1, lambda: self.print_percent(total_sent,
file_size))
timer.start()
@@ -454,10 +458,10 @@ class TestLargeFile(unittest.TestCase):
self.assertEqual(total_sent, file_size)
self.client.close()
if "sunos" in sys.platform:
- time.sleep(.1)
+ time.sleep(1)
self.server.wait()
data_len = self.server.handler_instance.in_buffer_len
- file_size = os.path.getsize(TESTFN2)
+ file_size = os.path.getsize(TESTFN3)
self.assertEqual(file_size, data_len)