Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
04c8b2e1
Commit
04c8b2e1
authored
19 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Resolve FIXME for wrap_close.
parent
56c1cbd0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miltermodule.c
+29
-31
29 additions, 31 deletions
miltermodule.c
with
29 additions
and
31 deletions
miltermodule.c
+
29
−
31
View file @
04c8b2e1
...
...
@@ -34,6 +34,9 @@ $ python setup.py help
libraries=["milter","smutil","resolv"]
* $Log$
* Revision 1.9 2005/12/23 21:46:36 customdesigned
* Compile on sendmail-8.12 (ifdef SMFIR_INSHEADER)
*
* Revision 1.8 2005/10/20 23:23:36 customdesigned
* Include smfi_progress is SMFIR_PROGRESS defined
*
...
...
@@ -286,7 +289,7 @@ _find_context(PyObject *c) {
if
(
c
->
ob_type
==
&
milter_ContextType
)
{
milter_ContextObject
*
self
=
(
milter_ContextObject
*
)
c
;
ctx
=
self
->
ctx
;
if
(
smfi_getpriv
(
ctx
)
!=
self
)
if
(
ctx
!=
NULL
&&
smfi_getpriv
(
ctx
)
!=
self
)
ctx
=
NULL
;
}
if
(
ctx
==
NULL
)
...
...
@@ -294,23 +297,6 @@ _find_context(PyObject *c) {
return
ctx
;
}
/* Release the Python Context for a SMFICTX. */
static
void
_clear_context
(
SMFICTX
*
ctx
)
{
milter_ContextObject
*
self
=
smfi_getpriv
(
ctx
);
if
(
self
)
{
PyThreadState
*
t
=
self
->
t
;
PyEval_AcquireThread
(
t
);
self
->
t
=
0
;
self
->
ctx
=
0
;
smfi_setpriv
(
ctx
,
0
);
Py_DECREF
(
self
);
PyThreadState_Clear
(
t
);
PyEval_ReleaseThread
(
t
);
PyThreadState_Delete
(
t
);
}
}
static
void
milter_Context_dealloc
(
PyObject
*
s
)
{
milter_ContextObject
*
self
=
(
milter_ContextObject
*
)
s
;
...
...
@@ -544,13 +530,19 @@ milter_set_exception_policy(PyObject *self, PyObject *args) {
return
NULL
;
}
static
void
_release_thread
(
PyThreadState
*
t
)
{
if
(
t
!=
NULL
)
PyEval_ReleaseThread
(
t
);
}
/** Report and clear any python exception before returning to libmilter.
The interpreter is locked when we are called, and we unlock it. */
static
int
_report_exception
(
milter_ContextObject
*
self
)
{
if
(
PyErr_Occurred
())
{
PyErr_Print
();
PyErr_Clear
();
/* must clear since not returning to python */
PyEval_R
elease
T
hread
(
self
->
t
);
_r
elease
_t
hread
(
self
->
t
);
switch
(
exception_policy
)
{
case
SMFIS_REJECT
:
smfi_setreply
(
self
->
ctx
,
"554"
,
"5.3.0"
,
"Filter failure"
);
...
...
@@ -561,7 +553,7 @@ static int _report_exception(milter_ContextObject *self) {
}
return
SMFIS_CONTINUE
;
}
PyEval_R
elease
T
hread
(
self
->
t
);
_r
elease
_t
hread
(
self
->
t
);
return
SMFIS_CONTINUE
;
}
...
...
@@ -580,7 +572,7 @@ _generic_wrapper(milter_ContextObject *self, PyObject *cb, PyObject *arglist) {
retval
=
PyInt_AsLong
(
result
);
Py_DECREF
(
result
);
if
(
PyErr_Occurred
())
return
_report_exception
(
self
);
PyEval_R
elease
T
hread
(
self
->
t
);
_r
elease
_t
hread
(
self
->
t
);
return
retval
;
}
...
...
@@ -777,17 +769,23 @@ milter_wrap_close(SMFICTX *ctx) {
PyObject
*
cb
=
close_callback
;
milter_ContextObject
*
self
=
smfi_getpriv
(
ctx
);
int
r
=
SMFIS_CONTINUE
;
if
(
self
!=
NULL
&&
cb
!=
NULL
&&
self
->
ctx
==
ctx
)
{
PyObject
*
arglist
;
PyEval_AcquireThread
(
self
->
t
);
arglist
=
Py_BuildValue
(
"(O)"
,
self
);
if
(
self
!=
NULL
)
{
PyThreadState
*
t
=
self
->
t
;
PyEval_AcquireThread
(
t
);
self
->
t
=
0
;
if
(
cb
!=
NULL
&&
self
->
ctx
==
ctx
)
{
PyObject
*
arglist
=
Py_BuildValue
(
"(O)"
,
self
);
/* Call python close callback, but do not ReleaseThread, because
* self->t is NULL */
r
=
_generic_wrapper
(
self
,
cb
,
arglist
);
}
/* FIXME: It is inefficient to have released the interp lock only to
acquire it again in _clear_context. We can tell _generic_return and
friends not to release the lock by, for instance, setting self->t to NULL.
However, first we make it work. */
_clear_context
(
ctx
);
self
->
ctx
=
0
;
smfi_setpriv
(
ctx
,
0
);
Py_DECREF
(
self
);
PyThreadState_Clear
(
t
);
PyEval_ReleaseThread
(
t
);
PyThreadState_Delete
(
t
);
}
return
r
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment