1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 01:40:44 +00:00

use value delegate to separate value and cancel

This is a issue with the usage of context for value storage and cancell signaling. This issue will be addressed in a permanent way in v5.
This commit is contained in:
Shelikhoo 2021-06-22 12:42:20 +01:00
parent 3c17276462
commit 90b560cd75
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -49,6 +49,14 @@ func toContext(ctx context.Context, v *Instance) context.Context {
Internal API
*/
func ToBackgroundDetachedContext(ctx context.Context) context.Context {
instance := MustFromContext(ctx)
return toContext(context.Background(), instance)
return &temporaryValueDelegationFix{context.Background(), ctx}
}
type temporaryValueDelegationFix struct {
context.Context
value context.Context
}
func (t *temporaryValueDelegationFix) Value(key interface{}) interface{} {
return t.value.Value(key)
}