+#else /* suggested change: increase reference counter so that a session
+ * can later be set in a new SSL object.
+ * Objections:
+ * -- the modified function should have a new name (or old
+ * applications, including s_client, leak memory);
+ * -- the locking seems unnecessary given that SSL structures
+ * usually cannot be safely shared between threads anyway. */
+SSL_SESSION *SSL_get_session(SSL *ssl)
+ {
+ SSL_SESSION *sess;
+ /* Need to lock this all up rather than just use CRYPTO_add so that
+ * somebody doesn't free ssl->session between when we check it's
+ * non-null and when we up the reference count. */
+ CRYPTO_r_lock(CRYPTO_LOCK_SSL_SESSION);
+ sess = ssl->session;
+ if(sess)
+ sess->references++;
+ CRYPTO_r_unlock(CRYPTO_LOCK_SSL_SESSION);
+ return(sess);
+ }
+#endif