Skip to content

Commit 7599df4

Browse files
krynjuKristofferC
authored andcommitted
add direct return of v_local
(cherry picked from commit 4b97df7)
1 parent 2fa46e6 commit 7599df4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

stdlib/Distributed/src/remotecall.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,15 @@ function fetch(r::Future)
634634
# why? local put! performs caching and putting into channel under r.lock
635635

636636
# 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
637-
v_cache = status ? v_local : v_old
637+
638+
# remote calls getting the value from `call_on_owner` used to return the value directly without wrapping it in `Some(x)`
639+
# so we're doing the same thing here
640+
if status
641+
send_del_client(r)
642+
return v_local
643+
else # this `v_cache` is returned at the end of the function
644+
v_cache = v_old
645+
end
638646
end
639647

640648
send_del_client(r)

stdlib/Distributed/test/distributed_exec.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,16 @@ v15406 = remotecall_wait(() -> 1, id_other)
841841
fetch(v15406)
842842
remotecall_wait(fetch, id_other, v15406)
843843

844+
845+
# issue #43396
846+
# Covers the remote fetch where the value returned is `nothing`
847+
# May be caused by attempting to unwrap a non-`Some` type with `something`
848+
# `call_on_owner` ref fetches return values not wrapped in `Some`
849+
# and have to be returned directly
850+
@test nothing === fetch(remotecall(() -> nothing, workers()[1]))
851+
@test 10 === fetch(remotecall(() -> 10, workers()[1]))
852+
853+
844854
# Test various forms of remotecall* invocations
845855

846856
@everywhere f_args(v1, v2=0; kw1=0, kw2=0) = v1+v2+kw1+kw2

0 commit comments

Comments
 (0)