From d28c5e4f9ee6630a18667d2215e737ed361af2fe Mon Sep 17 00:00:00 2001 From: Bruno Silvestre Date: Sun, 2 Sep 2012 11:30:04 -0300 Subject: [PATCH] LuaSec 0.3.2 --- CHANGELOG | 6 ++++++ INSTALL | 2 +- LICENSE | 2 +- src/context.c | 2 +- src/context.h | 2 +- src/socket.h | 1 + src/ssl.c | 9 ++++----- src/ssl.h | 2 +- src/ssl.lua | 6 +++--- src/usocket.c | 8 ++++++++ src/wsocket.c | 7 ++++++- 11 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 902a7e2..157247b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +-------------------------------------------------------------------------------- +LuaSec 0.3.2 +------------ +- BUG: Windows uses a different way to report socket error. + (thanks Sebastien Perin) + -------------------------------------------------------------------------------- LuaSec 0.3.1 ------------ diff --git a/INSTALL b/INSTALL index 2b22ffd..d673c12 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -LuaSec 0.3.1 +LuaSec 0.3.2 ------------ * On Linux, BSD, and Mac OS X: diff --git a/LICENSE b/LICENSE index 10b830e..a54ad24 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -LuaSec 0.3.1 license +LuaSec 0.3.2 license Copyright (C) 2006-2009 Bruno Silvestre Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/context.c b/src/context.c index b99b5af..7a5d07f 100644 --- a/src/context.c +++ b/src/context.c @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- - * LuaSec 0.3.1 + * LuaSec 0.3.2 * Copyright (C) 2006-2009 Bruno Silvestre * *--------------------------------------------------------------------------*/ diff --git a/src/context.h b/src/context.h index 47895fe..e75242e 100644 --- a/src/context.h +++ b/src/context.h @@ -2,7 +2,7 @@ #define __CONTEXT_H__ /*-------------------------------------------------------------------------- - * LuaSec 0.3.1 + * LuaSec 0.3.2 * Copyright (C) 2006-2009 Bruno Silvestre * *--------------------------------------------------------------------------*/ diff --git a/src/socket.h b/src/socket.h index 8a5b1f2..674ab29 100644 --- a/src/socket.h +++ b/src/socket.h @@ -43,5 +43,6 @@ void socket_setnonblocking(p_socket ps); void socket_setblocking(p_socket ps); int socket_waitfd(p_socket ps, int sw, p_timeout tm); const char *socket_strerror(int err); +int socket_error(); #endif /* SOCKET_H */ diff --git a/src/ssl.c b/src/ssl.c index 8bdd113..ff1d5e8 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1,10 +1,9 @@ /*-------------------------------------------------------------------------- - * LuaSec 0.3.1 + * LuaSec 0.3.2 * Copyright (C) 2006-2009 Bruno Silvestre * *--------------------------------------------------------------------------*/ -#include #include #include @@ -91,7 +90,7 @@ static int handshake(p_ssl ssl) } if (err == 0) return IO_CLOSED; - return errno; + return socket_error(); default: return IO_SSL; } @@ -133,7 +132,7 @@ static int ssl_send(void *ctx, const char *data, size_t count, size_t *sent, } if (err == 0) return IO_CLOSED; - return errno; + return socket_error(); default: return IO_SSL; } @@ -178,7 +177,7 @@ static int ssl_recv(void *ctx, char *data, size_t count, size_t *got, } if (err == 0) return IO_CLOSED; - return errno; + return socket_error(); default: return IO_SSL; } diff --git a/src/ssl.h b/src/ssl.h index 4dd9831..9d8f219 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -2,7 +2,7 @@ #define __SSL_H__ /*-------------------------------------------------------------------------- - * LuaSec 0.3.1 + * LuaSec 0.3.2 * Copyright (C) 2006-2009 Bruno Silvestre * *--------------------------------------------------------------------------*/ diff --git a/src/ssl.lua b/src/ssl.lua index 2fb3a1b..9a43d02 100644 --- a/src/ssl.lua +++ b/src/ssl.lua @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------ --- LuaSec 0.3.1 +-- LuaSec 0.3.2 -- Copyright (C) 2006-2008 Bruno Silvestre -- ------------------------------------------------------------------------------ @@ -10,8 +10,8 @@ require("ssl.core") require("ssl.context") -_VERSION = "0.3.1" -_COPYRIGHT = "LuaSec 0.3.1 - Copyright (C) 2006-2009 Bruno Silvestre\n" .. +_VERSION = "0.3.2" +_COPYRIGHT = "LuaSec 0.3.2 - Copyright (C) 2006-2009 Bruno Silvestre\n" .. "LuaSocket 2.0.2 - Copyright (C) 2004-2007 Diego Nehab" -- Export functions diff --git a/src/usocket.c b/src/usocket.c index 9ead9f4..2fd9651 100644 --- a/src/usocket.c +++ b/src/usocket.c @@ -135,3 +135,11 @@ const char *socket_strerror(int err) { } } +/*-------------------------------------------------------------------------*\ +* Underline error code. +\*-------------------------------------------------------------------------*/ +int socket_error() +{ + return errno; +} + diff --git a/src/wsocket.c b/src/wsocket.c index 9f99138..ee399f3 100644 --- a/src/wsocket.c +++ b/src/wsocket.c @@ -150,7 +150,6 @@ static const char *wstrerror(int err) { const char *socket_strerror(int err) { if (err <= 0) return io_strerror(err); switch (err) { - case ERROR_FILE_NOT_FOUND: return "closed"; case WSAEADDRINUSE: return "address already in use"; case WSAECONNREFUSED: return "connection refused"; case WSAEISCONN: return "already connected"; @@ -162,3 +161,9 @@ const char *socket_strerror(int err) { } } +/* Socket error code */ +int socket_error() +{ + return WSAGetLastError(); +} +