Browse Source

Replace posix() by atom(), for now.

The type isn't exported by OTP so we don't win much.
Also, inet.erl and file.erl define posix() différently,
so OTP needs to stop being so confuse in the first place
before we can attempt to use it properly.
Loïc Hoguin 14 years ago
parent
commit
731d839323
4 changed files with 17 additions and 18 deletions
  1. 0 1
      include/types.hrl
  2. 2 2
      src/cowboy_http_req.erl
  3. 8 8
      src/cowboy_ssl_transport.erl
  4. 7 7
      src/cowboy_tcp_transport.erl

+ 0 - 1
include/types.hrl

@@ -12,5 +12,4 @@
 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
--type posix() :: atom().
 -type port_number() :: 0..65535.

+ 2 - 2
src/cowboy_http_req.erl

@@ -145,7 +145,7 @@ headers(Req) ->
 
 %% @todo We probably want to allow a max length.
 -spec body(Req::#http_req{})
-	-> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::posix()}.
+	-> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::atom()}.
 body(Req) ->
 	{Length, Req2} = cowboy_http_req:header('Content-Length', Req),
 	case Length of
@@ -157,7 +157,7 @@ body(Req) ->
 
 %% @todo We probably want to configure the timeout.
 -spec body(Length::non_neg_integer(), Req::#http_req{})
-	-> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::posix()}.
+	-> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::atom()}.
 body(Length, Req=#http_req{socket=Socket, transport=Transport,
 		body_state=waiting}) ->
 	Transport:setopts(Socket, [{packet, raw}]),

+ 8 - 8
src/cowboy_ssl_transport.erl

@@ -30,7 +30,7 @@ messages() -> {ssl, ssl_closed, ssl_error}.
 
 -spec listen([{port, Port::port_number()} | {certfile, CertPath::string()}
 	| {keyfile, KeyPath::string()} | {password, Password::string()}])
-	-> {ok, LSocket::sslsocket()} | {error, Reason::posix()}.
+	-> {ok, LSocket::sslsocket()} | {error, Reason::atom()}.
 listen(Opts) ->
 	{port, Port} = lists:keyfind(port, 1, Opts),
 	{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
@@ -41,7 +41,7 @@ listen(Opts) ->
 		{certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]).
 
 -spec accept(LSocket::sslsocket(), Timeout::timeout())
-	-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
+	-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | atom()}.
 accept(LSocket, Timeout) ->
 	case ssl:transport_accept(LSocket, Timeout) of
 		{ok, CSocket} ->
@@ -51,27 +51,27 @@ accept(LSocket, Timeout) ->
 	end.
 
 -spec recv(Socket::sslsocket(), Length::integer(), Timeout::timeout())
-	-> {ok, Packet::term()} | {error, Reason::closed | posix()}.
+	-> {ok, Packet::term()} | {error, Reason::closed | atom()}.
 recv(Socket, Length, Timeout) ->
 	ssl:recv(Socket, Length, Timeout).
 
 -spec send(Socket::sslsocket(), Packet::iolist())
-	-> ok | {error, Reason::posix()}.
+	-> ok | {error, Reason::atom()}.
 send(Socket, Packet) ->
 	ssl:send(Socket, Packet).
 
 -spec setopts(Socket::sslsocket(), Opts::list(term()))
-	-> ok | {error, Reason::posix()}.
+	-> ok | {error, Reason::atom()}.
 setopts(Socket, Opts) ->
 	ssl:setopts(Socket, Opts).
 
 -spec controlling_process(Socket::sslsocket(), Pid::pid())
-	-> ok | {error, Reason::closed | not_owner | posix()}.
+	-> ok | {error, Reason::closed | not_owner | atom()}.
 controlling_process(Socket, Pid) ->
 	ssl:controlling_process(Socket, Pid).
 
 -spec peername(Socket::sslsocket())
-	-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, posix()}.
+	-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
 peername(Socket) ->
 	ssl:peername(Socket).
 
@@ -82,7 +82,7 @@ close(Socket) ->
 %% Internal.
 
 -spec ssl_accept(CSocket::sslsocket(), Timeout::timeout())
-	-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
+	-> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | atom()}.
 ssl_accept(CSocket, Timeout) ->
 	case ssl:ssl_accept(CSocket, Timeout) of
 		ok ->

+ 7 - 7
src/cowboy_tcp_transport.erl

@@ -27,7 +27,7 @@ name() -> tcp.
 messages() -> {tcp, tcp_closed, tcp_error}.
 
 -spec listen([{port, Port::port_number()}])
-	-> {ok, LSocket::inet:socket()} | {error, Reason::posix()}.
+	-> {ok, LSocket::inet:socket()} | {error, Reason::atom()}.
 listen(Opts) ->
 	{port, Port} = lists:keyfind(port, 1, Opts),
 	gen_tcp:listen(Port, [binary, {active, false},
@@ -35,32 +35,32 @@ listen(Opts) ->
 
 -spec accept(LSocket::inet:socket(), Timeout::timeout())
 	-> {ok, Socket::inet:socket()}
-	| {error, Reason::closed | timeout | posix()}.
+	| {error, Reason::closed | timeout | atom()}.
 accept(LSocket, Timeout) ->
 	gen_tcp:accept(LSocket, Timeout).
 
 -spec recv(Socket::inet:socket(), Length::integer(), Timeout::timeout())
-	-> {ok, Packet::term()} | {error, Reason::closed | posix()}.
+	-> {ok, Packet::term()} | {error, Reason::closed | atom()}.
 recv(Socket, Length, Timeout) ->
 	gen_tcp:recv(Socket, Length, Timeout).
 
 -spec send(Socket::inet:socket(), Packet::iolist())
-	-> ok | {error, Reason::posix()}.
+	-> ok | {error, Reason::atom()}.
 send(Socket, Packet) ->
 	gen_tcp:send(Socket, Packet).
 
 -spec setopts(Socket::inet:socket(), Opts::list(term()))
-	-> ok | {error, Reason::posix()}.
+	-> ok | {error, Reason::atom()}.
 setopts(Socket, Opts) ->
 	inet:setopts(Socket, Opts).
 
 -spec controlling_process(Socket::inet:socket(), Pid::pid())
-	-> ok | {error, Reason::closed | not_owner | posix()}.
+	-> ok | {error, Reason::closed | not_owner | atom()}.
 controlling_process(Socket, Pid) ->
 	gen_tcp:controlling_process(Socket, Pid).
 
 -spec peername(Socket::inet:socket())
-	-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, posix()}.
+	-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
 peername(Socket) ->
 	inet:peername(Socket).