ossl_init_thread_deregister.pod 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. =pod
  2. =head1 NAME
  3. OSSL_thread_stop_handler_fn,
  4. ossl_init_thread_start,
  5. ossl_init_thread_deregister
  6. - internal thread routines
  7. =head1 SYNOPSIS
  8. #include "crypto/cryptlib.h"
  9. #include <openssl/core.h>
  10. typedef void (*OSSL_thread_stop_handler_fn)(void *arg);
  11. int ossl_init_thread_start(const void *index, void *arg,
  12. OSSL_thread_stop_handler_fn handfn);
  13. int ossl_init_thread_deregister(void *index);
  14. =head1 DESCRIPTION
  15. Thread aware code may be informed about when a thread is stopping, typically to
  16. perform some cleanup operation.
  17. Thread stop events may be detected by OpenSSL either automatically (using the
  18. capabilities of the underlying threading library) where possible or explicitly
  19. by the application calling OPENSSL_thread_stop() or OPENSSL_thread_stop_ex().
  20. Thread aware code registers a "stop handler" for each new thread that it uses.
  21. Typically, when a new thread is being used, code will add a new value to some
  22. thread local variable and then register a stop handler. When the thread is
  23. stopping the stop handler is called (while on that thread) and the code can
  24. clean up the value stored in the thread local variable.
  25. A new stop handler is registered using the function ossl_init_thread_start().
  26. The I<index> parameter should be a unique value that can be used to identify a
  27. set of common stop handlers and is passed in a later call to
  28. ossl_init_thread_deregister. If no later call to ossl_init_thread_deregister is
  29. made then NULL can be passed for this parameter. The I<arg> parameter is passed
  30. back as an argument to the stop handler when it is later invoked. Finally the
  31. I<handfn> is a function pointer to the stop handler itself.
  32. In the event that previously registered stop handlers need to be deregistered
  33. then this can be done using the function ossl_init_thread_deregister().
  34. This will deregister all stop handlers (no matter which thread they were
  35. registered for) which the same I<index> value.
  36. =head1 RETURN VALUES
  37. ossl_init_thread_start() and ossl_init_thread_deregister() return 1 for success
  38. or 0 on error.
  39. =head1 HISTORY
  40. The functions described here were all added in OpenSSL 3.0.
  41. =head1 COPYRIGHT
  42. Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  43. Licensed under the Apache License 2.0 (the "License"). You may not use
  44. this file except in compliance with the License. You can obtain a copy
  45. in the file LICENSE in the source distribution or at
  46. L<https://www.openssl.org/source/license.html>.
  47. =cut