diff --git a/netproto.c b/netproto.c index 22f3b00..ffdddb6 100644 --- a/netproto.c +++ b/netproto.c @@ -98,17 +98,18 @@ void register_WS(onion_websocket *ws){ void send_all_WS(char *data){ if(strlen(data) == 0) return; // zero length WSlist *l = wslist; + if(!l) return; int cnt = 0; unregister_WS(); // check for dead ws while(l){ - DBG("try to send"); + //DBG("try to send"); if(onion_websocket_printf(l->ws, "%s", data) <= 0){ // dead websocket? remove it from list DBG("Error printing - check for dead"); unregister_WS(); }else ++cnt; l = l->next; } - DBG("Send message %s to %d clients", data, cnt); + //DBG("Send message %s to %d clients", data, cnt); } void unregister_WS(){ @@ -128,6 +129,7 @@ void unregister_WS(){ wslist->last = l->prev; // we should delete last element } WSlist *nxt = l->next; + if(l == wslist) wslist = nxt; // delete the first element FREE(l); l = nxt; continue; diff --git a/static/auth.js b/static/auth.js index 6bec214..794889f 100644 --- a/static/auth.js +++ b/static/auth.js @@ -43,7 +43,9 @@ auth = function(){ s.type = 'text/css'; s.innerHTML = '.shadow{position:absolute;text-align:center;vertical-align:center;top:0;display:none;left:0;width:100%;height:100%;background-color:lightGrey;opacity:0.9;}'; document.body.appendChild(s); - d.innerHTML = "