Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select used as sleep does not work #74

Open
cwmos opened this issue Apr 19, 2018 · 1 comment
Open

select used as sleep does not work #74

cwmos opened this issue Apr 19, 2018 · 1 comment

Comments

@cwmos
Copy link

cwmos commented Apr 19, 2018

Some programs call select without any file descriptors as a sleep. This does not work with DCE. The following patch fixes this by calling Wait i this case:

diff --git a/model/dce-poll.cc b/model/dce-poll.cc
index 0cac665..9f5f728 100644
--- a/model/dce-poll.cc
+++ b/model/dce-poll.cc
@@ -128,11 +128,6 @@ int dce_poll (struct pollfd *fds, nfds_t nfds, int timeout)
   return count;
 }
 
-int dce___poll_chk (struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen)
-{
-  return dce_poll(fds, nfds, timeout);
-}
-
 int dce_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
                 struct timeval *timeout)
 {
@@ -146,18 +141,25 @@ int dce_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
       current->err = EINVAL;
       return -1;
     }
-  if (readfds == 0 && writefds == 0 && exceptfds == 0)
+  if (timeout)
+  {
+    if (timeout->tv_sec < 0 || timeout->tv_usec < 0)
     {
       current->err = EINVAL;
       return -1;
     }
-  if (timeout)
+  }
+  if (readfds == 0 && writefds == 0 && exceptfds == 0)
     {
-      if (timeout->tv_sec < 0 || timeout->tv_usec < 0)
+      if(!timeout) {
         {
           current->err = EINVAL;
           return -1;
         }
+      }
+      Time sleepTime = UtilsTimevalToTime(*timeout);
+      current->process->manager->Wait(sleepTime);
+      return 0;
     }
   for (int fd = 0; fd < nfds; fd++)
     {

Please let me know if I should make a pull request (I did not seem to have access to do this).

@teto
Copy link
Member

teto commented Apr 24, 2018

looks ok. What program do you have in mind that exhibits such behavior ? feel free to open the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants