Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #448 from csirtgadgets/fix/zmq-fd-leaks
Browse files Browse the repository at this point in the history
problem: IOLoop leaks FDs in fireball mode
  • Loading branch information
ckrez authored Mar 28, 2019
2 parents dfc9cba + 7543e80 commit d3f0556
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cif/httpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def login():
if request.form['token'] == '':
return render_template('login.html')

c = Client(remote, HTTPD_TOKEN)
rv = c.tokens_search({'token': request.form['token']})
with Client(remote, HTTPD_TOKEN) as cli:
rv = cli.tokens_search({'token': request.form['token']})

if len(rv) == 0:
return render_template('login.html', code=401)

Expand Down
11 changes: 8 additions & 3 deletions cif/httpd/views/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def get(self):
return jsonify_success(r)

try:
r = Client(remote, pull_token()).indicators_search(filters, decode=False)
with Client(remote, pull_token()) as cli:
r = cli.indicators_search(filters, decode=False)

except RuntimeError as e:
logger.error(e)
return jsonify_unknown(msg='search failed')
Expand Down Expand Up @@ -68,7 +70,9 @@ def post(self):
logger.info('fireball mode')
fireball = True
try:
r = Client(remote, pull_token()).indicators_create(request.data, nowait=nowait, fireball=fireball)
with Client(remote, pull_token()) as cli:
r = cli.indicators_create(request.data, nowait=nowait,
fireball=fireball)
if nowait:
r = 'pending'

Expand Down Expand Up @@ -99,7 +103,8 @@ def post(self):
def delete(self):
try:
data = request.data.decode('utf-8')
r = Client(remote, pull_token()).indicators_delete(data)
with Client(remote, pull_token()) as cli:
r = cli.indicators_delete(data)

except RuntimeError as e:
logger.error(e)
Expand Down
3 changes: 2 additions & 1 deletion cif/httpd/views/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def get(self):
return jsonify_success(r)

try:
r = Client(remote, pull_token()).ping(write=write)
with Client(remote, pull_token()) as cli:
r = cli.ping(write=write)

except TimeoutError:
return jsonify_unknown(msg='timeout', code=408)
Expand Down
4 changes: 2 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage>=4.2
pytest-cov>=2.2.1,<2.6.1
pytest>=2.8.0,<3.0
pytest-cov>=2.6
pytest>=4.2
-r requirements.txt

0 comments on commit d3f0556

Please sign in to comment.