A town which has paid the owner of sheep for the killing or maiming of them by dogs may recover of the owner of the dogs the actual damage caused thereby. In an action by a town against the owner of a dog to recover the damages it has paid to an agister of sheep which were injured by the dog, justice may require the joining of the owner of the sheep, or the filing of a release by him, to prevent further litigation.