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
f749b6f2
Commit
f749b6f2
authored
Jul 15, 2005
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Support callback exception policy
parent
23485978
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miltermodule.c
+38
-3
38 additions, 3 deletions
miltermodule.c
with
38 additions
and
3 deletions
miltermodule.c
+
38
−
3
View file @
f749b6f2
...
@@ -34,6 +34,9 @@ $ python setup.py help
...
@@ -34,6 +34,9 @@ $ python setup.py help
libraries=["milter","smutil","resolv"]
libraries=["milter","smutil","resolv"]
* $Log$
* $Log$
* Revision 1.5 2005/06/24 04:20:07 customdesigned
* Report context allocation error.
*
* Revision 1.4 2005/06/24 04:12:43 customdesigned
* Revision 1.4 2005/06/24 04:12:43 customdesigned
* Remove unused name argument to generic wrappers.
* Remove unused name argument to generic wrappers.
*
*
...
@@ -343,7 +346,8 @@ CHGHDRS - filter may change/delete headers";
...
@@ -343,7 +346,8 @@ CHGHDRS - filter may change/delete headers";
static
PyObject
*
static
PyObject
*
milter_set_flags
(
PyObject
*
self
,
PyObject
*
args
)
{
milter_set_flags
(
PyObject
*
self
,
PyObject
*
args
)
{
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
description
.
xxfi_flags
))
return
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:set_flags"
,
&
description
.
xxfi_flags
))
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
}
}
...
@@ -509,6 +513,28 @@ milter_set_close_callback(PyObject *self, PyObject *args) {
...
@@ -509,6 +513,28 @@ milter_set_close_callback(PyObject *self, PyObject *args) {
return
generic_set_callback
(
args
,
"O:set_close_callback"
,
&
close_callback
);
return
generic_set_callback
(
args
,
"O:set_close_callback"
,
&
close_callback
);
}
}
static
int
exception_policy
=
SMFIS_TEMPFAIL
;
static
char
milter_set_exception_policy__doc__
[]
=
"set_exception_policy(i) -> None
\n
\
Sets the policy for untrapped Python exceptions during a callback.
\n
\
Must be one of TEMPFAIL,REJECT,CONTINUE"
;
static
PyObject
*
milter_set_exception_policy
(
PyObject
*
self
,
PyObject
*
args
)
{
int
i
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:set_exception_policy"
,
&
i
))
return
NULL
;
switch
(
i
)
{
case
SMFIS_REJECT
:
case
SMFIS_TEMPFAIL
:
case
SMFIS_CONTINUE
:
exception_policy
=
i
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
PyErr_SetString
(
MilterError
,
"invalid exception policy"
);
return
NULL
;
}
/** Report and clear any python exception before returning to libmilter.
/** Report and clear any python exception before returning to libmilter.
The interpreter is locked when we are called, and we unlock it. */
The interpreter is locked when we are called, and we unlock it. */
static
int
_report_exception
(
milter_ContextObject
*
self
)
{
static
int
_report_exception
(
milter_ContextObject
*
self
)
{
...
@@ -516,9 +542,16 @@ static int _report_exception(milter_ContextObject *self) {
...
@@ -516,9 +542,16 @@ static int _report_exception(milter_ContextObject *self) {
PyErr_Print
();
PyErr_Print
();
PyErr_Clear
();
/* must clear since not returning to python */
PyErr_Clear
();
/* must clear since not returning to python */
PyEval_ReleaseThread
(
self
->
t
);
PyEval_ReleaseThread
(
self
->
t
);
switch
(
exception_policy
)
{
case
SMFIS_REJECT
:
smfi_setreply
(
self
->
ctx
,
"554"
,
"5.3.0"
,
"Filter failure"
);
return
SMFIS_REJECT
;
case
SMFIS_TEMPFAIL
:
smfi_setreply
(
self
->
ctx
,
"451"
,
"4.3.0"
,
"Filter failure"
);
smfi_setreply
(
self
->
ctx
,
"451"
,
"4.3.0"
,
"Filter failure"
);
return
SMFIS_TEMPFAIL
;
return
SMFIS_TEMPFAIL
;
}
}
return
SMFIS_CONTINUE
;
}
PyEval_ReleaseThread
(
self
->
t
);
PyEval_ReleaseThread
(
self
->
t
);
return
SMFIS_CONTINUE
;
return
SMFIS_CONTINUE
;
}
}
...
@@ -1180,6 +1213,8 @@ static PyMethodDef milter_methods[] = {
...
@@ -1180,6 +1213,8 @@ static PyMethodDef milter_methods[] = {
{
"set_eom_callback"
,
milter_set_eom_callback
,
METH_VARARGS
,
milter_set_eom_callback__doc__
},
{
"set_eom_callback"
,
milter_set_eom_callback
,
METH_VARARGS
,
milter_set_eom_callback__doc__
},
{
"set_abort_callback"
,
milter_set_abort_callback
,
METH_VARARGS
,
milter_set_abort_callback__doc__
},
{
"set_abort_callback"
,
milter_set_abort_callback
,
METH_VARARGS
,
milter_set_abort_callback__doc__
},
{
"set_close_callback"
,
milter_set_close_callback
,
METH_VARARGS
,
milter_set_close_callback__doc__
},
{
"set_close_callback"
,
milter_set_close_callback
,
METH_VARARGS
,
milter_set_close_callback__doc__
},
{
"set_exception_policy"
,
milter_set_exception_policy
,
METH_VARARGS
,
milter_set_exception_policy__doc__
},
{
"register"
,
milter_register
,
METH_VARARGS
,
milter_register__doc__
},
{
"register"
,
milter_register
,
METH_VARARGS
,
milter_register__doc__
},
{
"register"
,
milter_register
,
METH_VARARGS
,
milter_register__doc__
},
{
"main"
,
milter_main
,
METH_VARARGS
,
milter_main__doc__
},
{
"main"
,
milter_main
,
METH_VARARGS
,
milter_main__doc__
},
{
"setdbg"
,
milter_setdbg
,
METH_VARARGS
,
milter_setdbg__doc__
},
{
"setdbg"
,
milter_setdbg
,
METH_VARARGS
,
milter_setdbg__doc__
},
...
...
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
sign in
to comment