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 · netty/netty@e5455d3

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
@@ -230,41 +230,45 @@ protected void deallocate() {
230230
this.jdkCompatibilityMode = jdkCompatibilityMode;
231231
Lock readerLock = context.ctxLock.readLock();
232232
readerLock.lock();
233+
final long finalSsl;
233234
try {
234-
ssl = SSL.newSSL(context.ctx, !context.isClient());
235+
finalSsl = SSL.newSSL(context.ctx, !context.isClient());
235236
} finally {
236237
readerLock.unlock();
237238
}
238-
try {
239-
networkBIO = SSL.bioNewByteBuffer(ssl, context.getBioNonApplicationBufferSize());
239+
synchronized (this) {
240+
ssl = finalSsl;
241+
try {
242+
networkBIO = SSL.bioNewByteBuffer(ssl, context.getBioNonApplicationBufferSize());
240243

241-
// Set the client auth mode, this needs to be done via setClientAuth(...) method so we actually call the
242-
// needed JNI methods.
243-
setClientAuth(clientMode ? ClientAuth.NONE : context.clientAuth);
244+
// Set the client auth mode, this needs to be done via setClientAuth(...) method so we actually call the
245+
// needed JNI methods.
246+
setClientAuth(clientMode ? ClientAuth.NONE : context.clientAuth);
244247

245-
if (context.protocols != null) {
246-
setEnabledProtocols(context.protocols);
247-
}
248+
if (context.protocols != null) {
249+
setEnabledProtocols(context.protocols);
250+
}
248251

249-
// Use SNI if peerHost was specified
250-
// See https://github.com/netty/netty/issues/4746
251-
if (clientMode && peerHost != null) {
252-
SSL.setTlsExtHostName(ssl, peerHost);
253-
}
252+
// Use SNI if peerHost was specified
253+
// See https://github.com/netty/netty/issues/4746
254+
if (clientMode && peerHost != null) {
255+
SSL.setTlsExtHostName(ssl, peerHost);
256+
}
254257

255-
if (enableOcsp) {
256-
SSL.enableOcsp(ssl);
257-
}
258+
if (enableOcsp) {
259+
SSL.enableOcsp(ssl);
260+
}
258261

259-
if (!jdkCompatibilityMode) {
260-
SSL.setMode(ssl, SSL.getMode(ssl) | SSL.SSL_MODE_ENABLE_PARTIAL_WRITE);
261-
}
262+
if (!jdkCompatibilityMode) {
263+
SSL.setMode(ssl, SSL.getMode(ssl) | SSL.SSL_MODE_ENABLE_PARTIAL_WRITE);
264+
}
262265

263-
// setMode may impact the overhead.
264-
calculateMaxWrapOverhead();
265-
} catch (Throwable cause) {
266-
SSL.freeSSL(ssl);
267-
PlatformDependent.throwException(cause);
266+
// setMode may impact the overhead.
267+
calculateMaxWrapOverhead();
268+
} catch (Throwable cause) {
269+
SSL.freeSSL(ssl);
270+
PlatformDependent.throwException(cause);
271+
}
268272
}
269273
}
270274

0 commit comments

Comments
0 (0)
You are visitor 01402792 — 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.