Commit 21e00174 authored by Richard Levitte's avatar Richard Levitte
Browse files

Restore the ERR_remove_thread_state() API and make it a no-op



The ERR_remove_thread_state() API is restored to take a pointer
argument, but does nothing more.  ERR_remove_state() is also made into
a no-op.  Both functions are deprecated and users are recommended to
use OPENSSL_thread_stop() instead.

Documentation is changed to reflect this.

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent 06aa885d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -740,7 +740,7 @@ const char *ERR_reason_error_string(unsigned long e)
    return ((p == NULL) ? NULL : p->string);
}

void ERR_remove_thread_state(void)
void err_delete_thread_state(void)
{
    ERR_STATE *state = ERR_get_state();
    if (state == NULL)
@@ -750,10 +750,15 @@ void ERR_remove_thread_state(void)
    ERR_STATE_free(state);
}

#if OPENSSL_API_COMPAT < 0x10000000L
void ERR_remove_thread_state(void *dummy)
{
}
#endif

#if OPENSSL_API_COMPAT < 0x10000000L
void ERR_remove_state(unsigned long pid)
{
    ERR_remove_thread_state();
}
#endif

+1 −0
Original line number Diff line number Diff line
@@ -13,5 +13,6 @@

void err_load_crypto_strings_int(void);
void err_cleanup(void);
void err_delete_thread_state(void);

#endif
+2 −2
Original line number Diff line number Diff line
@@ -351,9 +351,9 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
    if (locals->err_state) {
#ifdef OPENSSL_INIT_DEBUG
        fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
                        "ERR_remove_thread_state()\n");
                        "err_delete_thread_state()\n");
#endif
        ERR_remove_thread_state();
        err_delete_thread_state();
    }

    OPENSSL_free(locals);
+16 −18
Original line number Diff line number Diff line
@@ -2,44 +2,42 @@

=head1 NAME

ERR_remove_thread_state, ERR_remove_state - free a thread's error queue
ERR_remove_thread_state, ERR_remove_state - DEPRECATED

=head1 SYNOPSIS

 #include <openssl/err.h>

 void ERR_remove_thread_state(void);

Deprecated:

 #if OPENSSL_API_COMPAT < 0x10000000L
 void ERR_remove_state(unsigned long pid);
 #endif

=head1 DESCRIPTION
 #if OPENSSL_API_COMPAT < 0x10100000L
 void ERR_remove_thread_state(void *);
 #endif

ERR_remove_thread_state() frees the error queue associated with the current
thread.
=head1 DESCRIPTION

Since error queue data structures are allocated automatically for new
threads, they must be freed when threads are terminated in order to
avoid memory leaks.
The functions described here were used to free the error queue
associated with the current or specificed thread.

ERR_remove_state is deprecated and has been replaced by
ERR_remove_thread_state. Any argument to this function is ignored and
calling ERR_remove_state is equivalent to B<ERR_remove_thread_state()>.
They are now deprecated and do nothing, please use
OPENSSL_thread_stop() instead.

=head1 RETURN VALUE

ERR_remove_thread_state and ERR_remove_state() return no value.
The functions described here return no value.

=head1 SEE ALSO

L<err(3)>
L<err(3)>, L<OPENSSL_thread_stop(3)>

=head1 HISTORY

ERR_remove_state()
was deprecated in OpenSSL 1.0.0 when ERR_remove_thread_state() was introduced.
ERR_remove_state() was deprecated in OpenSSL 1.0.0 when
ERR_remove_thread_state() was introduced.

ERR_remove_thread_state() was deprecated in OpenSSL 1.1.0 when the
thread handling functionality was entirely rewritten.

=cut
+4 −5
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ err - error codes
 int ERR_GET_REASON(unsigned long e);

 void ERR_clear_error(void);
 void ERR_remove_thread_state(void);

 char *ERR_error_string(unsigned long e, char *buf);
 const char *ERR_lib_error_string(unsigned long e);
@@ -48,6 +47,10 @@ Deprecated:
 void ERR_remove_state(unsigned long pid);
 #endif

 #if OPENSSL_API_COMPAT < 0x10100000L
 void ERR_remove_thread_state(void *);
 #endif

 #if OPENSSL_API_COMPAT < 0x10100000L
 void ERR_free_strings(void)
 #endif
@@ -71,9 +74,6 @@ messages is described in L<ERR_error_string(3)>.
L<ERR_clear_error(3)> can be used to clear the
error queue.

Note that L<ERR_remove_thread_state(3)> should be used to
avoid memory leaks when threads are terminated.

=head1 ADDING NEW ERROR CODES TO OPENSSL

See L<ERR_put_error(3)> if you want to record error codes in the
@@ -186,7 +186,6 @@ L<ERR_clear_error(3)>,
L<ERR_error_string(3)>,
L<ERR_print_errors(3)>,
L<ERR_load_crypto_strings(3)>,
L<ERR_remove_thread_state(3)>,
L<ERR_put_error(3)>,
L<ERR_load_strings(3)>,
L<SSL_get_error(3)>
Loading