mirror of https://github.com/borgbackup/borg.git
fix chunker holding the GIL during blocking I/O
This commit is contained in:
parent
8d89ee981c
commit
b1b66be593
|
@ -157,6 +157,8 @@ chunker_fill(Chunker *c)
|
|||
off_t offset, length;
|
||||
int overshoot;
|
||||
PyObject *data;
|
||||
PyThreadState *thread_state;
|
||||
|
||||
memmove(c->data, c->data + c->last, c->position + c->remaining - c->last);
|
||||
c->position -= c->last;
|
||||
c->last = 0;
|
||||
|
@ -165,6 +167,8 @@ chunker_fill(Chunker *c)
|
|||
return 1;
|
||||
}
|
||||
if(c->fh >= 0) {
|
||||
thread_state = PyEval_SaveThread();
|
||||
|
||||
offset = c->bytes_read;
|
||||
// if we have a os-level file descriptor, use os-level API
|
||||
n = read(c->fh, c->data + c->position + c->remaining, n);
|
||||
|
@ -177,6 +181,7 @@ chunker_fill(Chunker *c)
|
|||
c->eof = 1;
|
||||
}
|
||||
else {
|
||||
PyEval_RestoreThread(thread_state);
|
||||
// some error happened
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
return 0;
|
||||
|
@ -211,6 +216,8 @@ chunker_fill(Chunker *c)
|
|||
|
||||
posix_fadvise(c->fh, offset & ~pagemask, length - overshoot, POSIX_FADV_DONTNEED);
|
||||
#endif
|
||||
|
||||
PyEval_RestoreThread(thread_state);
|
||||
}
|
||||
else {
|
||||
// no os-level file descriptor, use Python file object API
|
||||
|
|
Loading…
Reference in New Issue