Permalink
Browse files

Allow caller to retrieve serial num of message

Some operations, like those involving streams, require the caller to
know the serial number. Further calls will increment the serial number
but the messages from the stream call may appear async.
  • Loading branch information...
1 parent 21ee21a commit 09ff4084394b24848e7713287fcdda9802e6c2f6 @msantos committed Sep 13, 2012
Showing with 21 additions and 11 deletions.
  1. +6 −1 src/verx_client.erl
  2. +4 −3 src/verx_client_tcp.erl
  3. +4 −3 src/verx_client_tls.erl
  4. +7 −4 src/verx_client_unix.erl
View
@@ -40,7 +40,9 @@
send/2,
recv/1, recv/2,
recvall/1, recvall/2,
- finish/1
+ finish/1,
+
+ getserial/1
]).
-export([stream/2]).
@@ -94,6 +96,9 @@ recvall({Module, Ref}, Timeout) ->
finish({Module, Ref}) ->
Module:finish(Ref).
+getserial({Module, Ref}) ->
+ Module:getserial(Ref).
+
%%-------------------------------------------------------------------------
%%% Utility functions
%%-------------------------------------------------------------------------
View
@@ -47,7 +47,7 @@
send/2,
finish/1,
- getfd/1
+ getserial/1
]).
-export([start_link/0, start_link/1]).
-export([start/0, start/1, stop/1]).
@@ -154,8 +154,9 @@ send(Ref, [Buf|Rest]) when is_binary(Buf) ->
finish(Ref) when is_pid(Ref) ->
gen_server:call(Ref, finish, infinity).
-getfd(Ref) when is_pid(Ref) ->
- gen_server:call(Ref, getfd).
+getserial(Ref) when is_pid(Ref) ->
+ #state{serial = Serial} = gen_server:call(Ref, getstate),
+ Serial.
start() ->
start([]).
View
@@ -47,7 +47,7 @@
send/2,
finish/1,
- getfd/1
+ getserial/1
]).
-export([start_link/0, start_link/1]).
-export([start/0, start/1, stop/1]).
@@ -151,8 +151,9 @@ send(Ref, [Buf|Rest]) when is_binary(Buf) ->
finish(Ref) when is_pid(Ref) ->
gen_server:call(Ref, finish, infinity).
-getfd(Ref) when is_pid(Ref) ->
- gen_server:call(Ref, getfd).
+getserial(Ref) when is_pid(Ref) ->
+ #state{serial = Serial} = gen_server:call(Ref, getstate),
+ Serial.
start() ->
start([]).
View
@@ -46,6 +46,7 @@
send/2,
finish/1,
+ getserial/1,
getfd/1
]).
-export([read_packet/1, read_packet/2]).
@@ -200,8 +201,13 @@ finish(Ref) when is_pid(Ref) ->
Len = ?REMOTE_MESSAGE_HEADER_XDR_LEN + byte_size(Header),
procket:write(FD, <<Len:32, Header/binary>>).
+getserial(Ref) when is_pid(Ref) ->
+ #state{serial = Serial} = gen_server:call(Ref, getstate),
+ Serial.
+
getfd(Ref) when is_pid(Ref) ->
- gen_server:call(Ref, getfd).
+ #state{s = FD} = gen_server:call(Ref, getfd),
+ FD.
start() ->
start([]).
@@ -245,9 +251,6 @@ handle_call({call, Proc, _Message}, _From, #state{serial = Serial} = State) ->
Serial1 = Serial + 1,
{reply, {ok, Serial1}, State#state{proc = Proc, serial = Serial1}};
-handle_call(getfd, _From, #state{s = Socket} = State) ->
- {reply, Socket, State};
-
handle_call(getstate, _From, State) ->
{reply, State, State};

0 comments on commit 09ff408

Please sign in to comment.