diff options
-rw-r--r-- | lib/gnutls_db.c | 6 | ||||
-rw-r--r-- | lib/gnutls_state.c | 40 |
2 files changed, 42 insertions, 4 deletions
diff --git a/lib/gnutls_db.c b/lib/gnutls_db.c index f3ef5f31c3..fd420595b5 100644 --- a/lib/gnutls_db.c +++ b/lib/gnutls_db.c @@ -317,13 +317,15 @@ int ret = 0; } /** - * gnutls_db_remove_session - This function will remove the current session data from the db + * gnutls_db_remove_session - This function will remove the current session data from the database * @state: is a &GNUTLS_STATE structure. * * This function will remove the current session data from the session * database. This will prevent future handshakes reusing these session * data. This function should be called if a session was terminated - * abnormaly. + * abnormaly, and before gnutls_deinit() is called. + * + * Normally gnutls_deinit() will remove abnormally terminated sessions. * **/ void gnutls_db_remove_session(GNUTLS_STATE state) { diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index 314e85f483..6938860932 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -206,13 +206,24 @@ int default_protocol_list[] = { GNUTLS_TLS1, 0 }; return 0; } +/* returns RESUME_FALSE or RESUME_TRUE. + */ +int _gnutls_session_is_resumable( GNUTLS_STATE state) +{ + return state->gnutls_internals.resumable; +} + + /** - * gnutls_deinit - This function clears all buffers associated with the &state + * _gnutls_deinit - This function clears all buffers associated with the &state * @state: is a &GNUTLS_STATE structure. * * This function clears all buffers associated with the &state. + * The difference with gnutls_deinit() is that this function will not + * interfere with the session database. + * **/ -void gnutls_deinit(GNUTLS_STATE state) +void _gnutls_deinit(GNUTLS_STATE state) { if (state==NULL) return; @@ -277,6 +288,31 @@ void gnutls_deinit(GNUTLS_STATE state) return; } +/** + * gnutls_deinit - This function clears all buffers associated with the &state + * @state: is a &GNUTLS_STATE structure. + * + * This function clears all buffers associated with the &state. + * This function will also remove session data from the session database + * if the session was terminated abnormally. + * + **/ +void gnutls_deinit(GNUTLS_STATE state) +{ + + if (state==NULL) return; + + /* If the session was terminated abnormally then remove + * the session data. + */ + if (_gnutls_session_is_resumable(state)==RESUME_FALSE) { + gnutls_db_remove_session( state); + } + + _gnutls_deinit( state); +} + + int _gnutls_dh_get_prime_bits( GNUTLS_STATE state) { return state->gnutls_internals.dh_prime_bits; } |