Week 7 P2

Published: 07/19/2019

After doing some traceback of the program, I found that when running multithread scanning, each thread instantiates a nvd object NVDSQLite, while in nvd.get_cvelist_if_stale() the object tries to call init_database() regardless of the database situation, and in line 131 of NVDAutoUpdate.py, it will execute the CREATE TABLE IF NOT EXISTS. Since this is not thread-safe, the database might be locked.

Therefore, there might be a logical incorrection in previous code, which is posted in issue #177. I think in getting cves we don't need to check database status since we have already checked it before, if not we could manually checked the status first and then try to get cve, therefore, we only need to make a cursor and connect to the database. So I will fix that first and then test mutithread mode.

Actually I don't think sqlite3 is a good fit with multithread since in python's official document it says "Older SQLite versions had issues with sharing connections between threads. That’s why the Python module disallows sharing connections and cursors between threads. If you still try to do so, you will get an exception at runtime."

1000 characters left