diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-16 17:30:51 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-16 17:30:51 +0000 |
commit | aeb1e83b15e81f869b791e693b08400e15dad33d (patch) | |
tree | 8efe97dbd6043cc14130e20a68f78865f092b614 | |
parent | 60789c86854bb60444a8db07e3b7afe3f53a1064 (diff) | |
download | pysendfile-aeb1e83b15e81f869b791e693b08400e15dad33d.tar.gz |
Py_BEGIN/END_ALLOW_THREADS around getsockopt(), setsockopt(), send()
-rw-r--r-- | sendfilemodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c index 1148b5d..e85ad9a 100644 --- a/sendfilemodule.c +++ b/sendfilemodule.c @@ -251,18 +251,24 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) if (head_len != 0 || tail_len != 0) { int cork = 1; // first, fetch the original setting + Py_BEGIN_ALLOW_THREADS ret = getsockopt(out_fd, SOL_TCP, TCP_CORK, (void*)&orig_cork, &orig_cork_len); + Py_END_ALLOW_THREADS if (ret == -1) return PyErr_SetFromErrno(PyExc_OSError); + Py_BEGIN_ALLOW_THREADS ret = setsockopt(out_fd, SOL_TCP, TCP_CORK, (void*)&cork, sizeof(cork)); + Py_END_ALLOW_THREADS if (ret == -1) return PyErr_SetFromErrno(PyExc_OSError); } // send header if (head_len != 0) { + Py_BEGIN_ALLOW_THREADS sent_h = send(out_fd, head, head_len, 0); + Py_END_ALLOW_THREADS if (sent_h < 0) return PyErr_SetFromErrno(PyExc_OSError); else if (sent_h == 0) { @@ -284,7 +290,9 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) // send trailer if (tail_len != 0) { + Py_BEGIN_ALLOW_THREADS sent_t = send(out_fd, tail, tail_len, 0); + Py_END_ALLOW_THREADS if (sent_t < 0) return PyErr_SetFromErrno(PyExc_OSError); else if (sent_t == 0) { |