Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 58 additions and 11 deletions.
  1. +6 −3 rebar.config
  2. +24 −7 src/gen_esme.erl
  3. +28 −1 src/gen_esme_session.erl
View
9 rebar.config
@@ -1,9 +1,11 @@
{lib_dirs, ["deps"]}.
-{erl_opts, [warnings_as_errors, debug_info]}.
+{erl_opts, [warnings_as_errors, debug_info, {parse_transform, lager_transform}]}.
-{deps, [{common_lib, "3.3.4",
- {git, "git://github.com/iamaleksey/common_lib.git", "master"}}]}.
+{deps, [
+ {common_lib, "3.3.4", {git, "git://github.com/mijkenator/common_lib.git", "master"}},
+ {lager, "0.9.*", {git, "git://github.com/basho/lager", {branch, "master"}}}
+]}.
{erl_first_files, ["src/gen_esme_session.erl",
"src/gen_mc_session.erl",
@@ -11,3 +13,4 @@
"src/gen_mc.erl"]}.
{xref_checks, [undefined_function_calls]}.
+
View
31 src/gen_esme.erl
@@ -292,6 +292,7 @@ submit_sm(SrvRef, Params, Args) ->
submit_sm(SrvRef, Params, Args, ?ASSERT_TIME).
submit_sm(SrvRef, Params, Args, Timeout) ->
+ lager:debug("GES SUBMIT_SM ~p ~p ~n", [SrvRef, Args]),
gen_server:call(SrvRef, {{submit_sm, Params}, Args}, Timeout).
@@ -464,15 +465,20 @@ handle_call({start_session, Opts}, _From, St) ->
{reply, Error, St}
end;
handle_call({{CmdName, Params} = Req, Args}, _From, St) ->
+ %lager:debug("HC1: ~p ~n", [CmdName]),
Ref = req_send(St#st.session, CmdName, Params),
- case pack((St#st.mod):handle_req(Req, Args, Ref, St#st.mod_st), St) of
+ %lager:debug("HCREF: ~p ~n", [Ref]),
+ %lager:debug("HC2: ~p ~p ~n", [St#st.session, St#st.mod]),
+ Ret = case pack((St#st.mod):handle_req(Req, Args, Ref, St#st.mod_st), St) of
{noreply, NewSt} ->
- {reply, ok, NewSt};
+ {reply, {ok, Ref}, NewSt};
{noreply, NewSt, Timeout} ->
- {reply, ok, NewSt, Timeout};
+ {reply, {ok, Ref}, NewSt, Timeout};
{stop, Reason, NewSt} ->
{stop, ok, Reason, NewSt}
- end;
+ end,
+ %lager:debug("HC3: ~p ~n", [Ret]),
+ Ret;
handle_call(pause, _From, St) ->
try
true = is_process_alive(St#st.consumer),
@@ -495,6 +501,7 @@ handle_call({handle_accept, Addr}, From, St) ->
handle_call({handle_data_sm, Pdu}, From, St) ->
pack((St#st.mod):handle_data_sm(Pdu, From, St#st.mod_st), St);
handle_call({handle_deliver_sm, Pdu}, From, St) ->
+ %lager:debug("HEHC deliver_sm ~p ~p ~n", [St#st.mod, Pdu]),
pack((St#st.mod):handle_deliver_sm(Pdu, From, St#st.mod_st), St);
handle_call({handle_unbind, Pdu}, From, St) ->
pack((St#st.mod):handle_unbind(Pdu, From, St#st.mod_st), St);
@@ -545,7 +552,11 @@ handle_cast({rps_max, Rps}, St) ->
ok = cl_consumer:rps(St#st.consumer, Rps),
{noreply, St#st{rps = Rps}};
handle_cast({handle_resp, Resp, Ref}, St) ->
- pack((St#st.mod):handle_resp(Resp, Ref, St#st.mod_st), St);
+ lager:debug("GENESME HCHR: ~p ~p ~p ~n",[St#st.mod, Resp, Ref]),
+ Ret = (St#st.mod):handle_resp(Resp, Ref, St#st.mod_st),
+ lager:debug("GENESME HCHR Ret: ~p ~n",[Ret]),
+ pack(Ret, St);
+ %pack((St#st.mod):handle_resp(Resp, Ref, St#st.mod_st), St);
handle_cast({handle_alert_notification, Pdu}, St) ->
pack((St#st.mod):handle_alert_notification(Pdu, St#st.mod_st), St).
@@ -578,20 +589,23 @@ handle_closed(SrvRef, Reason) ->
handle_enquire_link(SrvRef, Pdu) ->
+ lager:debug("enquire_link ~p ~n",[Pdu]),
gen_server:call(SrvRef, {handle_enquire_link, Pdu}, ?ASSERT_TIME).
handle_operation(SrvRef, {data_sm, Pdu}) ->
+ lager:debug("GEHO data_sm ~p ~n",[{data_sm, Pdu}]),
gen_server:call(SrvRef, {handle_data_sm, Pdu}, ?ASSERT_TIME);
handle_operation(SrvRef, {deliver_sm, Pdu}) ->
+ %lager:debug("GEHO deliver_sm ~p ~n",[{deliver_sm, Pdu}]),
gen_server:call(SrvRef, {handle_deliver_sm, Pdu}, ?ASSERT_TIME).
-
handle_outbind(SrvRef, Pdu) ->
gen_server:cast(SrvRef, {handle_outbind, Pdu}).
handle_resp(SrvRef, Resp, Ref) ->
+ lager:debug("GENESME HR: ~p ~p ~p ~n", [SrvRef, Resp, Ref]),
gen_server:cast(SrvRef, {handle_resp, Resp, Ref}).
@@ -662,7 +676,10 @@ req_send(Pid, CmdName, Params) ->
CmdName == submit_multi ->
gen_esme_session:submit_multi(Pid, Params);
CmdName == submit_sm ->
- gen_esme_session:submit_sm(Pid, Params);
+ lager:debug("GES REQ_SEND ~p ~n",[Pid]),
+ Ret = gen_esme_session:submit_sm(Pid, Params),
+ lager:debug("GES REQ_SEND RET ~p ~n",[Ret]),
+ Ret;
CmdName == unbind ->
gen_esme_session:unbind(Pid)
end
View
29 src/gen_esme_session.erl
@@ -129,16 +129,19 @@ reply(FsmRef, {SeqNum, Reply}) ->
bind_receiver(FsmRef, Params) ->
+ lager:debug("BIND RECEIVER ~n",[]),
Event = {?COMMAND_ID_BIND_RECEIVER, Params},
gen_fsm:sync_send_all_state_event(FsmRef, Event, ?ASSERT_TIME).
bind_transmitter(FsmRef, Params) ->
+ lager:debug("BIND TRANSMITTER ~n",[]),
Event = {?COMMAND_ID_BIND_TRANSMITTER, Params},
gen_fsm:sync_send_all_state_event(FsmRef, Event, ?ASSERT_TIME).
bind_transceiver(FsmRef, Params) ->
+ lager:debug("BIND TRANSCEIVER ~n",[]),
Event = {?COMMAND_ID_BIND_TRANSCEIVER, Params},
gen_fsm:sync_send_all_state_event(FsmRef, Event, ?ASSERT_TIME).
@@ -185,7 +188,9 @@ submit_multi(FsmRef, Params) ->
submit_sm(FsmRef, Params) ->
Event = {?COMMAND_ID_SUBMIT_SM, Params},
- gen_fsm:sync_send_all_state_event(FsmRef, Event, ?ASSERT_TIME).
+ Ret = gen_fsm:sync_send_all_state_event(FsmRef, Event, ?ASSERT_TIME),
+ lager:debug("GESMES SSM: ~p ~p ~n", [FsmRef, Ret]),
+ Ret.
unbind(FsmRef) ->
@@ -396,10 +401,12 @@ esme_rinvbndsts_resp({CmdId, Pdu}, Sock, Log) ->
%%%-----------------------------------------------------------------------------
handle_event({input, CmdId, _Pdu, _Lapse, _Timestamp}, Stn, Std)
when CmdId == ?COMMAND_ID_ENQUIRE_LINK_RESP ->
+ %lager:debug("GES HE1 ~p ~p ~p ~n",[CmdId, _Pdu, _Lapse]),
smpp_session:cancel_timer(Std#st.enquire_link_resp_timer),
{next_state, Stn, Std};
handle_event({input, CmdId, Pdu, _Lapse, _Timestamp}, Stn, Std)
when CmdId == ?COMMAND_ID_GENERIC_NACK ->
+ lager:debug("GES HE2 ~p ~p ~p ~n",[CmdId, Pdu, _Lapse]),
smpp_session:cancel_timer(Std#st.enquire_link_resp_timer), % In case it was set
SeqNum = smpp_operation:get_value(sequence_number, Pdu),
case smpp_req_tab:read(Std#st.req_tab, SeqNum) of
@@ -419,33 +426,41 @@ handle_event({input, CmdId, Pdu, _Lapse, _Timestamp}, Stn, Std)
{next_state, Stn, Std};
handle_event({input, CmdId, Pdu, _Lapse, _Timestamp}, Stn, Std)
when ?IS_RESPONSE(CmdId) ->
+ lager:debug("GES HE3 ~p ~p ~p ~p ~p ~n",[CmdId, Pdu, _Lapse, Stn, Std]),
smpp_session:cancel_timer(Std#st.enquire_link_resp_timer), % In case it was set
SeqNum = smpp_operation:get_value(sequence_number, Pdu),
ReqId = ?REQUEST(CmdId),
case smpp_req_tab:read(Std#st.req_tab, SeqNum) of
{ok, {SeqNum, ReqId, RTimer, Ref}} ->
smpp_session:cancel_timer(RTimer),
+ lager:debug("GES HE31 ~p ~n",[Ref]),
case smpp_operation:get_value(command_status, Pdu) of
?ESME_ROK when CmdId == ?COMMAND_ID_BIND_RECEIVER_RESP ->
smpp_session:cancel_timer(Std#st.session_init_timer),
+ lager:debug("GES HE311 ~n",[]),
handle_peer_resp({ok, Pdu}, Ref, Std),
{next_state, bound_rx, Std};
?ESME_ROK when CmdId == ?COMMAND_ID_BIND_TRANSCEIVER_RESP ->
smpp_session:cancel_timer(Std#st.session_init_timer),
+ lager:debug("GES HE312 ~n",[]),
handle_peer_resp({ok, Pdu}, Ref, Std),
{next_state, bound_trx, Std};
?ESME_ROK when CmdId == ?COMMAND_ID_BIND_TRANSMITTER_RESP ->
smpp_session:cancel_timer(Std#st.session_init_timer),
+ lager:debug("GES HE313 ~n",[]),
handle_peer_resp({ok, Pdu}, Ref, Std),
{next_state, bound_tx, Std};
?ESME_ROK when CmdId == ?COMMAND_ID_UNBIND_RESP ->
smpp_session:cancel_timer(Std#st.inactivity_timer),
+ lager:debug("GES HE314 ~n",[]),
handle_peer_resp({ok, Pdu}, Ref, Std),
{next_state, unbound, Std};
?ESME_ROK ->
+ lager:debug("GES HE315 ~n",[]),
handle_peer_resp({ok, Pdu}, Ref, Std),
{next_state, Stn, Std};
Status ->
+ lager:debug("GES HE316 ~n",[]),
Reason = {command_status, Status},
handle_peer_resp({error, Reason}, Ref, Std),
{next_state, Stn, Std}
@@ -461,6 +476,7 @@ handle_event({input, CmdId, Pdu, _Lapse, _Timestamp}, Stn, Std)
when CmdId == ?COMMAND_ID_ENQUIRE_LINK ->
smpp_session:cancel_timer(Std#st.enquire_link_resp_timer), % In case it was set
smpp_session:cancel_timer(Std#st.enquire_link_timer),
+ lager:debug("GES HE4 ~p ~p ~p ~n",[CmdId, Pdu, _Lapse]),
ok = (Std#st.mod):handle_enquire_link(Std#st.esme, Pdu),
SeqNum = smpp_operation:get_value(sequence_number, Pdu),
RespId = ?COMMAND_ID_ENQUIRE_LINK_RESP,
@@ -471,6 +487,7 @@ handle_event({input, CmdId, Pdu, Lapse, Timestamp}, Stn, Std) ->
smpp_session:cancel_timer(Std#st.enquire_link_resp_timer), % In case it was set
smpp_session:cancel_timer(Std#st.inactivity_timer),
smpp_session:cancel_timer(Std#st.enquire_link_timer),
+ %lager:debug("GES HE5 ~p ~p ~p ~n",[CmdId, Pdu, Lapse]),
gen_fsm:send_event(self(), {CmdId, Pdu}),
TE = smpp_session:start_timer(Std#st.timers, enquire_link_timer),
TI = smpp_session:start_timer(Std#st.timers, inactivity_timer),
@@ -480,8 +497,10 @@ handle_event({input, CmdId, Pdu, Lapse, Timestamp}, Stn, Std) ->
inactivity_timer = TI}};
handle_event({error, CmdId, Status, _SeqNum}, _Stn, Std)
when ?IS_RESPONSE(CmdId) ->
+ lager:debug("GES HE6 ~p ~p ~n",[CmdId, Status]),
{stop, {command_status, Status}, Std};
handle_event({error, CmdId, Status, SeqNum}, Stn, Std) ->
+ lager:debug("GES HE7 ~p ~p ~n",[CmdId, Status]),
RespId = case ?VALID_COMMAND_ID(CmdId) of
true when CmdId /= ?COMMAND_ID_GENERIC_NACK ->
?RESPONSE(CmdId);
@@ -518,7 +537,9 @@ handle_info(_Info, Stn, Std) ->
handle_sync_event({stop, Reason}, _From, _Stn, Std) ->
{stop, Reason, ok, Std};
handle_sync_event({reply, {SeqNum, Reply}}, _From, Stn, Std) ->
+ lager:debug("GES HSE1 ~p ~p ~n",[SeqNum, Reply]),
{ok, {SeqNum, CmdId}} = smpp_req_tab:read(Std#st.op_tab, SeqNum),
+ lager:debug("GES HSE11 ~p ~p ~n",[SeqNum, CmdId]),
RespId = ?RESPONSE(CmdId),
Sock = Std#st.sock,
Log = Std#st.log,
@@ -532,6 +553,7 @@ handle_sync_event({reply, {SeqNum, Reply}}, _From, Stn, Std) ->
end,
{reply, ok, Stn, Std};
handle_sync_event({CmdId, Params}, From, Stn, Std) ->
+ lager:debug("GES HSE2 ~p ~p ~p ~n",[CmdId, Params, From]),
NewStd = send_request(CmdId, Params, From, Std),
{next_state, Stn, NewStd}.
@@ -582,6 +604,7 @@ handle_peer_operation({CmdId, Pdu}, St) ->
RespId = ?RESPONSE(CmdId),
Sock = St#st.sock,
Log = St#st.log,
+ lager:debug("GES HPO: ~p ~p ~n",[CmdName, RespId]),
case (St#st.mod):handle_operation(St#st.esme, {CmdName, Pdu}) of
noreply ->
ok = smpp_req_tab:write(St#st.op_tab, {SeqNum, CmdId}),
@@ -602,6 +625,7 @@ handle_peer_outbind({?COMMAND_ID_OUTBIND, Pdu}, St) ->
handle_peer_resp(Reply, Ref, St) ->
+ lager:debug("GES HPR: ~p ~p ---- ~p ~p ~n",[St#st.mod, St#st.esme, Reply, Ref]),
(St#st.mod):handle_resp(St#st.esme, Reply, Ref).
@@ -650,7 +674,9 @@ send_enquire_link(St) ->
send_request(CmdId, Params, From, St) ->
+ lager:debug("GESMES SRQ ~p ~p ~n",[CmdId, From]),
Ref = make_ref(),
+ lager:debug("GESMES SRQ MAKE REF ~p ~n",[Ref]),
gen_fsm:reply(From, Ref),
SeqNum = ?INCR_SEQUENCE_NUMBER(St#st.sequence_number),
Pdu = smpp_operation:new(CmdId, SeqNum, Params),
@@ -671,5 +697,6 @@ send_request(CmdId, Params, From, St) ->
send_response(CmdId, Status, SeqNum, Params, Sock, Log) ->
+ lager:debug("GESMES SRE ~p ~p ~n",[CmdId, Status]),
Pdu = smpp_operation:new(CmdId, Status, SeqNum, Params),
smpp_session:send_pdu(Sock, Pdu, Log).

No commit comments for this range

Something went wrong with that request. Please try again.