changeset 148:bac9c3b01692

Check that the ttyrec stream has an fd before passing it to fstat. The stream might not have an fd, presumably if the open isn't complete. Calling fstat then causes crashes.
author John "Elwin" Edwards
date Mon, 06 Jan 2014 09:11:35 -0500
parents 8d6bf19d8227
children 6758d832c10c
files rlgwebd.js
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rlgwebd.js	Wed Jan 01 14:13:10 2014 -0500
+++ b/rlgwebd.js	Mon Jan 06 09:11:35 2014 -0500
@@ -1035,8 +1035,10 @@
     }
   }
   for (var i = 0; i < statusinfo.g.length; i++) {
-    if (statusinfo.g[i].n in sessions) {
-      fs.fstat(sessions[statusinfo.g[i].n].record.fd, makecallback(i));
+    /* fd sometimes isn't a number, presumably when the file isn't open yet. */
+    var ssid = statusinfo.g[i].n;
+    if (ssid in sessions && typeof(sessions[ssid].record.fd) == 'number') {
+      fs.fstat(sessions[ssid].record.fd, makecallback(i));
     }
     else {
       idleset(i, null);