From 4b97df7647b40a16cf85466d8d0afa090ef1b38a Mon Sep 17 00:00:00 2001 From: krynju Date: Sat, 11 Dec 2021 10:34:04 +0100 Subject: [PATCH] add direct return of v_local --- stdlib/Distributed/src/remotecall.jl | 10 +++++++++- stdlib/Distributed/test/distributed_exec.jl | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/stdlib/Distributed/src/remotecall.jl b/stdlib/Distributed/src/remotecall.jl index e314df589ae2a..a8d56094b2276 100644 --- a/stdlib/Distributed/src/remotecall.jl +++ b/stdlib/Distributed/src/remotecall.jl @@ -631,7 +631,15 @@ function fetch(r::Future) # why? local put! performs caching and putting into channel under r.lock # for local put! use the cached value, for call_on_owner cases just take the v_local as it was just cached in r.v - v_cache = status ? v_local : v_old + + # remote calls getting the value from `call_on_owner` used to return the value directly without wrapping it in `Some(x)` + # so we're doing the same thing here + if status + send_del_client(r) + return v_local + else # this `v_cache` is returned at the end of the function + v_cache = v_old + end end send_del_client(r) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index fd85bca0ca511..69d9fb47eccc5 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -841,6 +841,16 @@ v15406 = remotecall_wait(() -> 1, id_other) fetch(v15406) remotecall_wait(fetch, id_other, v15406) + +# issue #43396 +# Covers the remote fetch where the value returned is `nothing` +# May be caused by attempting to unwrap a non-`Some` type with `something` +# `call_on_owner` ref fetches return values not wrapped in `Some` +# and have to be returned directly +@test nothing === fetch(remotecall(() -> nothing, workers()[1])) +@test 10 === fetch(remotecall(() -> 10, workers()[1])) + + # Test various forms of remotecall* invocations @everywhere f_args(v1, v2=0; kw1=0, kw2=0) = v1+v2+kw1+kw2