From 6dc9c1096a664fe3642e774aadcb5af9f511176e Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 11 Mar 2005 02:21:27 +0000 Subject: Seems to be working on windows. --- src/buffer.c | 2 +- src/tcp.c | 8 +++++--- src/timeout.h | 2 +- src/wsocket.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/buffer.c b/src/buffer.c index 45cd0f2..62211d8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -77,7 +77,7 @@ int buf_meth_send(lua_State *L, p_buf buf) { int top = lua_gettop(L); p_tm tm = tm_markstart(buf->tm); int err = IO_DONE; - size_t size, sent; + size_t size = 0, sent = 0; const char *data = luaL_checklstring(L, 2, &size); long start = (long) luaL_optnumber(L, 3, 1); long end = (long) luaL_optnumber(L, 4, -1); diff --git a/src/tcp.c b/src/tcp.c index 7ff3054..3aa1538 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -228,10 +228,12 @@ static int meth_connect(lua_State *L) static int meth_connected(lua_State *L) { - p_tcp tcp; + p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); int err; - tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); - err = sock_connected(&tcp->sock, &tcp->tm); + t_tm tm; + tm_init(&tm, 0.1, -1); + tm_markstart(&tm); + err = sock_connected(&tcp->sock, &tm); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, sock_strerror(err)); diff --git a/src/timeout.h b/src/timeout.h index 595aac2..d2f9be0 100644 --- a/src/timeout.h +++ b/src/timeout.h @@ -10,8 +10,8 @@ /* timeout control structure */ typedef struct t_tm_ { - double total; /* total number of miliseconds for operation */ double block; /* maximum time for blocking calls */ + double total; /* total number of miliseconds for operation */ double start; /* time of start of operation */ } t_tm; typedef t_tm *p_tm; diff --git a/src/wsocket.c b/src/wsocket.c index 8b00fa5..2c30fbb 100644 --- a/src/wsocket.c +++ b/src/wsocket.c @@ -129,10 +129,11 @@ int sock_connect(p_sock ps, SA *addr, socklen_t len, p_tm tm) { \*-------------------------------------------------------------------------*/ int sock_connected(p_sock ps, p_tm tm) { int err; + /* give windows time to find out what is up (yes, disgusting) */ if ((err = sock_waitfd(ps, WAITFD_C, tm)) == IO_CLOSED) { int len = sizeof(err); /* give windows time to set the error (yes, disgusting) */ - Sleep(0); + Sleep(10); /* find out why we failed */ getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len); /* we KNOW there was an error. if 'why' is 0, we will return -- cgit v1.2.3-55-g6feb