Skip to content

Commit 6ee52b0

Browse files
committed
[Driver/Java] Do not re-resolve control/endpoint addresses if the corresponding endpoint is not active.
In case of an endpoint being closed (e.g. publication is removed) all outstanding re-resolution requests should be ignored.
1 parent b07f7b5 commit 6ee52b0

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,20 @@ void onPublicationError(
439439
void onReResolveEndpoint(
440440
final String endpoint, final SendChannelEndpoint channelEndpoint, final InetSocketAddress address)
441441
{
442+
if (!channelEndpoint.isActive())
443+
{
444+
return;
445+
}
446+
442447
executeAsyncTask(
443448
() -> UdpChannel.resolve(endpoint, ENDPOINT_PARAM_NAME, true, nameResolver),
444449
(asyncResult) ->
445450
{
451+
if (!channelEndpoint.isActive())
452+
{
453+
return;
454+
}
455+
446456
try
447457
{
448458
final InetSocketAddress newAddress = asyncResult.get();
@@ -468,10 +478,20 @@ void onReResolveControl(
468478
final ReceiveChannelEndpoint channelEndpoint,
469479
final InetSocketAddress address)
470480
{
481+
if (!channelEndpoint.isActive())
482+
{
483+
return;
484+
}
485+
471486
executeAsyncTask(
472487
() -> UdpChannel.resolve(control, MDC_CONTROL_PARAM_NAME, true, nameResolver),
473488
(asyncResult) ->
474489
{
490+
if (!channelEndpoint.isActive())
491+
{
492+
return;
493+
}
494+
475495
try
476496
{
477497
final InetSocketAddress newAddress = asyncResult.get();

aeron-driver/src/main/java/io/aeron/driver/media/ReceiveChannelEndpoint.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ public void closeIndicators()
288288
}
289289
}
290290

291+
/**
292+
* Checks if an endpoint is still active, i.e. not being closed.
293+
*
294+
* @return {@code true} if active.
295+
*/
296+
public boolean isActive()
297+
{
298+
return !statusIndicator.isClosed() && ChannelEndpointStatus.ACTIVE == statusIndicator.get();
299+
}
300+
291301
/**
292302
* Close transports for {@link MultiRcvDestination} if present.
293303
*

aeron-driver/src/main/java/io/aeron/driver/media/SendChannelEndpoint.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ public void closeIndicators()
225225
CloseHelper.close(mdcDestinationsCounter);
226226
}
227227

228+
/**
229+
* Checks if an endpoint is still active, i.e. not being closed.
230+
*
231+
* @return {@code true} if active.
232+
*/
233+
public boolean isActive()
234+
{
235+
return !statusIndicator.isClosed() && ChannelEndpointStatus.ACTIVE == statusIndicator.get();
236+
}
237+
228238
/**
229239
* Called by to determine if the channel endpoint should be closed.
230240
*

0 commit comments

Comments
 (0)