tst->proxy = NULL;
}
- /* Create a proxy for calling thread
-
- We need to temporarily set the state back to Runnable for
- proxy_create's benefit.
+ /* Create a proxy for calling thread.
+
+ Since fork() is non-blocking, the thread status should already
+ be Runnable.
*/
+ vg_assert(VG_(is_valid_tid)(tid));
+ vg_assert(VG_(threads)[tid].proxy == NULL);
+ vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
- {
- ThreadState *tst = VG_(get_ThreadState)(tid);
-
- vg_assert(tst->proxy == NULL);
- vg_assert(tst->status == VgTs_WaitSys);
- tst->status = VgTs_Runnable;
- VG_(proxy_create)(tid);
- VG_(proxy_setsigmask)(tid);
- tst->status = VgTs_WaitSys;
- }
+ VG_(proxy_create)(tid);
+ VG_(proxy_setsigmask)(tid);
}
Int VG_(proxy_resfd)(void)
signal, or the syscall completed normally. In either case
eax contains the correct syscall return value, and the new
state is effectively PXS_SysDone. */
- vg_assert(px->state == PXS_RunSyscall || px->state == PXS_SysDone);
+ vg_assert(px->state == PXS_RunSyscall ||
+ px->state == PXS_SysDone);
px->state = PXS_SysDone;
px->tst->m_eax = eax;
}
anything - just pretend the syscall happened. */
syscall_done = True;
} else if (sys->may_block) {
- /* issue to worker */
+ /* Issue to worker. If we're waiting on the syscall because
+ it's in the hands of the ProxyLWP, then set the thread
+ state to WaitSys. */
+ tst->status = VgTs_WaitSys;
VG_(sys_issue)(tid);
} else {
/* run the syscall directly */
VGP_POPCC(VgpCoreSysWrap);
- /* If we're waiting on the syscall because it's in the hands of the
- ProxyLWP, then set the thread state to WaitSys. */
- if (!syscall_done)
- tst->status = VgTs_WaitSys;
+ vg_assert(( syscall_done && tst->status == VgTs_Runnable) ||
+ (!syscall_done && tst->status == VgTs_WaitSys ));
return syscall_done;
}