aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2002-06-10 18:38:08 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2002-06-10 18:38:08 +0000
commit5a92c17d8534e7ac762de1bd6b825039f71099f3 (patch)
tree1d0d51b3ab1571d40b2f19d7628859b97235de4c /src
parent8f05082f77a5bf612291de593f63e09e7fb3a5cb (diff)
downloadluasocket-5a92c17d8534e7ac762de1bd6b825039f71099f3.tar.gz
luasocket-5a92c17d8534e7ac762de1bd6b825039f71099f3.tar.bz2
luasocket-5a92c17d8534e7ac762de1bd6b825039f71099f3.zip
Corrigido bug no select.
Diffstat (limited to 'src')
-rw-r--r--src/luasocket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/luasocket.c b/src/luasocket.c
index 5168fbd..636bec2 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -576,7 +576,7 @@ int global_select(lua_State *L)
576 int ms = lua_isnil(L, 3) ? -1 : (int) (luaL_opt_number(L, 3, -1) * 1000); 576 int ms = lua_isnil(L, 3) ? -1 : (int) (luaL_opt_number(L, 3, -1) * 1000);
577 fd_set readfds, *prfds = NULL, writefds, *pwfds = NULL; 577 fd_set readfds, *prfds = NULL, writefds, *pwfds = NULL;
578 struct timeval tm, *ptm = NULL; 578 struct timeval tm, *ptm = NULL;
579 int ret; 579 int ret, dirty = 0;
580 unsigned max = 0; 580 unsigned max = 0;
581 SOCKET s; 581 SOCKET s;
582 int byfds, canread, canwrite; 582 int byfds, canread, canwrite;
@@ -604,7 +604,7 @@ int global_select(lua_State *L)
604 out which of the other sockets can be written to 604 out which of the other sockets can be written to
605 or read from immediately. */ 605 or read from immediately. */
606 if (!bf_isempty(sock)) { 606 if (!bf_isempty(sock)) {
607 ms = 0; 607 ms = 0; dirty = 1;
608 lua_pushnumber(L, lua_getn(L, canread) + 1); 608 lua_pushnumber(L, lua_getn(L, canread) + 1);
609 lua_pushvalue(L, -2); 609 lua_pushvalue(L, -2);
610 lua_settable(L, canread); 610 lua_settable(L, canread);
@@ -648,7 +648,7 @@ int global_select(lua_State *L)
648 /* see if we can read, write or if we timedout */ 648 /* see if we can read, write or if we timedout */
649 ret = select(max, prfds, pwfds, NULL, ptm); 649 ret = select(max, prfds, pwfds, NULL, ptm);
650 /* did we timeout? */ 650 /* did we timeout? */
651 if (ret <= 0 && ms >= 0) { 651 if (ret <= 0 && ms >= 0 && !dirty) {
652 push_error(L, NET_TIMEOUT); 652 push_error(L, NET_TIMEOUT);
653 return 3; 653 return 3;
654 } 654 }