[Kimchi-devel] [kimchi-devel][PATCH 0/7] Multiple instances of file handler leak fix

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Tue Jan 20 08:45:03 UTC 2015


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

File handler leak can be tested with following scripts against real model
kimchi server,
run "lsof -p $(kimchidpid)" and you can see many file opened without close.

import base64
import json
import os
import unittest
import time

from functools import partial

from utils import request


host = None
ssl_port = None


def setUpModule():
    global host, ssl_port

    host = '127.0.0.1'
    ssl_port = 8001

class RestTests(unittest.TestCase):
    def setUp(self):
        self.request = partial(request, host, ssl_port)

    def test_leak(self):
        def fake_auth_header():
            headers = {'Accept': 'application/json'}
            user, pw = ('my_username', 'my_passwd')
            hdr = "Basic " + base64.b64encode("%s:%s" % (user, pw))
            headers['AUTHORIZATION'] = hdr
            return headers

        def do_thousands(url):
            for i in range(1000):
                self.request(url, headers=fake_auth_header())
                print "called %i times" % i

        url = "https://%s:%s/toys" % \
                (host, ssl_port)
        do_thousands(url)

Royce Lv (7):
  Fix md5 file handler leak
  Fix file handler leak for uptime file
  Close json schema file after loading
  close fh after iso scanning
  Fix leak in check_url_path
  Work around eventfd leak using multiprocessing
  Fix file handler leak in netinfo.py

 src/kimchi/auth.py               | 65 +++++++++++++++++++++++-----------------
 src/kimchi/isoinfo.py            |  5 ++--
 src/kimchi/model/debugreports.py |  5 ++--
 src/kimchi/model/host.py         |  5 ++--
 src/kimchi/netinfo.py            | 16 ++++++----
 src/kimchi/root.py               |  4 +--
 src/kimchi/utils.py              |  4 ++-
 7 files changed, 61 insertions(+), 43 deletions(-)

-- 
1.9.3




More information about the Kimchi-devel mailing list