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
34746823
Commit
34746823
authored
12 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Use python locking to avoid busy wait.
parent
baeddd9f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Milter/greysql.py
+7
-1
7 additions, 1 deletion
Milter/greysql.py
with
7 additions
and
1 deletion
Milter/greysql.py
+
7
−
1
View file @
34746823
...
...
@@ -2,10 +2,13 @@ import time
import
logging
import
urllib
import
sqlite3
import
thread
from
datetime
import
datetime
log
=
logging
.
getLogger
(
'
milter.greylist
'
)
_db_lock
=
thread
.
allocate_lock
()
class
Greylist
(
object
):
def
__init__
(
self
,
dbname
,
grey_time
=
10
,
grey_expire
=
4
,
grey_retain
=
36
):
...
...
@@ -35,6 +38,7 @@ class Greylist(object):
def
check
(
self
,
ip
,
sender
,
recipient
,
timeinc
=
0
):
"
Return number of allowed messages for greylist triple.
"
_db_lock
.
acquire
()
cur
=
self
.
conn
.
execute
(
'
begin immediate
'
)
try
:
cur
.
execute
(
'''
select firstseen,lastseen,cnt,umis from greylist where
...
...
@@ -73,7 +77,9 @@ class Greylist(object):
where ip=? and sender=? and recipient=?
'''
,
(
now
,
now
,
0
,
None
,
ip
,
sender
,
recipient
))
self
.
conn
.
commit
()
finally
:
cur
.
close
()
finally
:
cur
.
close
()
_db_lock
.
release
()
return
cnt
def
close
(
self
):
...
...
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