MCPcopy
hub / github.com/plasma-umass/browsix / blobReady

Method blobReady

src/kernel/kernel.ts:2206–2266  ·  view source on GitHub ↗
(blobUrl: string)

Source from the content-addressed store, hash-verified

2204 }
2205
2206 blobReady(blobUrl: string): void {
2207 if (this.worker) {
2208 this.worker.onmessage = undefined;
2209 this.worker.terminate();
2210 this.worker = undefined;
2211 }
2212 this.timeWorkerStart = performance.now();
2213 this.worker = new Worker(blobUrl);
2214 this.worker.onmessage = this.syscallHandler.bind(this);
2215 this.worker.onerror = (err: ErrorEvent): void => {
2216 // if we're already a zombie, we have already
2217 // exited the process (according to the
2218 // kernel's record keeping) through an explict
2219 // exit() call. Ignore this onerror message.
2220 if (this.state === TaskState.Zombie)
2221 return;
2222
2223 // in this case, our onerror handler was
2224 // called before we received any explicit exit
2225 // message
2226
2227 // console.log("onerror arrived before exit() syscall");
2228
2229 if (this.files[2]) {
2230 console.log(err);
2231 let msg = new Buffer('Error while executing ' + this.pendingExePath + ': ' + err.message + '\n', 'utf8');
2232 this.files[2].write(msg, -1, () => {
2233 // setTimeout on purpose
2234 setTimeout(() => {
2235 this.kernel.exit(this, -1);
2236 });
2237 });
2238 } else {
2239 // setTimeout on purpose
2240 setTimeout(() => {
2241 this.kernel.exit(this, -1);
2242 });
2243 }
2244 };
2245
2246 let heap = this.heap;
2247 let args = this.forkArgs;
2248
2249 this.heap = undefined;
2250 this.forkArgs = undefined;
2251
2252 this.args = this.pendingArgs;
2253 this.env = this.pendingEnv;
2254 this.exePath = this.pendingExePath;
2255 this.pendingArgs = undefined;
2256 this.pendingEnv = undefined;
2257 this.pendingExePath = undefined;
2258
2259 this.signal(
2260 'init',
2261 [this.args, this.env, this.kernel.debug, this.pid, heap, args],
2262 heap ? [heap] : null);
2263

Callers 2

constructorMethod · 0.95
fileReadMethod · 0.95

Calls 5

signalMethod · 0.95
nowMethod · 0.80
bindMethod · 0.65
writeMethod · 0.65
exitMethod · 0.65

Tested by

no test coverage detected