Skip to content
This repository
Browse code

Merge pull request #2436 from ajaxorg/fix-debugger-race

[Liskov] Fix debugger race condition
  • Loading branch information...
commit 7c8b91796a35ab9f9f95c37aa43c4329b760e82e 2 parents 6b01123 + c6325e5
Harutyun Amirjanyan nightwing authored

Showing 1 changed file with 21 additions and 19 deletions. Show diff stats Hide diff stats

  1. +21 19 plugins-server/cloud9.run.node-debug/node_debug-runner.js
40 plugins-server/cloud9.run.node-debug/node_debug-runner.js
@@ -77,19 +77,19 @@ function setup (NodeRunner) {
77 77
78 78 proto.createChild = function(callback) {
79 79
80   - var self = this;
  80 + var _self = this;
81 81
82 82 var port = this.debugPort;
83 83
84   - if (self.breakOnStart)
85   - self.nodeArgs.push("--debug-brk=" + port);
  84 + if (_self.breakOnStart)
  85 + _self.nodeArgs.push("--debug-brk=" + port);
86 86 else
87   - self.nodeArgs.push("--debug=" + port);
  87 + _self.nodeArgs.push("--debug=" + port);
88 88
89   - Parent.prototype.createChild.call(self, callback);
  89 + Parent.prototype.createChild.call(_self, callback);
90 90
91 91 setTimeout(function() {
92   - self._startDebug(port);
  92 + _self._startDebug(port);
93 93 }, 100);
94 94 };
95 95
@@ -118,42 +118,44 @@ function setup (NodeRunner) {
118 118 };
119 119
120 120 proto._startDebug = function(port) {
121   - var self = this;
  121 + var _self = this;
122 122 function send(msg) {
123   - self.eventEmitter.emit(self.eventName, msg);
  123 + _self.eventEmitter.emit(_self.eventName, msg);
124 124 }
125   - this.nodeDebugProxy = new NodeDebugProxy(this.vfs, port);
126   - this.nodeDebugProxy.on("message", function(body) {
  125 + var nodeDebugProxy = new NodeDebugProxy(this.vfs, port);
  126 + nodeDebugProxy.on("message", function(body) {
127 127 // console.log("REC", body)
128 128 send({
129 129 "type": "node-debug",
130   - "pid": self.pid,
  130 + "pid": _self.pid,
131 131 "body": body,
132   - "extra": self.extra
  132 + "extra": _self.extra
133 133 });
134 134 });
135 135
136   - this.nodeDebugProxy.on("connection", function() {
  136 + nodeDebugProxy.on("connection", function() {
137 137 // console.log("Debug proxy connected");
138 138 send({
139 139 "type": "node-debug-ready",
140   - "pid": self.pid,
141   - "extra": self.extra
  140 + "pid": _self.pid,
  141 + "extra": _self.extra
142 142 });
143   - self._flushSendQueue();
  143 + _self.nodeDebugProxy = nodeDebugProxy;
  144 + _self._flushSendQueue();
144 145 });
145 146
146   - this.nodeDebugProxy.on("end", function(err) {
  147 + nodeDebugProxy.on("end", function(err) {
147 148 // console.log("nodeDebugProxy terminated");
148 149 if (err) {
149 150 // TODO send the error message back to the client
150 151 // _self.send({"type": "jvm-exit-with-error", errorMessage: err}, null, _self.name);
151 152 console.error(err);
152 153 }
153   - delete self.nodeDebugProxy;
  154 + if (_self.nodeDebugProxy)
  155 + delete _self.nodeDebugProxy;
154 156 });
155 157
156   - this.nodeDebugProxy.connect();
  158 + nodeDebugProxy.connect();
157 159 };
158 160 }
159 161

0 comments on commit 7c8b917

Please sign in to comment.
Something went wrong with that request. Please try again.