57 lines
1.7 KiB
Diff
57 lines
1.7 KiB
Diff
|
From bd26fd7e7f91e5c4c6903c3d7e1a375a14261a48 Mon Sep 17 00:00:00 2001
|
||
|
From: Jiri Konecny <jkonecny@redhat.com>
|
||
|
Date: Mon, 11 May 2015 13:16:26 +0200
|
||
|
Subject: [PATCH 18/32] Add macros to release GIL lock
|
||
|
|
||
|
Other threads are blocked when GIL is not released before the time consuming
|
||
|
functions.
|
||
|
---
|
||
|
libiscsi/pylibiscsi.c | 16 +++++++++++++---
|
||
|
1 file changed, 13 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/libiscsi/pylibiscsi.c b/libiscsi/pylibiscsi.c
|
||
|
index 88008538f04f..40b59553a28e 100644
|
||
|
--- a/libiscsi/pylibiscsi.c
|
||
|
+++ b/libiscsi/pylibiscsi.c
|
||
|
@@ -364,8 +364,13 @@ static PyObject *PyIscsiNode_str(PyObject *self)
|
||
|
static PyObject *PyIscsiNode_login(PyObject *self)
|
||
|
{
|
||
|
PyIscsiNode *node = (PyIscsiNode *)self;
|
||
|
+ int ret;
|
||
|
|
||
|
- if (libiscsi_node_login(context, &node->node)) {
|
||
|
+ Py_BEGIN_ALLOW_THREADS
|
||
|
+ ret = libiscsi_node_login(context, &node->node);
|
||
|
+ Py_END_ALLOW_THREADS
|
||
|
+
|
||
|
+ if (ret) {
|
||
|
PyErr_SetString(PyExc_IOError,
|
||
|
libiscsi_get_error_string(context));
|
||
|
return NULL;
|
||
|
@@ -551,6 +556,7 @@ static PyObject *pylibiscsi_discover_sendtargets(PyObject *self,
|
||
|
const struct libiscsi_auth_info *authinfo = NULL;
|
||
|
struct libiscsi_node *found_nodes;
|
||
|
PyObject* found_node_list;
|
||
|
+ int ret;
|
||
|
|
||
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO",
|
||
|
kwlist, &address, &port,
|
||
|
@@ -570,8 +576,12 @@ static PyObject *pylibiscsi_discover_sendtargets(PyObject *self,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- if (libiscsi_discover_sendtargets(context, address, port, authinfo,
|
||
|
- &nr_found, &found_nodes)) {
|
||
|
+ Py_BEGIN_ALLOW_THREADS
|
||
|
+ ret = libiscsi_discover_sendtargets(context, address, port, authinfo,
|
||
|
+ &nr_found, &found_nodes);
|
||
|
+ Py_END_ALLOW_THREADS
|
||
|
+
|
||
|
+ if (ret) {
|
||
|
PyErr_SetString(PyExc_IOError,
|
||
|
libiscsi_get_error_string(context));
|
||
|
return NULL;
|
||
|
--
|
||
|
2.14.4
|
||
|
|