@@ -213,33 +213,30 @@ while (my ($unit, $state) = each %{$activePrev}) {
213213 elsif (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes") || boolIsTrue($unitInfo->{'RefuseManualStop'} // "no") ) {
214214 $unitsToSkip{$unit} = 1;
215215 } else {
216− # If this unit is socket-activated, then stop the
217− # socket unit(s) as well, and restart the
218− # socket(s) instead of the service.
219− my $socketActivated = 0;
220− if ($unit =~ /\.service$/) {
221− my @sockets = split / /, ($unitInfo->{Sockets} // "");
222− if (scalar @sockets == 0) {
223− @sockets = ("$baseName.socket");
224− }
225− foreach my $socket (@sockets) {
226− if (defined $activePrev->{$socket}) {
227− $unitsToStop{$unit} = 1;
228− $unitsToStart{$unit} = 1;
229− recordUnit($startListFile, $socket);
230− $socketActivated = 1;
231− }
232− }
233− }
234−
235216 if (!boolIsTrue($unitInfo->{'X-StopIfChanged'} // "yes")) {
236−
237217 # This unit should be restarted instead of
238218 # stopped and started.
239219 $unitsToRestart{$unit} = 1;
240220 recordUnit($restartListFile, $unit);
241−
242221 } else {
222+ # If this unit is socket-activated, then stop the
223+ # socket unit(s) as well, and restart the
224+ # socket(s) instead of the service.
225+ my $socketActivated = 0;
226+ if ($unit =~ /\.service$/) {
227+ my @sockets = split / /, ($unitInfo->{Sockets} // "");
228+ if (scalar @sockets == 0) {
229+ @sockets = ("$baseName.socket");
230+ }
231+ foreach my $socket (@sockets) {
232+ if (defined $activePrev->{$socket}) {
233+ $unitsToStop{$socket} = 1;
234+ $unitsToStart{$socket} = 1;
235+ recordUnit($startListFile, $socket);
236+ $socketActivated = 1;
237+ }
238+ }
239+ }
243240
244241 # If the unit is not socket-activated, record
245242 # that this unit needs to be started below.
@@ -251,7 +248,6 @@ while (my ($unit, $state) = each %{$activePrev}) {
251248 }
252249
253250 $unitsToStop{$unit} = 1;
254−
255251 }
256252 }
257253 }