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