Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 451a356

Browse files
committed
Merged revisions 64685 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r64685 | amaury.forgeotdarc | 2008-07-03 01:40:28 +0200 (Thu, 03 Jul 2008) | 3 lines Try a blind fix to nismodule which fails on the solaris10 3.0 buildbot: the GIL must be re-acquired in the callback function ........
1 parent 4b02c5a commit 451a356

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Modules/nismodule.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ typedef int (*foreachfunc)(int, char *, int, char *, int, char *);
9898
struct ypcallback_data {
9999
PyObject *dict;
100100
int fix;
101+
PyThreadState *state;
101102
};
102103

103104
static int
@@ -109,6 +110,7 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
109110
PyObject *val;
110111
int err;
111112

113+
PyEval_RestoreThread(indata->state);
112114
if (indata->fix) {
113115
if (inkeylen > 0 && inkey[inkeylen-1] == '\0')
114116
inkeylen--;
@@ -127,10 +129,11 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
127129
err = PyDict_SetItem(indata->dict, key, val);
128130
Py_DECREF(key);
129131
Py_DECREF(val);
130-
if (err != 0) {
132+
if (err != 0)
131133
PyErr_Clear();
132-
return 1;
133-
}
134+
indata->state = PyEval_SaveThread();
135+
if (err != 0)
136+
return 1;
134137
return 0;
135138
}
136139
return 1;
@@ -206,9 +209,9 @@ nis_cat (PyObject *self, PyObject *args, PyObject *kwdict)
206209
data.dict = dict;
207210
map = nis_mapname (map, &data.fix);
208211
cb.data = (char *)&data;
209-
Py_BEGIN_ALLOW_THREADS
212+
data.state = PyEval_SaveThread();
210213
err = yp_all (domain, map, &cb);
211-
Py_END_ALLOW_THREADS
214+
PyEval_RestoreThread(data.state);
212215
if (err != 0) {
213216
Py_DECREF(dict);
214217
return nis_error(err);

0 commit comments

Comments
 (0)