ipcz: Don't retry failed RouterLinkState allocs

RouterLinkState allocation can really only fail if general shared
memory allocation begins to fail. Don't keep retrying such
allocations when they fail.

Fixed: 1395657
Change-Id: Ib8b88d876d45ee68d268c225c82cd791ae22ef86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148210
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/main@{#1090489}
NOKEYCHECK=True
GitOrigin-RevId: 38c99fb3ca7ea2c8cc42217c6c8623cbe0b2977a
diff --git a/src/ipcz/router.cc b/src/ipcz/router.cc
index ea05b2a..6c9f921 100644
--- a/src/ipcz/router.cc
+++ b/src/ipcz/router.cc
@@ -1557,6 +1557,11 @@
          local_outward_peer = WrapRefCounted(&local_outward_peer),
          inward_link = WrapRefCounted(&inward_link)](
             FragmentRef<RouterLinkState> new_link_state) {
+          if (new_link_state.is_null()) {
+            // If this fails once, it's unlikely to succeed afterwards.
+            return;
+          }
+
           router->StartSelfBypassToLocalPeer(context, *local_outward_peer,
                                              *inward_link,
                                              std::move(new_link_state));
@@ -1871,6 +1876,10 @@
         [router = WrapRefCounted(this), requestor = WrapRefCounted(&requestor),
          node_link = WrapRefCounted(&node_link), context,
          bypass_target_sublink](FragmentRef<RouterLinkState> new_link_state) {
+          if (!new_link_state.is_null()) {
+            // If this fails once, it's unlikely to succeed afterwards.
+            return;
+          }
           router->BypassPeerWithNewRemoteLink(context, *requestor, *node_link,
                                               bypass_target_sublink,
                                               std::move(new_link_state));