Netty

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates

Changeset {id} does not exist.

Don't use timerfd for epollWaitTimeboxed()

    • -41
    • +16
    /transport-native-epoll/src/main/c/netty_epoll_native.c
Allow domain sockets to configure SO_SNDBUF and SO_RCVBUF (#9584)

Motivation:

Running tests with a `KQueueDomainSocketChannel` showed worse performance than an `NioSocketChannel`. It turns out that the default send buffer size for Nio sockets is 64k while for KQueue sockets it's 8k. I verified that manually setting the socket's send buffer size improved perf to expected levels.

Modification:

Plumb the `SO_SNDBUF` and `SO_RCVBUF` options into the `*DomainSocketChannelConfig`.

Result:

Can now configure send and receive buffer sizes for domain sockets.

Allow domain sockets to configure SO_SNDBUF and SO_RCVBUF (#9584)

Motivation:

Running tests with a `KQueueDomainSocketChannel` showed worse performance than an `NioSocketChannel`. It turns out that the default send buffer size for Nio sockets is 64k while for KQueue sockets it's 8k. I verified that manually setting the socket's send buffer size improved perf to expected levels.

Modification:

Plumb the `SO_SNDBUF` and `SO_RCVBUF` options into the `*DomainSocketChannelConfig`.

Result:

Can now configure send and receive buffer sizes for domain sockets.

Use volatile store to reset wakenUp field; add log for missed evfd write

Optimize the QueryStringEncoder performance (#9568)

Motivation:

Optimize the QueryStringEncoder for lower memory overhead and higher encode speed.

Modification:

Encode the space to + directly, and reuse the uriStringBuilder rather then create a new one.

Result:

Improved performance

Optimize the QueryStringEncoder performance (#9568)

Motivation:

Optimize the QueryStringEncoder for lower memory overhead and higher encode speed.

Modification:

Encode the space to + directly, and reuse the uriStringBuilder rather then create a new one.

Result:

Improved performance

Correctly handle whitespaces in HTTP header names as defined by RFC7230#section-3.2.4 (#9585)

Motivation:

When parsing HTTP headers special care needs to be taken when a whitespace is detected in the header name.

Modifications:

- Ignore whitespace when decoding response (just like before)

- Throw exception when whitespace is detected during parsing

- Add unit tests

Result:

Fixes https://github.com/netty/netty/issues/9571

Correctly handle whitespaces in HTTP header names as defined by RFC7230#section-3.2.4 (#9585)

Motivation:

When parsing HTTP headers special care needs to be taken when a whitespace is detected in the header name.

Modifications:

- Ignore whitespace when decoding response (just like before)

- Throw exception when whitespace is detected during parsing

- Add unit tests

Result:

Fixes https://github.com/netty/netty/issues/9571

WIP

Close eventfd shutdown/wakeup race by closely tracking epoll edges

Motivation

This is another iteration of #9476.

Modifications

Instead of maintaining a count of all writes performed and then using

reads during shutdown to ensure all are accounted for, just set a flag

after each write and don't reset it until the corresponding event has

been returned from epoll_wait.

This requires that while a write is still pending we don't reset

wakenUp, i.e. continue to block writes from the wakeup() method.

Result

Race condition eliminated. Fixes #9362

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

FIX : Unpacking causes socks5proxy init failure (#9582)

Motivation:

Socks5InitialRequestDecoder does not correctly handle fragmentation

Modifications:

- Delete detection of not enough bytes as ReplyingDecoder already handles all of this correctly.

- Add unit test

Result:

Fixes #9574.

FIX : Unpacking causes socks5proxy init failure (#9582)

Motivation:

Socks5InitialRequestDecoder does not correctly handle fragmentation

Modifications:

- Delete detection of not enough bytes as ReplyingDecoder already handles all of this correctly.

- Add unit test

Result:

Fixes #9574.

Correctly handle whitespaces in HTTP header names as defined by RFC7230#section-3.2.4

Motivation:

When parsing HTTP headers special care needs to be taken when a whitespace is detected in the header name.

Modifications:

- Ignore whitespace when decoding response (just like before)

- Throw exception when whitespace is detected during parsing

- Add unit tests

Result:

Fixes https://github.com/netty/netty/issues/9571

Epoll: Avoid redundant EPOLL_CTL_MOD calls (#9397) (#9583)

Motivation

Currently an epoll_ctl syscall is made every time there is a change to

the event interest flags (EPOLLIN, EPOLLOUT, etc) of a channel. These

are only done in the event loop so can be aggregated into 0 or 1 such

calls per channel prior to the next call to epoll_wait.

Modifications

I think further streamlining/simplification is possible but for now I've

tried to minimize structural changes and added the aggregation beneath

the existing flag manipulation logic.

A new AbstractChannel#activeFlags field records the flags last set on

the epoll fd for that channel. Calls to setFlag/clearFlag update the

flags field as before but instead of calling epoll_ctl immediately, just

set or clear a bit for the channel in a new bitset in the associated

EpollEventLoop to reflect whether there's any change to the last set

value.

Prior to calling epoll_wait the event loop makes the appropriate

epoll_ctl(EPOLL_CTL_MOD) call once for each channel who's bit is set.

Result

Fewer syscalls, particularly in some auto-read=false cases. Simplified

error handling from centralization of these calls.

Fix a bug introduced by 79706357c73ded02615d0445db7503b646ff9547 which can cause thread to spin in an infinite loop. (#9579)

Motivation:

peek() is implemented in a similar way to poll() for the mpsc queue, thus it is more like a consumer call.

It is possible that we could have multiple thread call peek() and possibly one thread calls poll() at at the same time.

This lead to multiple consumer scenario, which violates the multiple producer single consumer condition and could lead to spin in an infinite loop in peek()

Modification:

Use isEmpty() instead of peek() to check if task queue is empty

Result:

Dont violate the mpsc semantics.

Fix a bug introduced by 79706357c73ded02615d0445db7503b646ff9547 which can cause thread to spin in an infinite loop. (#9579)

Motivation:

peek() is implemented in a similar way to poll() for the mpsc queue, thus it is more like a consumer call.

It is possible that we could have multiple thread call peek() and possibly one thread calls poll() at at the same time.

This lead to multiple consumer scenario, which violates the multiple producer single consumer condition and could lead to spin in an infinite loop in peek()

Modification:

Use isEmpty() instead of peek() to check if task queue is empty

Result:

Dont violate the mpsc semantics.

Correctly reset cached local and remote address when disconnect() is called (#9545)

Motivation:

We should correctly reset the cached local and remote address when a Channel.disconnect() is called and the channel has a notion of disconnect vs close (for example DatagramChannel implementations).

Modifications:

- Correctly reset cached kicak abd remote address

- Update testcase to cover it and so ensure all transports work in a consistent way

Result:

Correctly handle disconnect()

Correctly reset cached local and remote address when disconnect() is called (#9545)

Motivation:

We should correctly reset the cached local and remote address when a Channel.disconnect() is called and the channel has a notion of disconnect vs close (for example DatagramChannel implementations).

Modifications:

- Correctly reset cached kicak abd remote address

- Update testcase to cover it and so ensure all transports work in a consistent way

Result:

Correctly handle disconnect()

No need to explicit use the AccessController when SystemPropertyUtil is used (#9577)

Motivation:

SystemPropertyUtil already uses the AccessController internally so not need to wrap its usage with AccessController as well.

Modifications:

Remove explicit AccessController usage when SystemPropertyUtil is used.

Result:

Code cleanup

No need to explicit use the AccessController when SystemPropertyUtil is used (#9577)

Motivation:

SystemPropertyUtil already uses the AccessController internally so not need to wrap its usage with AccessController as well.

Modifications:

Remove explicit AccessController usage when SystemPropertyUtil is used.

Result:

Code cleanup

Correctly handle task offloading when using BoringSSL / OpenSSL (#9575)

Motivation:

We did not correctly handle taskoffloading when using BoringSSL / OpenSSL. This could lead to the situation that we did not write the SSL alert out for the remote peer before closing the connection.

Modifications:

- Correctly handle exceptions when we resume processing on the EventLoop after the task was offloadded

- Ensure we call SSL.doHandshake(...) to flush the alert out to the outboundbuffer when an handshake exception was detected

- Correctly signal back the need to call WRAP again when a handshake exception is pending. This will ensure we flush out the alert in all cases.

Result:

No more failures when task offloading is used.

Correctly handle task offloading when using BoringSSL / OpenSSL (#9575)

Motivation:

We did not correctly handle taskoffloading when using BoringSSL / OpenSSL. This could lead to the situation that we did not write the SSL alert out for the remote peer before closing the connection.

Modifications:

- Correctly handle exceptions when we resume processing on the EventLoop after the task was offloadded

- Ensure we call SSL.doHandshake(...) to flush the alert out to the outboundbuffer when an handshake exception was detected

- Correctly signal back the need to call WRAP again when a handshake exception is pending. This will ensure we flush out the alert in all cases.

Result:

No more failures when task offloading is used.

Uplift scheduling-related hooks to AbstractScheduledEventExecutor

Also introduce LazyRunnable and AbstractEventExecutor#lazyExecute

No need to explicit use the AccessController when SystemPropertyUtil is used

Motivation:

SystemPropertyUtil already uses the AccessController internally so not need to wrap its usage with AccessController as well.

Modifications:

Remove explicit AccessController usage when SystemPropertyUtil is used.

Result:

Code cleanup

run tests with useTasks as well

run tests with useTasks as well

Correctly handle task offloading when using BoringSSL / OpenSSL

Motivation:

We did not correctly handle taskoffloading when using BoringSSL / OpenSSL. This could lead to the situation that we did not write the SSL alert out for the remote peer before closing the connection.

Modifications:

- Correctly handle exceptions when we resume processing on the EventLoop after the task was offloadded

- Ensure we call SSL.doHandshake(...) to flush the alert out to the outboundbuffer when an handshake exception was detected

- Correctly signal back the need to call WRAP again when a handshake exception is pending. This will ensure we flush out the alert in all cases.

Result:

No more failures when task offloading is used.

Correctly synchronize before trying to set key material to fix possible native crash (#9566)

Motivation:

When using io.netty.handler.ssl.openssl.useTasks=true we may call ReferenceCountedOpenSslEngine.setKeyMaterial(...) from another thread and so need to synchronize and also check if the engine was destroyed in the meantime to eliminate of the possibility of a native crash.

The same is try when trying to access the authentication methods.

Modification:

- Add synchronized and isDestroyed() checks where missing

- Add null checks for the case when a callback is executed by another thread after the engine was destroyed already

- Move code for master key extraction to ReferenceCountedOpenSslEngine to ensure there can be no races.

Result:

No native crash possible anymore when using io.netty.handler.ssl.openssl.useTasks=true

Correctly synchronize before trying to set key material to fix possible native crash (#9566)

Motivation:

When using io.netty.handler.ssl.openssl.useTasks=true we may call ReferenceCountedOpenSslEngine.setKeyMaterial(...) from another thread and so need to synchronize and also check if the engine was destroyed in the meantime to eliminate of the possibility of a native crash.

The same is try when trying to access the authentication methods.

Modification:

- Add synchronized and isDestroyed() checks where missing

- Add null checks for the case when a callback is executed by another thread after the engine was destroyed already

- Move code for master key extraction to ReferenceCountedOpenSslEngine to ensure there can be no races.

Result:

No native crash possible anymore when using io.netty.handler.ssl.openssl.useTasks=true

Correctly synchronize before trying to set key material to fix possible native crash

Motivation:

When using io.netty.handler.ssl.openssl.useTasks=true we may call ReferenceCountedOpenSslEngine.setKeyMaterial(...) from another thread and so need to synchronize and also check if the engine was destroyed in the meantime to eliminate of the possibility of a native crash.

The same is try when trying to access the authentication methods.

Modification:

- Add synchronized and isDestroyed() checks where missing

- Add null checks for the case when a callback is executed by another thread after the engine was destroyed already

- Move code for master key extraction to ReferenceCountedOpenSslEngine to ensure there can be no races.

Result:

No native crash possible anymore when using io.netty.handler.ssl.openssl.useTasks=true