]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Now gnutls_deinit() removes abnormally terminated sessions. Added the _gnutls_deinit...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 10 Jul 2002 12:07:00 +0000 (12:07 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 10 Jul 2002 12:07:00 +0000 (12:07 +0000)
lib/gnutls_db.c
lib/gnutls_state.c

index f3ef5f31c3569860d661a1bc4d81e8600aa1fa04..fd420595b5016c93e31610ed0280b210fafe3b48 100644 (file)
@@ -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) {
index 314e85f4838b0a9e503e6ab4d48546a2399bd30f..693886093215036b5b593efdfc7d79ff1a4eb359 100644 (file)
@@ -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;
 }