nanosleep_interval.tv_nsec = 50 * 1000 * 1000; /* 50 milliseconds */
/* It's critical here that valgrind's nanosleep implementation
is nonblocking. */
- (void)my_do_syscall2(__NR_nanosleep,
+ res = my_do_syscall2(__NR_nanosleep,
(int)(&nanosleep_interval), (int)NULL);
+ if (res == -VKI_EINTR) {
+ /* The nanosleep was interrupted by a signal. So we do the
+ same. */
+ * (__errno_location()) = EINTR;
+ return -1;
+ }
}
}
nanosleep_interval.tv_nsec = 50 * 1000 * 1000; /* 50 milliseconds */
/* It's critical here that valgrind's nanosleep implementation
is nonblocking. */
- (void)my_do_syscall2(__NR_nanosleep,
+ res = my_do_syscall2(__NR_nanosleep,
(int)(&nanosleep_interval), (int)NULL);
+ if (res == -VKI_EINTR) {
+ /* The nanosleep was interrupted by a signal. So we do the
+ same. */
+ * (__errno_location()) = EINTR;
+ return -1;
+ }
}
}
TODO sometime:
+- poll() in the vg_libpthread.c -- should it handle the nanosleep
+ being interrupted by a signal? Ditto accept?
+
- Mutex scrubbing - clearup_after_thread_exit: look for threads
blocked on mutexes held by the exiting thread, and release them
appropriately. (??)
{
Char msg_buf[100];
Bool restart_blocked_syscalls;
+ struct vki_timespec * rem;
vg_assert(VG_(is_valid_tid)(tid));
return;
}
- if (VG_(threads)[tid].status == VgTs_WaitFD
+ if (VG_(threads)[tid].status == VgTs_Sleeping
&& VG_(threads)[tid].m_eax == __NR_nanosleep) {
/* We interrupted a nanosleep(). The right thing to do is to
- write the unused time to nanosleep's second param and return
- EINTR, but I'm too lazy for that. */
+ write the unused time to nanosleep's second param, but that's
+ too much effort ... we just say that 1 nanosecond was not
+ used, and return EINTR. */
+ rem = (struct vki_timespec *)VG_(threads)[tid].m_ecx; /* arg2 */
+ if (rem != NULL) {
+ rem->tv_sec = 0;
+ rem->tv_nsec = 1;
+ }
+ SET_EAX(tid, -VKI_EINTR);
+ VG_(threads)[tid].status = VgTs_Runnable;
return;
}
nanosleep_interval.tv_nsec = 50 * 1000 * 1000; /* 50 milliseconds */
/* It's critical here that valgrind's nanosleep implementation
is nonblocking. */
- (void)my_do_syscall2(__NR_nanosleep,
+ res = my_do_syscall2(__NR_nanosleep,
(int)(&nanosleep_interval), (int)NULL);
+ if (res == -VKI_EINTR) {
+ /* The nanosleep was interrupted by a signal. So we do the
+ same. */
+ * (__errno_location()) = EINTR;
+ return -1;
+ }
}
}
TODO sometime:
+- poll() in the vg_libpthread.c -- should it handle the nanosleep
+ being interrupted by a signal? Ditto accept?
+
- Mutex scrubbing - clearup_after_thread_exit: look for threads
blocked on mutexes held by the exiting thread, and release them
appropriately. (??)
{
Char msg_buf[100];
Bool restart_blocked_syscalls;
+ struct vki_timespec * rem;
vg_assert(VG_(is_valid_tid)(tid));
return;
}
- if (VG_(threads)[tid].status == VgTs_WaitFD
+ if (VG_(threads)[tid].status == VgTs_Sleeping
&& VG_(threads)[tid].m_eax == __NR_nanosleep) {
/* We interrupted a nanosleep(). The right thing to do is to
- write the unused time to nanosleep's second param and return
- EINTR, but I'm too lazy for that. */
+ write the unused time to nanosleep's second param, but that's
+ too much effort ... we just say that 1 nanosecond was not
+ used, and return EINTR. */
+ rem = (struct vki_timespec *)VG_(threads)[tid].m_ecx; /* arg2 */
+ if (rem != NULL) {
+ rem->tv_sec = 0;
+ rem->tv_nsec = 1;
+ }
+ SET_EAX(tid, -VKI_EINTR);
+ VG_(threads)[tid].status = VgTs_Runnable;
return;
}