very fast at protocol indexer with flexible filtering, xrpc queries, cursor-backed event stream, and more, built on fjall
rust fjall at-protocol atproto indexer
58
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backfill] simplify task cleanup if already running

dawn bf4fc916 9d643386

+14 -7
+14 -7
src/backfill/mod.rs
··· 111 111 } 112 112 }; 113 113 114 + // check before trying to acquire a permit so we dont acquire a permit 115 + // for no reason, the read will be cheap anyhow 114 116 if self.in_flight.contains_sync(&did) { 115 117 continue; 116 118 } 117 - let _ = self.in_flight.insert_sync(did.clone().into_static()); 118 119 119 120 let permit = match self.semaphore.clone().try_acquire_owned() { 120 121 Ok(p) => p, 121 - Err(_) => { 122 - // remove before breaking so the DID isn't permanently stuck in 123 - // in_flight with no task to clean it up 124 - self.in_flight.remove_sync(&did); 125 - break; 126 - } 122 + Err(_) => break, 127 123 }; 124 + 125 + // only mark as in flight if we can acquire a permit 126 + if self 127 + .in_flight 128 + .insert_sync(did.clone().into_static()) 129 + .is_err() 130 + { 131 + // a task is already running, weh 132 + // so we don't need this one anymore... 133 + break; 134 + } 128 135 129 136 let guard = InFlightGuard { 130 137 did: did.clone().into_static(),