Skip to content

Fix imported target dependencies for OpenSSL#1

Open
trondn wants to merge 6 commits into
couchbasedeps:release-2.1.12-stable-cbfrom
trondn:release-2.1.12-stable-cb
Open

Fix imported target dependencies for OpenSSL#1
trondn wants to merge 6 commits into
couchbasedeps:release-2.1.12-stable-cbfrom
trondn:release-2.1.12-stable-cb

Conversation

@trondn
Copy link
Copy Markdown

@trondn trondn commented Sep 15, 2022

CMake V3.4 allows to search for the components SSL and Crypto and defines targets for them.

The targets should be used instead of the old variables as they populate the correct include path and libraries.

The targets should also be used in our interface library definition so that it'll continue to work if OpenSSL was moved after the cmake files was created.

CMake V3.4 allows to search for the components SSL and Crypto
and defines targets for them.

The targets should be used instead of the old variables
as they populate the correct include path and libraries.

The targets should also be used in our interface library
definition so that it'll continue to work if OpenSSL was
moved after the cmake files was created.
Copy link
Copy Markdown

@daverigby daverigby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest we also propose this upstream to the main libevent repo.

Comment thread CMakeLists.txt
find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL)
list(APPEND LIB_APPS OpenSSL::SSL OpenSSL::Crypto)
else()
find_package(OpenSSL REQUIRED)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably better to do this based on behaviour - i.e. call find_package(OpenSSL ...), then if the modern-style targets exist use them otherwise use OPENSSL_LIBRARIES.

@trondn
Copy link
Copy Markdown
Author

trondn commented Sep 15, 2022

There is some problems with the change when trying from a clean repo... more testing underway

trondn added 2 commits May 24, 2026 07:34
When activating an event_callback (like those used for deferred
bufferevent callbacks), we now set base->event_continue if the
new callback has a higher priority than the one currently being
processed.

Previously, this logic was only present in event_active_nolock_.
Moving it to event_callback_activate_nolock_ ensures that all
callback activations (including those from bufferevent_trigger)
properly interrupt lower-priority queues, preventing starvation
during high I/O volume.
@trondn trondn force-pushed the release-2.1.12-stable-cb branch 4 times, most recently from 1767058 to 12525b7 Compare May 26, 2026 14:01
trondn and others added 3 commits May 27, 2026 13:04
Add the /.idea/ directory to .gitignore to prevent local IDE-specific
project configurations, caches, and developer profiles from being
accidentally tracked in the repository.
Under OpenSSL 3.0+, unexpected socket closures before a clean SSL/TLS
shutdown alert is exchanged are classified as protocol errors rather than
clean EOFs. This behavior change causes various regression tests to fail.

To resolve these compatibility issues:
1. bufferevent_openssl.c: Identify the SSL_R_UNEXPECTED_EOF_WHILE_READING
   protocol error and treat it as a dirty shutdown (clean TCP closure) to
   ensure backward compatibility.
2. test/regress_http.c (https_bev): Enable 'allow_dirty_shutdown = 1'
   on server bufferevents inside the mock HTTPS server to cleanly handle
   abrupt client socket closures.
3. test/regress_http.c (http_incomplete_errorcb): Recognize SSL protocol
   errors arising from raw socket shutdowns on OpenSSL 3.0 as successful
   terminations during the incomplete HTTP request test.
Implement kernel-measured socket receive timestamps
with nanosecond precision on supported platforms via
recvmsg() syscall. Timestamps are stored per-chain
in the evbuffer.

Infrastructure changes:
- evbuffer-internal.h: Add timestamp storage to
  evbuffer_chain structure with validity flag
- evbuffer_read_with_timestamp(): New internal function
  for reading data with kernel timestamp parsing and
  validation, including MSG_CTRUNC and cmsg_len checks
- bufferevent-internal.h: Add recv_timestamps_enabled
  flag to bufferevent_private structure
- bufferevent_sock.c: Integrate recvmsg() wrapper for
  socket reads when BEV_OPT_RECV_TIMESTAMPS is set
- bufferevent_openssl.c: Pass timestamps from underlying
  bufferevent through SSL decryption layer in filtered
  mode via evbuffer_read_with_timestamp()
- Build system: Platform detection for SO_TIMESTAMP and
  SO_TIMESTAMPNS socket options

Public API additions:
- BEV_OPT_RECV_TIMESTAMPS flag for opt-in timestamp
  capture on socket bufferevents
- evbuffer_get_timestamp() function to retrieve stored
  timestamp with nanosecond precision
- Documentation of timestamp semantics and availability

Platform support:
- Linux 2.6.22+: nanosecond (SO_TIMESTAMPNS) and
  microsecond (SO_TIMESTAMP) precision
- macOS 10.12+: microsecond (SO_TIMESTAMP) precision

Testing: All existing tests pass. Added regress tests
for socket and SSL bufferevent timestamp functionality.

Note: This commit implements the timestamp plumbing
and storage infrastructure. Public API functions to
access timestamps are separate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@trondn trondn force-pushed the release-2.1.12-stable-cb branch from 0cff36d to 4672c46 Compare May 27, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants