fission-codes / go-car-mirror

Generic Go implementation of the CAR Mirror protocol
Apache License 2.0
4 stars 0 forks source link

Potential issues with unsetting state flags #112

Open justindotpub opened 1 year ago

justindotpub commented 1 year ago

There are potentially cases where we might try to unset a state flag while another parallel process is setting it. I've run into issues as I was refactoring session termination.

For example, if we are in SOURCE_SENDING, this means we have blocks to flush. If we flush, we will be unsetting SOURCE_SENDING afterward. However, it is possible that concurrently another request comes in and we start queueing up blocks to send.

In theory the condvar wait logic would prevent us from getting in these bad scenarios, but it is really hard to keep track of this, and if we end up supporting more parallel requests for example, we might need to just switch away from this approach entirely and use some other kind of counter based approach.

ETA: 2023-10-31