@@ -245,7 +245,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
245
245
running_on(-1 ),
246
246
pinned_on(-1 ),
247
247
local_region(&sched->srv->local_region),
248
- failed (false ),
248
+ unwinding (false ),
249
249
killed(false ),
250
250
propagate_failure(true ),
251
251
dynastack(this ),
@@ -299,27 +299,27 @@ struct spawn_args {
299
299
300
300
struct cleanup_args {
301
301
spawn_args *spargs;
302
- bool failed ;
302
+ bool threw_exception ;
303
303
};
304
304
305
305
void
306
306
cleanup_task (cleanup_args *args) {
307
307
spawn_args *a = args->spargs ;
308
- bool failed = args->failed ;
308
+ bool threw_exception = args->threw_exception ;
309
309
rust_task *task = a->task ;
310
310
311
311
cc::do_cc (task);
312
312
313
313
task->die ();
314
314
315
- if (task->killed && !failed ) {
315
+ if (task->killed && !threw_exception ) {
316
316
LOG (task, task, " Task killed during termination" );
317
- failed = true ;
317
+ threw_exception = true ;
318
318
}
319
319
320
- task->notify (!failed );
320
+ task->notify (!threw_exception );
321
321
322
- if (failed ) {
322
+ if (threw_exception ) {
323
323
#ifndef __WIN32__
324
324
task->conclude_failure ();
325
325
#else
@@ -336,15 +336,15 @@ void task_start_wrapper(spawn_args *a)
336
336
{
337
337
rust_task *task = a->task ;
338
338
339
- bool failed = false ;
339
+ bool threw_exception = false ;
340
340
try {
341
341
// The first argument is the return pointer; as the task fn
342
342
// must have void return type, we can safely pass 0.
343
343
a->f (0 , a->envptr , a->argptr );
344
344
} catch (rust_task *ex) {
345
345
A (task->sched , ex == task,
346
346
" Expected this task to be thrown for unwinding" );
347
- failed = true ;
347
+ threw_exception = true ;
348
348
}
349
349
350
350
rust_opaque_closure* env = a->envptr ;
@@ -357,7 +357,7 @@ void task_start_wrapper(spawn_args *a)
357
357
}
358
358
359
359
// The cleanup work needs lots of stack
360
- cleanup_args ca = {a, failed };
360
+ cleanup_args ca = {a, threw_exception };
361
361
task->sched ->c_context .call_shim_on_c_stack (&ca, (void *)cleanup_task);
362
362
363
363
task->ctx .next ->swap (task->ctx );
@@ -437,11 +437,17 @@ rust_task::kill() {
437
437
// run_on_resume(rust_unwind_glue);
438
438
}
439
439
440
+ extern " C" CDECL
441
+ bool rust_task_is_unwinding (rust_task *rt) {
442
+ return rt->unwinding ;
443
+ }
444
+
440
445
void
441
446
rust_task::fail () {
442
447
// See note in ::kill() regarding who should call this.
443
448
DLOG (sched, task, " task %s @0x%" PRIxPTR " failing" , name, this );
444
449
backtrace ();
450
+ unwinding = true ;
445
451
#ifndef __WIN32__
446
452
throw this ;
447
453
#else
@@ -455,7 +461,6 @@ rust_task::fail() {
455
461
void
456
462
rust_task::conclude_failure () {
457
463
fail_parent ();
458
- failed = true ;
459
464
}
460
465
461
466
void
0 commit comments