@@ -1027,40 +1027,44 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
10271027 * Faked select()
10281028 */
10291029int select (int nfds , fd_set * readfds ,
1030- fd_set * writefds ,
1031- fd_set * errorfds ,
1032- struct timeval * timeout )
1030+ fd_set * writefds ,
1031+ fd_set * errorfds ,
1032+ struct timeval * timeout )
10331033{
10341034 int ret ;
10351035 struct timeval timeout_real ;
10361036
1037- if (user_rate_set && !dont_fake && (timeout -> tv_sec > 0 || timeout -> tv_usec > 0 ))
1038- {
1039- struct timespec ts ;
1040-
1041- ts .tv_sec = timeout -> tv_sec ;
1042- ts .tv_nsec = timeout -> tv_usec * 1000 ;
1043-
1044- timespecmul (& ts , 1.0 / user_rate , & ts );
1045-
1046- timeout_real .tv_sec = ts .tv_sec ;
1047- timeout_real .tv_usec = ts .tv_nsec / 1000 ;
1048- }
1049- else
1050- {
1051- timeout_real .tv_sec = timeout -> tv_sec ;
1052- timeout_real .tv_usec = timeout -> tv_usec ;
1053- }
1054-
10551037 if (!initialized )
10561038 {
10571039 ftpl_init ();
10581040 }
1041+
10591042 if (real_select == NULL )
10601043 {
10611044 return -1 ;
10621045 }
10631046
1047+ if (timeout != NULL )
1048+ {
1049+ if (user_rate_set && !dont_fake && (timeout -> tv_sec > 0 || timeout -> tv_usec > 0 ))
1050+ {
1051+ struct timespec ts ;
1052+
1053+ ts .tv_sec = timeout -> tv_sec ;
1054+ ts .tv_nsec = timeout -> tv_usec * 1000 ;
1055+
1056+ timespecmul (& ts , 1.0 / user_rate , & ts );
1057+
1058+ timeout_real .tv_sec = ts .tv_sec ;
1059+ timeout_real .tv_usec = ts .tv_nsec / 1000 ;
1060+ }
1061+ else
1062+ {
1063+ timeout_real .tv_sec = timeout -> tv_sec ;
1064+ timeout_real .tv_usec = timeout -> tv_usec ;
1065+ }
1066+ }
1067+
10641068 DONT_FAKE_TIME (ret = (* real_select )(nfds , readfds , writefds , errorfds , & timeout_real ));
10651069 return ret ;
10661070}
0 commit comments