Concurrent.Future->try_success() causes logging when promise already fulfilled

Imported from https://youtrack.roxen.com/issue/PIKE-177

Reported by KG Sterneberg kg@roxen.com

While testing some new archive code I got 10:33:26 : Internal server error: Promise has already been finalised. /usr/local/pike/8.0.787/lib/modules/Concurrent.pmod (f581060e):903: Concurrent->Promise(/* Concurrent->Promise(/* REP.Archive.StoryArchiver()->ArcDataField()->prepare_file("pv_web") */)->promise_factory() */)->finalise(1,,,2) /usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:926: Concurrent->Promise(/* Concurrent->Promise(/* REP.Archive.StoryArchiver()->ArcDataField()->prepare_file("pv_web") */)->promise_factory() */)->success(,,,1) base_server/roxen.pike:763: roxen()->handler_thread(14)

I wrote a separate test running not in Roxen and I still got logging when try_success() was called:

` int main(int argc, array(string) argv) { Concurrent.Promise promise = Concurrent.Promise();

Thread.Thread( lambda(Concurrent.Promise promise) { sleep(3); werror("Success!\n"); promise->try_success("hej hopp"); }, promise);

Concurrent.Future future = promise->future()->timeout(1);

future = future->recover_with(lambda(mixed value) { return Concurrent.resolve( ([ "failure" : value ]) ); });

future->on_success(lambda(mixed result) { werror("TRACE: got result: %O\n", result); });

return -1; // return 0; } `

Output: `

./tmp.pike TRACE: got result: ([ /* 1 element / "failure": ({ / 2 elements / "Timeout.\n", ({ / 3 elements / backtrace_frame(/usr/local/pike/8.0.787/lib/master.pike:3634, _main(), Args: 1), backtrace_frame(/Users/kg/dev/learning/pike/tmp.pike:21, main(), Args: 2), backtrace_frame(/usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:677, timeout(), Args: 1) }) }) ]) Success! Promise has already been finalised. /usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:903: Concurrent.Promise(rejection_reported,({ / 2 elements / "Timeout.\n", ({ / 3 elements / backtrace_frame(/usr/local/pike/8.0.787/lib/master.pike:3634, _main(), Args: 1), backtrace_frame(/Users/kg/dev/learning/pike/tmp.pike:21, main(), Args: 2), backtrace_frame(/usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:677, timeout(), Args: 1) }) }))->finalise(1,"hej hopp",UNDEFINED,UNDEFINED) /usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:926: Concurrent.Promise(rejection_reported,({ / 2 elements / "Timeout.\n", ({ / 3 elements */ backtrace_frame(/usr/local/pike/8.0.787/lib/master.pike:3634, _main(), Args: 1), backtrace_frame(/Users/kg/dev/learning/pike/tmp.pike:21, main(), Args: 2), backtrace_frame(/usr/local/pike/8.0.787/lib/modules/Concurrent.pmod:677, timeout(), Args: 1) }) }))->success("hej hopp",UNDEFINED) -:1: Pike.Backend(0)->()(3600.0)

Pike version Pike v8.0 release 787 running Hilfe v3.5 (Incremental Pike Frontend)