1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2024-10-27 18:34:01 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Mathias Buus
21658b5ebb 2.2.6 2020-06-03 21:26:19 +02:00
Mathias Buus
34554d664b pass down array buffer in timeout 2020-06-03 21:26:08 +02:00
Mathias Buus
14b3a23d68 2.2.5 2020-06-02 16:15:01 +02:00
Mathias Buus
3d8ddd21b5 wrong argument in timeout switch 2020-06-02 16:14:59 +02:00
Mathias Buus
fc92548561 2.2.4 2020-06-02 16:10:23 +02:00
Mathias Buus
7f529df642 fix timeout assert crashes 2020-06-02 16:10:19 +02:00
2 changed files with 22 additions and 5 deletions

View File

@ -230,7 +230,8 @@ class Fuse extends Nanoresource {
return function (nativeHandler, opCode, ...args) {
const sig = signal.bind(null, nativeHandler)
const boundSignal = to ? autoTimeout(sig) : sig
const input = [...args]
const boundSignal = to ? autoTimeout(sig, input) : sig
const funcName = `_op_${name}`
if (!self[funcName] || !self._implemented.has(op)) return boundSignal(-1, ...defaults)
return self[funcName].apply(self, [boundSignal, ...args])
@ -247,16 +248,32 @@ class Fuse extends Nanoresource {
return process.nextTick(nativeSignal, ...arr)
}
function autoTimeout (cb) {
function autoTimeout (cb, input) {
let called = false
const timeout = setTimeout(timeoutWrap, to, TIMEOUT_ERRNO)
return timeoutWrap
function timeoutWrap (...args) {
function timeoutWrap (err, ...args) {
if (called) return
called = true
clearTimeout(timeout)
cb(...args)
if (err === TIMEOUT_ERRNO) {
switch (name) {
case 'write':
case 'read':
return cb(TIMEOUT_ERRNO, 0, input[2].buffer)
case 'setxattr':
return cb(TIMEOUT_ERRNO, input[2].buffer)
case 'getxattr':
return cb(TIMEOUT_ERRNO, input[2].buffer)
case 'listxattr':
return cb(TIMEOUT_ERRNO, input[1].buffer)
}
}
cb(err, ...args)
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "fuse-native",
"version": "2.2.3",
"version": "2.2.6",
"description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api",
"main": "index.js",
"bin": {