- /* return approximate time left in milliseconds */
- if (timeleft)
- *timeleft = milliseconds;
-
- T(("end twait: returned %d (%d), remaining time %d msec",
- result, errno, milliseconds));
-
- /*
- * Both 'poll()' and 'select()' return the number of file descriptors
- * that are active. Translate this back to the mask that denotes which
- * file-descriptors, so that we don't need all of this system-specific
- * code everywhere.
- */
- if (result != 0) {
- if (result > 0) {
- result = 0;
+#if PRECISE_GETTIME && HAVE_NANOSLEEP
+ /*
+ * If the timeout hasn't expired, and we've gotten no data,
+ * this is probably a system where 'select()' needs to be left
+ * alone so that it can complete. Make this process sleep,
+ * then come back for more.
+ */
+ if (result == 0 && milliseconds > 100) {
+ napms(100); /* FIXME: this won't be right if I recur! */
+ milliseconds -= 100;
+ goto retry;
+ }
+#endif
+
+ /* return approximate time left in milliseconds */
+ if (timeleft)
+ *timeleft = milliseconds;
+
+ TR(TRACE_IEVENT, ("end twait: returned %d (%d), remaining time %d msec",
+ result, errno, milliseconds));
+
+ /*
+ * Both 'poll()' and 'select()' return the number of file descriptors
+ * that are active. Translate this back to the mask that denotes which
+ * file-descriptors, so that we don't need all of this system-specific
+ * code everywhere.
+ */
+ if (result != 0) {
+ if (result > 0) {
+ result = 0;