SSL_CTX_set_read_ahead.pod 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_read_ahead, SSL_CTX_get_read_ahead,
  4. SSL_set_read_ahead, SSL_get_read_ahead,
  5. SSL_CTX_get_default_read_ahead
  6. - manage whether to read as many input bytes as possible
  7. =head1 SYNOPSIS
  8. #include <openssl/ssl.h>
  9. void SSL_set_read_ahead(SSL *s, int yes);
  10. int SSL_get_read_ahead(const SSL *s);
  11. SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes);
  12. long SSL_CTX_get_read_ahead(SSL_CTX *ctx);
  13. long SSL_CTX_get_default_read_ahead(SSL_CTX *ctx);
  14. =head1 DESCRIPTION
  15. SSL_CTX_set_read_ahead() and SSL_set_read_ahead() set whether we should read as
  16. many input bytes as possible (for nonblocking reads) or not. For example if
  17. B<x> bytes are currently required by OpenSSL, but B<y> bytes are available from
  18. the underlying BIO (where B<y> > B<x>), then OpenSSL will read all B<y> bytes
  19. into its buffer (providing that the buffer is large enough) if reading ahead is
  20. on, or B<x> bytes otherwise.
  21. Setting the parameter B<yes> to 0 turns reading ahead is off, other values turn
  22. it on.
  23. SSL_CTX_set_default_read_ahead() is identical to SSL_CTX_set_read_ahead().
  24. SSL_CTX_get_read_ahead() and SSL_get_read_ahead() indicate whether reading
  25. ahead has been set or not.
  26. SSL_CTX_get_default_read_ahead() is identical to SSL_CTX_get_read_ahead().
  27. These functions cannot be used with QUIC SSL objects. SSL_set_read_ahead()
  28. has no effect if called on a QUIC SSL object.
  29. =head1 NOTES
  30. These functions have no impact when used with DTLS. The return values for
  31. SSL_CTX_get_read_head() and SSL_get_read_ahead() are undefined for DTLS. Setting
  32. B<read_ahead> can impact the behaviour of the SSL_pending() function
  33. (see L<SSL_pending(3)>).
  34. Since SSL_read() can return B<SSL_ERROR_WANT_READ> for non-application data
  35. records, and SSL_has_pending() can't tell the difference between processed and
  36. unprocessed data, it's recommended that if read ahead is turned on that
  37. B<SSL_MODE_AUTO_RETRY> is not turned off using SSL_CTX_clear_mode().
  38. That will prevent getting B<SSL_ERROR_WANT_READ> when there is still a complete
  39. record available that hasn't been processed.
  40. If the application wants to continue to use the underlying transport (e.g. TCP
  41. connection) after the SSL connection is finished using SSL_shutdown() reading
  42. ahead should be turned off.
  43. Otherwise the SSL structure might read data that it shouldn't.
  44. =head1 RETURN VALUES
  45. SSL_get_read_ahead() and SSL_CTX_get_read_ahead() return 0 if reading ahead is off,
  46. and non zero otherwise.
  47. =head1 SEE ALSO
  48. L<ssl(7)>, L<SSL_pending(3)>
  49. =head1 COPYRIGHT
  50. Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
  51. Licensed under the Apache License 2.0 (the "License"). You may not use
  52. this file except in compliance with the License. You can obtain a copy
  53. in the file LICENSE in the source distribution or at
  54. L<https://www.openssl.org/source/license.html>.
  55. =cut