GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix Race in ReferenceCountedOpenSslEngine · pulllock/netty@f13bc9a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler/src/main/java/io/netty/handler/ssl
    • ReferenceCountedOpenSslEngine.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java
+29-25Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -221,41 +221,45 @@ protected void deallocate() {
221221
this.jdkCompatibilityMode = jdkCompatibilityMode;
222222
Lock readerLock = context.ctxLock.readLock();
223223
readerLock.lock();
224+
final long finalSsl;
224225
try {
225-
ssl = SSL.newSSL(context.ctx, !context.isClient());
226+
finalSsl = SSL.newSSL(context.ctx, !context.isClient());
226227
} finally {
227228
readerLock.unlock();
228229
}
229-
try {
230-
networkBIO = SSL.bioNewByteBuffer(ssl, context.getBioNonApplicationBufferSize());
230+
synchronized (this) {
231+
ssl = finalSsl;
232+
try {
233+
networkBIO = SSL.bioNewByteBuffer(ssl, context.getBioNonApplicationBufferSize());
231234

232-
// Set the client auth mode, this needs to be done via setClientAuth(...) method so we actually call the
233-
// needed JNI methods.
234-
setClientAuth(clientMode ? ClientAuth.NONE : context.clientAuth);
235+
// Set the client auth mode, this needs to be done via setClientAuth(...) method so we actually call the
236+
// needed JNI methods.
237+
setClientAuth(clientMode ? ClientAuth.NONE : context.clientAuth);
235238

236-
if (context.protocols != null) {
237-
setEnabledProtocols(context.protocols);
238-
}
239+
if (context.protocols != null) {
240+
setEnabledProtocols(context.protocols);
241+
}
239242

240-
// Use SNI if peerHost was specified
241-
// See https://github.com/netty/netty/issues/4746
242-
if (clientMode && peerHost != null) {
243-
SSL.setTlsExtHostName(ssl, peerHost);
244-
}
243+
// Use SNI if peerHost was specified
244+
// See https://github.com/netty/netty/issues/4746
245+
if (clientMode && peerHost != null) {
246+
SSL.setTlsExtHostName(ssl, peerHost);
247+
}
245248

246-
if (enableOcsp) {
247-
SSL.enableOcsp(ssl);
248-
}
249+
if (enableOcsp) {
250+
SSL.enableOcsp(ssl);
251+
}
249252

250-
if (!jdkCompatibilityMode) {
251-
SSL.setMode(ssl, SSL.getMode(ssl) | SSL.SSL_MODE_ENABLE_PARTIAL_WRITE);
252-
}
253+
if (!jdkCompatibilityMode) {
254+
SSL.setMode(ssl, SSL.getMode(ssl) | SSL.SSL_MODE_ENABLE_PARTIAL_WRITE);
255+
}
253256

254-
// setMode may impact the overhead.
255-
calculateMaxWrapOverhead();
256-
} catch (Throwable cause) {
257-
SSL.freeSSL(ssl);
258-
PlatformDependent.throwException(cause);
257+
// setMode may impact the overhead.
258+
calculateMaxWrapOverhead();
259+
} catch (Throwable cause) {
260+
SSL.freeSSL(ssl);
261+
PlatformDependent.throwException(cause);
262+
}
259263
}
260264
}
261265

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.