diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-22 04:49:57 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-22 04:49:57 +0000 |
| commit | 7195ab620bd5029856a5c6c88e54a9a6eceb5e87 (patch) | |
| tree | 9b60807d8bb2112dcec6ea2e0991e468b112ea5a /src | |
| parent | bce1cb30d856d167e167c4c2997f9bebe03a612c (diff) | |
| download | luasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.tar.gz luasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.tar.bz2 luasocket-7195ab620bd5029856a5c6c88e54a9a6eceb5e87.zip | |
Few extra changes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luasocket.h | 4 | ||||
| -rw-r--r-- | src/mime.h | 4 | ||||
| -rw-r--r-- | src/smtp.lua | 5 | ||||
| -rw-r--r-- | src/socket.lua | 1 | ||||
| -rw-r--r-- | src/tcp.c | 2 | ||||
| -rw-r--r-- | src/timeout.c | 3 |
6 files changed, 6 insertions, 13 deletions
diff --git a/src/luasocket.h b/src/luasocket.h index 35dc3d9..716b7ff 100644 --- a/src/luasocket.h +++ b/src/luasocket.h | |||
| @@ -25,10 +25,6 @@ | |||
| 25 | /*-------------------------------------------------------------------------*\ | 25 | /*-------------------------------------------------------------------------*\ |
| 26 | * Initializes the library. | 26 | * Initializes the library. |
| 27 | \*-------------------------------------------------------------------------*/ | 27 | \*-------------------------------------------------------------------------*/ |
| 28 | #ifndef LUASOCKET_LIBNAME | ||
| 29 | #define LUASOCKET_LIBNAME "socket" | ||
| 30 | #endif | ||
| 31 | |||
| 32 | LUASOCKET_API int luaopen_socket(lua_State *L); | 28 | LUASOCKET_API int luaopen_socket(lua_State *L); |
| 33 | 29 | ||
| 34 | #endif /* LUASOCKET_H */ | 30 | #endif /* LUASOCKET_H */ |
| @@ -19,10 +19,6 @@ | |||
| 19 | #define MIME_API extern | 19 | #define MIME_API extern |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #ifndef MIME_LIBNAME | ||
| 23 | #define MIME_LIBNAME "mime" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | MIME_API int luaopen_mime(lua_State *L); | 22 | MIME_API int luaopen_mime(lua_State *L); |
| 27 | 23 | ||
| 28 | #endif /* MIME_H */ | 24 | #endif /* MIME_H */ |
diff --git a/src/smtp.lua b/src/smtp.lua index ac74205..c68b750 100644 --- a/src/smtp.lua +++ b/src/smtp.lua | |||
| @@ -106,7 +106,10 @@ function open(server, port) | |||
| 106 | local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) | 106 | local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) |
| 107 | local s = setmetatable({tp = tp}, metat) | 107 | local s = setmetatable({tp = tp}, metat) |
| 108 | -- make sure tp is closed if we get an exception | 108 | -- make sure tp is closed if we get an exception |
| 109 | s.try = socket.newtry(function() s:close() end) | 109 | s.try = socket.newtry(function() |
| 110 | if s.tp:command("QUIT") then s.tp:check("2..") end | ||
| 111 | s:close() | ||
| 112 | end) | ||
| 110 | return s | 113 | return s |
| 111 | end | 114 | end |
| 112 | 115 | ||
diff --git a/src/socket.lua b/src/socket.lua index b3889d7..ad96ddb 100644 --- a/src/socket.lua +++ b/src/socket.lua | |||
| @@ -30,7 +30,6 @@ function socket.bind(host, port, backlog) | |||
| 30 | sock:setoption("reuseaddr", true) | 30 | sock:setoption("reuseaddr", true) |
| 31 | local res, err = sock:bind(host, port) | 31 | local res, err = sock:bind(host, port) |
| 32 | if not res then return nil, err end | 32 | if not res then return nil, err end |
| 33 | backlog = backlog or 32 | ||
| 34 | res, err = sock:listen(backlog) | 33 | res, err = sock:listen(backlog) |
| 35 | if not res then return nil, err end | 34 | if not res then return nil, err end |
| 36 | return sock | 35 | return sock |
| @@ -232,7 +232,7 @@ static int meth_close(lua_State *L) | |||
| 232 | static int meth_listen(lua_State *L) | 232 | static int meth_listen(lua_State *L) |
| 233 | { | 233 | { |
| 234 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); | 234 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); |
| 235 | int backlog = (int) luaL_checknumber(L, 2); | 235 | int backlog = (int) luaL_optnumber(L, 2, 32); |
| 236 | const char *err = sock_listen(&tcp->sock, backlog); | 236 | const char *err = sock_listen(&tcp->sock, backlog); |
| 237 | if (err) { | 237 | if (err) { |
| 238 | lua_pushnil(L); | 238 | lua_pushnil(L); |
diff --git a/src/timeout.c b/src/timeout.c index e089051..dcc2105 100644 --- a/src/timeout.c +++ b/src/timeout.c | |||
| @@ -136,8 +136,7 @@ int tm_gettime(void) | |||
| 136 | int tm_gettime(void) | 136 | int tm_gettime(void) |
| 137 | { | 137 | { |
| 138 | struct timeval v; | 138 | struct timeval v; |
| 139 | struct timezone z = {0, 0}; | 139 | gettimeofday(&v, (struct timezone *) NULL); |
| 140 | gettimeofday(&v, &z); | ||
| 141 | return v.tv_sec * 1000 + v.tv_usec/1000; | 140 | return v.tv_sec * 1000 + v.tv_usec/1000; |
| 142 | } | 141 | } |
| 143 | #endif | 142 | #endif |
