~ubuntu-branches/ubuntu/precise/ejabberd/precise-proposed

« back to all changes in this revision

Viewing changes to src/p1_fsm.erl

  • Committer: Bazaar Package Importer
  • Author(s): Konstantin Khomoutov, Konstantin Khomoutov
  • Date: 2010-07-26 20:36:14 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20100726203614-s3asj0k5ym3bxhdw
Tags: 2.1.4-1
[ Konstantin Khomoutov ]
* Do not prevent ejabberd_debug from being installed and used
  as this was implemented upstream as the default behavior.
* Add build dependency on erlang-parsetools.
* Add 'sharedscripts' option to logrotate config.
* Update VCS references in control file to point to git.deb.at.
* Add group sticky bit to permissions on the log directory --
  this should make log files owned by the group "adm".
* Explicitly set umask to 027 before starting erl.
* Add patch with fix for EJAB-953 (closes: #590389).
* Fix call to setup_ejabberd in postinst.
* Fix owner/permissions for log files when upgrading.
* Minor fixes and clarifications in ejabberdctl.8 manual page.
* Refresh reopen-log.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
%%   - You can limit the time processing a message (TODO): If the
26
26
%%   message processing does not return in a given period of time, the
27
27
%%   process will be terminated.
28
 
%% 
 
28
%%   - You might customize the State data before sending it to error_logger
 
29
%%   in case of a crash (just export the function print_state/1)
29
30
%%     $Id$
30
31
%%
31
32
-module(p1_fsm).
146
147
 
147
148
behaviour_info(callbacks) ->
148
149
    [{init,1},{handle_event,3},{handle_sync_event,4},{handle_info,3},
149
 
     {terminate,3},{code_change,4}];
 
150
     {terminate,3},{code_change,4}, {print_state,1}];
150
151
behaviour_info(_Other) ->
151
152
    undefined.
152
153
 
376
377
                       Debug, Limits, Queue1, QueueLen - 1, false);
377
378
        {empty, _} ->
378
379
            Reason = internal_queue_error,
379
 
            error_info(Reason, Name, hibernate, StateName, StateData, Debug),
 
380
            error_info(Mod, Reason, Name, hibernate, StateName, StateData, Debug),
380
381
            exit(Reason)
381
382
    end;
382
383
loop(Parent, Name, StateName, StateData, Mod, hibernate, Debug,
620
621
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug) ->
621
622
    case catch Mod:terminate(Reason, StateName, StateData) of
622
623
        {'EXIT', R} ->
623
 
            error_info(R, Name, Msg, StateName, StateData, Debug),
 
624
            error_info(Mod, R, Name, Msg, StateName, StateData, Debug),
624
625
            exit(R);
625
626
        _ ->
626
627
            case Reason of
639
640
                                           [self(), Limit]),
640
641
                    exit(shutdown);
641
642
                _ ->
642
 
                    error_info(Reason, Name, Msg, StateName, StateData, Debug),
 
643
                    error_info(Mod, Reason, Name, Msg, StateName, StateData, Debug),
643
644
                    exit(Reason)
644
645
            end
645
646
    end.
646
647
 
647
 
error_info(Reason, Name, Msg, StateName, StateData, Debug) ->
 
648
error_info(Mod, Reason, Name, Msg, StateName, StateData, Debug) ->
648
649
    Reason1 = 
649
650
        case Reason of
650
651
            {undef,[{M,F,A}|MFAs]} ->
662
663
            _ ->
663
664
                Reason
664
665
        end,
 
666
    StateToPrint = case erlang:function_exported(Mod, print_state, 1) of
 
667
      true -> (catch Mod:print_state(StateData));
 
668
      false -> StateData
 
669
    end,
665
670
    Str = "** State machine ~p terminating \n" ++
666
671
        get_msg_str(Msg) ++
667
672
        "** When State == ~p~n"
668
673
        "**      Data  == ~p~n"
669
674
        "** Reason for termination = ~n** ~p~n",
670
 
    format(Str, [Name, get_msg(Msg), StateName, StateData, Reason1]),
 
675
    format(Str, [Name, get_msg(Msg), StateName, StateToPrint, Reason1]),
671
676
    sys:print_log(Debug),
672
677
    ok.
673
678