Blame SOURCES/0018-Add-macros-to-release-GIL-lock.patch

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