Skip to content

Commit

Permalink
[homekit] fix restarted on network interface change
Browse files Browse the repository at this point in the history
a regression caused during the final changes of openhab#13877

Signed-off-by: Cody Cutrer <cody@cutrer.us>
  • Loading branch information
ccutrer committed Jan 15, 2023
1 parent 2bc4490 commit 412f16c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready
private final List<HomekitServer> homekitServers = new ArrayList<>();
private final List<HomekitRoot> bridges = new ArrayList<>();
private MDNSClient mdnsClient;
private int currentStartLevel = 0;
private boolean started = false;

private final List<HomekitChangeListener> changeListeners = new ArrayList<>();

Expand Down Expand Up @@ -170,7 +170,7 @@ protected synchronized void modified(Map<String, Object> config) {
clearStorage(i);
}
stopHomekitServer();
if (currentStartLevel >= StartLevelService.STARTLEVEL_STATES) {
if (started) {
startHomekitServer();
}
} else {
Expand Down Expand Up @@ -201,6 +201,7 @@ protected synchronized void modified(Map<String, Object> config) {
@Override
public synchronized void onReadyMarkerAdded(ReadyMarker readyMarker) {
try {
started = true;
startHomekitServer();
} catch (IOException | InvalidAlgorithmParameterException e) {
logger.warn("could not initialize HomeKit bridge: {}", e.getMessage());
Expand All @@ -209,6 +210,7 @@ public synchronized void onReadyMarkerAdded(ReadyMarker readyMarker) {

@Override
public synchronized void onReadyMarkerRemoved(ReadyMarker readyMarker) {
started = false;
stopHomekitServer();
}

Expand Down Expand Up @@ -411,7 +413,7 @@ public int getInstanceCount() {
@Override
public synchronized void onChanged(final List<CidrAddress> added, final List<CidrAddress> removed) {
logger.trace("HomeKit bridge reacting on network interface changes.");
if (currentStartLevel < StartLevelService.STARTLEVEL_STATES) {
if (!started) {
return;
}
removed.forEach(i -> {
Expand Down

0 comments on commit 412f16c

Please sign in to comment.