diff --git a/Makefile b/Makefile index 19dce8c..2b6cee6 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ DEPS = inert procket edown #DEP_PLUGINS = annotations dep_procket = git https://github.com/msantos/procket.git master -dep_inert = git https://github.com/msantos/inert.git 0.2.1 +dep_inert = git https://github.com/msantos/inert.git 0.6.2 dep_annotations_commit = 9f8a800 EDOC_OPTS = {app_default, "http://www.erlang.org/doc/"} \ diff --git a/src/dbus_transport_unix.erl b/src/dbus_transport_unix.erl index a21fa59..8d41b59 100644 --- a/src/dbus_transport_unix.erl +++ b/src/dbus_transport_unix.erl @@ -26,7 +26,7 @@ terminate/2]). %% Internal --export([do_read/3]). +-export([do_read/2]). -record(state, {sock, owner, @@ -53,14 +53,14 @@ connect(BusOptions, _Options) -> init([{Mode, Path}, Owner]) when is_pid(Owner), is_binary(Path) -> true = link(Owner), ?debug("Connecting to UNIX socket: ~p~n", [Path]), + ok = inert:start(), case procket:socket(?PF_LOCAL, ?SOCK_STREAM, 0) of {ok, Sock} -> SockUn = get_sock_un(Mode, Path), case procket:connect(Sock, SockUn) of ok -> process_flag(trap_exit, true), - PollID = inert:start(), - Loop = spawn_link(?MODULE, do_read, [PollID, Sock, self()]), + Loop = spawn_link(?MODULE, do_read, [Sock, self()]), {ok, #state{sock=Sock, owner=Owner, loop=Loop}}; {error, Err} -> ?error("Error connecting socket: ~p~n", [Err]), @@ -136,11 +136,11 @@ terminate(_Reason, #state{sock=Sock, loop=Loop}) -> %%% %%% Priv %%% -do_read(PollID, Sock, Pid) -> +do_read(Sock, Pid) -> case procket:recvfrom(Sock, 16#FFFF) of {error, eagain} -> - ok = inert:poll(PollID, Sock), - do_read(PollID, Sock, Pid); + {ok, read} = inert:poll(Sock, [{mode, read}]), + do_read(Sock, Pid); {error, _Err} -> ok; %% EOF @@ -148,7 +148,7 @@ do_read(PollID, Sock, Pid) -> ok; {ok, Buf} -> Pid ! {unix, Buf}, - do_read(PollID, Sock, Pid) + do_read(Sock, Pid) end. get_sock_un(abstract, Path) when byte_size(Path) < ?UNIX_PATH_MAX-1 ->