view options.js @ 165:59e62710cbb5

rlgwebd.js: prevent races when reading ttyrecs. DglSession objects read a 12-byte TTYREC header, extract therefrom the length of the data chunk, and then read the data. In between these two reads, the file watcher could trigger another readchunk() invocation, which might attempt to read a header from the beginning of the data chunk. This usually results in expecting a data chunk of several GB and failing to create a Buffer for it. The race is remedied by setting a flag on the DglSession object whenever readchunk() is called, clearing it when both reads complete, and refusing to read if it is already set.
author John "Elwin" Edwards
date Wed, 07 Jan 2015 13:18:35 -0500
parents 99fbc7c55b81
children
line wrap: on
line source

function setup() {
  if (!("lcred" in sessionStorage)) {
    setstatus("You are not logged in.");
    return;
  }
  var url = "/uinfo/email?key=" + sessionStorage.getItem("lcred");
  var req = new XMLHttpRequest();
  req.onreadystatechange = function () {
    if (req.readyState != 4 || req.status != 200) 
      return;
    var reply = JSON.parse(req.responseText);
    if (!("email" in reply)) {
      setstatus("You are not logged in.");
    }
    else {
      setstatus("You are logged in as " + reply.u + ".");
      document.getElementById("input_email").value = reply["email"];
      //document.getElementById("switch").style.display = "block";
    }
  }
  req.open('GET', url, true);
  req.send();
}

function setstatus(stattext) {
  var statnode = document.createTextNode(stattext);
  var statdiv = document.getElementById("ostat");
  statdiv.replaceChild(statnode, statdiv.firstChild);
}

function postemail() {
  if (!("lcred" in sessionStorage))
    return;
  var posturl = "/uinfo/email?key=" + sessionStorage.getItem("lcred");
  var msg = {"v": document.getElementById("input_email").value};
  var req = new XMLHttpRequest();
  req.open('POST', posturl, true);
  req.send(JSON.stringify(msg));
}

function postpw() {
  if (!("lcred" in sessionStorage))
    return;
  var posturl = "/uinfo/pw?key=" + sessionStorage.getItem("lcred");
  var msg = {"v": document.getElementById("input_pw").value};
  var req = new XMLHttpRequest();
  req.open('POST', posturl, true);
  req.send(JSON.stringify(msg));
}