Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zotonic fails to (re)start if an existing admin panel is open with browser supporting WebSockets #75

Closed
arjan opened this issue Sep 5, 2011 · 4 comments
Labels

Comments

@arjan
Copy link
Member

arjan commented Sep 5, 2011

From http://code.google.com/p/zotonic/issues/detail?id=70

What steps will reproduce the problem?

  1. Start Zotonic (can be fresh default site)
  2. Login to admin with WebSocket compatible browser, edit any of the articles
  3. (not sure if needed but I did:) Edit the article and save it
  4. Stop and try to start Zotonic

What is the expected output? What do you see instead?
Server should start without any problems

What version of the product are you using? On what operating system?
On the console the server goes into an infinite loop throwing following exception

Please provide any additional information below.
=ERROR REPORT==== 2-Apr-2010::12:42:52 ===
** Generic server 'z_session_manager$default' terminating
** Last message in was {ensure_session,false,
{context,
{wm_reqdata,#Port<0.4562>,
{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],
[[zotonic_host|default]],
[[resource_module|resource_websocket]],
[],[],[],[],[],[],[],[],[],[]}}},
undefined,"defined_in_wm_req_srv_init",undefined,
{wm_log_data,undefined,
{1270,208572,879595},
'GET',
{5,
{"upgrade",
{'Upgrade',"WebSocket"},
{"connection",
{'Connection',"Upgrade"},
nil,
{"host",
{'Host',"127.0.0.1:8000"},
{"cookie",
{'Cookie',
"z_pid=BoVVuVaOOSJ6Pg1l4pW0; z_sid=z72LVcrbsLKBTI5fda4n"},
nil,nil},
{"origin",
{"Origin","http://127.0.0.1:8000&quot;},
nil,nil}}},
nil}},
"defined_in_wm_req_srv_init","/websocket",
{1,1},
404,0,undefined,undefined},
'GET',
{1,1},
[],"/websocket","/websocket",
{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],
[[zotonic_host|default]],
[],[],[],
[[zotonic_dispatch|websocket]],
[],[],[],[],[],[],[]}}},
[],".",500,1073741824,
[{"z_pid","BoVVuVaOOSJ6Pg1l4pW0"},
{"z_sid","z72LVcrbsLKBTI5fda4n"}],
[],
[{"connection","Upgrade"},
{"cookie",
"z_pid=BoVVuVaOOSJ6Pg1l4pW0; z_sid=z72LVcrbsLKBTI5fda4n"},
{"host","127.0.0.1:8000"},
{"origin","http://127.0.0.1:8000"},
{"upgrade","WebSocket"}],
not_fetched_yet,false,
{0,nil},
<<>>,[],none,[]},
undefined,undefined,undefined,undefined,undefined,
default,'z_depcache$default','z_notifier$default',
'z_session_manager$default',
'z_visitor_manager$default','z_dispatcher$default',
'z_template$default','z_scomp$default',
'z_dropbox$default','z_pivot_rsc$default',
'z_module_indexer$default','z_module_sup$default',
undefined,en,undefined,undefined,[],[],[],[],[],[],
[],
[{zotonic_dispatch,websocket}]}}
** When Server state == {session_srv,
{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
[]},
{{[],[],[],[],[],[],[],[],[],[],[],[],[],[],
[],[]}}},
{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
[]},
{{[],[],[],[],[],[],[],[],[],[],[],[],[],[],
[],[]}}}}
** Reason for termination ==
** {{case_clause,error},
[{z_session_manager,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}

=CRASH REPORT==== 2-Apr-2010::12:42:52 ===
crasher:
initial call: z_session_manager:init/1
pid: <0.335.0>
registered_name: 'z_session_manager$default'
exception exit: {{case_clause,error},
[{z_session_manager,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
in function gen_server:terminate/6
ancestors: [<0.93.0>,z_sites_sup,zotonic_sup,<0.59.0>]
messages: []
links: [<0.93.0>,<0.81.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 1597
stack_size: 24
reductions: 265
neighbours:

=SUPERVISOR REPORT==== 2-Apr-2010::12:42:52 ===
Supervisor: {<0.93.0>,z_site_sup}
Context: child_terminated
Reason: {{case_clause,error},
[{z_session_manager,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
Offender: [{pid,<0.335.0>},
{name,z_session_manager},
{mfa,
{z_session_manager,start_link,
[[{enabled,true},
{host,default},
{hostname,"127.0.0.1:8000"},
{hostalias,"www.example.com"},
{hostalias,"example.com"},
{dbhost,"127.0.0.1"},
{dbport,5432},
{dbuser,"zotonic"},
{dbpassword,"zotonic"},
{dbdatabase,"zotonic"},
{dbschema,"public"},
{adminpassword,"admin"},
{sign_key_simple,<<"9y4ni9csmow4">>},
{sign_key,
<<"98349r8ncrbywcrg28313865cnyosaish4uncwhaio474nyc">>},
{title,<<"Zotonic Default">>},
{subtitle,
<<"Built with Zotonic, the Erlang CMS.">>},
{pagelen,5}]]}},
{restart_type,permanent},
{shutdown,5000},
{child_type,worker}]

=ERROR REPORT==== 2-Apr-2010::12:42:52 ===
webmachine error: path="/websocket"
{exit,
{{{case_clause,error},
[{z_session_manager,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]},
{gen_server,call,
['z_session_manager$default',
{ensure_session,false,
{context,
{wm_reqdata,#Port<0.4562>,
{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],
[[zotonic_host|default]],
[[resource_module|resource_websocket]],
[],[],[],[],[],[],[],[],[],[]}}},
undefined,"defined_in_wm_req_srv_init",undefined,
{wm_log_data,undefined,
{1270,208572,879595},
'GET',
{5,
{"upgrade",
{'Upgrade',"WebSocket"},
{"connection",
{'Connection',"Upgrade"},
nil,
{"host",
{'Host',"127.0.0.1:8000"},
{"cookie",
{'Cookie',
"z_pid=BoVVuVaOOSJ6Pg1l4pW0; z_sid=z72LVcrbsLKBTI5fda4n"},
nil,nil},
{"origin",
{"Origin","http://127.0.0.1:8000"},
nil,nil}}},
nil}},
"defined_in_wm_req_srv_init","/websocket",
{1,1},
404,0,undefined,undefined},
'GET',
{1,1},
[],"/websocket","/websocket",
{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],
[[zotonic_host|default]],
[],[],[],
[[zotonic_dispatch|websocket]],
[],[],[],[],[],[],[]}}},
[],".",500,1073741824,
[{"z_pid","BoVVuVaOOSJ6Pg1l4pW0"},
{"z_sid","z72LVcrbsLKBTI5fda4n"}],
[],
[{"connection","Upgrade"},
{"cookie",
"z_pid=BoVVuVaOOSJ6Pg1l4pW0; z_sid=z72LVcrbsLKBTI5fda4n"},
{"host","127.0.0.1:8000"},
{"origin","http://127.0.0.1:8000"},
{"upgrade","WebSocket"}],
not_fetched_yet,false,
{0,nil},
<<>>,[],none,[]},
undefined,undefined,undefined,undefined,undefined,default,
'z_depcache$default','z_notifier$default',
'z_session_manager$default','z_visitor_manager$default',
'z_dispatcher$default','z_template$default',
'z_scomp$default','z_dropbox$default','z_pivot_rsc$default',
'z_module_indexer$default','z_module_sup$default',undefined,
en,undefined,undefined,[],[],[],[],[],[],[],
[{zotonic_dispatch,websocket}]}}]}},
[{gen_server,call,2},
{z_context,continue_session,1},
{resource_websocket,forbidden,2},
{webmachine_resource,resource_call,3},
{webmachine_resource,do,3},
{webmachine_decision_core,decision,3},
{webmachine_decision_core,handle_request,2},
{webmachine_mochiweb,loop,1}]}

@arjan
Copy link
Member Author

arjan commented Sep 5, 2011

A workaround for anyone testing this is to close the browser tab/window with the admin panel and the start the
server ;)

_Commented on Google Code by _yazzg...@gmail.com**

@arjan
Copy link
Member Author

arjan commented Sep 5, 2011

diff -r ce6e27552ab4 src/support/z_session_manager.erl
--- a/src/support/z_session_manager.erl Tue Apr 06 14:13:42 2010 +0200
+++ b/src/support/z_session_manager.erl Tue Apr 06 13:50:08 2010 +0100
@@ -142,7 +142,7 @@
Pid when is_pid(Pid) orelse AllowNew ->
{_Pid1, Context1, State1} = ensure_session1(SessionId, Pid, Context, State),
{reply, {ok, Context1}, State1};

  •    undefined ->
    
  •    _ ->
         {reply, {error, no_session_pid}, State}
    
    end;

Above patch fixes it.

_Commented on Google Code by _yazzg...@gmail.com**

@arjan
Copy link
Member Author

arjan commented Sep 5, 2011

Thanks. Upon closer inspection I see that the function session_find_pid/2 returns either a pid() or the atom
'error'. I will change the 'undefined' into 'error'.

Thanks for your fix.

_Commented on Google Code by _profile.url**

@arjan
Copy link
Member Author

arjan commented Sep 5, 2011

Closed by revision b92cde363d.

_Commented on Google Code by _profile.url**

@arjan arjan closed this as completed Sep 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant