Removed unnecessary lock and check if TaskEnded when checking if for DiscoveryReply

The EmitDiscoverySignalTask may have ended from a previous packet in the datagram if max discovery replies already reached.