aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-03-22 13:11:03 +0000
committerlloyd <[email protected]>2012-03-22 13:11:03 +0000
commit697d63169705b9ce0dabb46b656b1b26777a3e5d (patch)
tree44775b518d6daaf2c88710a059cff587f238e8f9 /src
parentaee464bfa7c104f24620d96467ae7770d96a884a (diff)
Reorder schema and make the session id a primary key since it should
not only be unique but fast searches on it are likely useful. Not bothering to put an index on the (hostname,hostport) tuple as it's only used by clients on initial connection, and even at a 10K rows that search wouldn't take long at all.
Diffstat (limited to 'src')
-rw-r--r--src/tls/sessions_sqlite/tls_sqlite_sess_mgr.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tls/sessions_sqlite/tls_sqlite_sess_mgr.cpp b/src/tls/sessions_sqlite/tls_sqlite_sess_mgr.cpp
index 3b68939fa..7605313ff 100644
--- a/src/tls/sessions_sqlite/tls_sqlite_sess_mgr.cpp
+++ b/src/tls/sessions_sqlite/tls_sqlite_sess_mgr.cpp
@@ -88,11 +88,11 @@ Session_Manager_SQLite::Session_Manager_SQLite(const std::string& db_filename,
const std::string table_sql =
"create table if not exists " +
m_table_name + "(" +
+ "session_id TEXT PRIMARY KEY, "
+ "session_start INTEGER, "
"hostname TEXT, "
"hostport INTEGER, "
- "session_start INTEGER, "
- "session_id TEXT UNIQUE, "
- "session TEXT"
+ "session BLOB"
")";
char* errmsg = 0;
@@ -193,10 +193,10 @@ void Session_Manager_SQLite::save(const Session& session)
{
sqlite3_statement stmt(m_db, "insert into " + m_table_name + " values(?1, ?2, ?3, ?4, ?5)");
- stmt.bind(1, session.sni_hostname());
- stmt.bind(2, 0);
- stmt.bind(3, session.start_time());
- stmt.bind(4, hex_encode(session.session_id()));
+ stmt.bind(1, hex_encode(session.session_id()));
+ stmt.bind(2, session.start_time());
+ stmt.bind(3, session.sni_hostname());
+ stmt.bind(4, 0);
stmt.bind(5, session.DER_encode());
stmt.spin();