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