-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
A-networkC-assignedThere is someone working on resolving the issueThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
Description
Right now it is possible to "cancel" a network request by freeing the Receiver that corresponds to the network response (ie. when the Receiver goes out of scope), since that causes the network thread to panic when it tries to send on the closed channel. This won't be enough when we move to an event-based system instead of using channels - the network thread will just keep sending events to the target thread, and the target thread has no way to inform the network thread that the response is not wanted.
I propose the following:
- create a new
ResourceIdtype that wraps an integer - add a new optional
Sender<ResourceId>argument to theLoadmessage inControlMsginresource_task.rs - in the load handler for
ResourceTask, generate a new resource id for each load that requires it, and send it on the providedSenderif it exists - for loads with a resource id, create a new channel and store the sender in a vector in
ResourceTask, and pass the receiver to the loader factory - in each loader implementation, use the new optional receiver to check if a load is supposed to be cancelled at key points (after headers are received and before each read of the response)
- add a new
Cancelmessage toControlMsginresource_task.rswhich takes aResourceId, finds the corresponding entry in the vector and sends a message on corresponding termination sender
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-networkC-assignedThere is someone working on resolving the issueThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issVariable effort required; may require a mentor. Recommended solution is clearly described in the iss