!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/share/.cache/yarn/v6/npm-atomically-1.7.0-integrity/node_modules/atomically/test/   drwxr-xr-x
Free 13.21 GB of 57.97 GB (22.78%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     concurrency.js (4.33 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict'

process.setMaxListeners(1000000);

const fs = require('fs')
const {test} = require('tap')
const requireInject = require('require-inject')

// defining mock for fs so its functions can be modified
const fsMock = Object.assign ( {}, fs, {
  /* ASYNC */
  mkdir (filename, opts, cb) {
    return cb(null);
  },
  realpath (filename, cb) {
    return cb(null, filename)
  },
  open (tmpfile, options, mode, cb) {
    if (/noopen/.test(tmpfile)) return cb(new Error('ENOOPEN'))
    cb(null, tmpfile)
  },
  write (fd) {
    const cb = arguments[arguments.length - 1]
    if (/nowrite/.test(fd)) return cb(new Error('ENOWRITE'))
    cb()
  },
  fsync (fd, cb) {
    if (/nofsync/.test(fd)) return cb(new Error('ENOFSYNC'))
    cb()
  },
  close (fd, cb) {
    cb()
  },
  chown (tmpfile, uid, gid, cb) {
    if (/nochown/.test(tmpfile)) return cb(new Error('ENOCHOWN'))
    cb()
  },
  chmod (tmpfile, mode, cb) {
    if (/nochmod/.test(tmpfile)) return cb(new Error('ENOCHMOD'))
    cb()
  },
  rename (tmpfile, filename, cb) {
    if (/norename/.test(tmpfile)) return cb(new Error('ENORENAME'))
    cb()
  },
  unlink (tmpfile, cb) {
    if (/nounlink/.test(tmpfile)) return cb(new Error('ENOUNLINK'))
    cb()
  },
  stat (tmpfile, cb) {
    if (/nostat/.test(tmpfile)) return cb(new Error('ENOSTAT'))
    cb()
  },
  /* SYNC */
  mkdirSync (filename) {},
  realpathSync (filename, cb) {
    return filename
  },
  openSync (tmpfile, options) {
    if (/noopen/.test(tmpfile)) throw new Error('ENOOPEN')
    return tmpfile
  },
  writeSync (fd) {
    if (/nowrite/.test(fd)) throw new Error('ENOWRITE')
  },
  fsyncSync (fd) {
    if (/nofsync/.test(fd)) throw new Error('ENOFSYNC')
  },
  closeSync () {},
  chownSync (tmpfile, uid, gid) {
    if (/nochown/.test(tmpfile)) throw new Error('ENOCHOWN')
  },
  chmodSync (tmpfile, mode) {
    if (/nochmod/.test(tmpfile)) throw new Error('ENOCHMOD')
  },
  renameSync (tmpfile, filename) {
    if (/norename/.test(tmpfile)) throw new Error('ENORENAME')
  },
  unlinkSync (tmpfile) {
    if (/nounlink/.test(tmpfile)) throw new Error('ENOUNLINK')
  },
  statSync (tmpfile) {
    if (/nostat/.test(tmpfile)) throw new Error('ENOSTAT')
  }
})

const {writeFile: writeFileAtomic} = requireInject('../dist', { fs: fsMock });

// preserve original functions
const oldRealPath = fsMock.realpath
const oldRename = fsMock.rename

test('ensure writes to the same file are serial', t => {
  let fileInUse = false
  const ops = 5 // count for how many concurrent write ops to request
  t.plan(ops * 3 + 3)
  fsMock.realpath = (...args) => {
    t.false(fileInUse, 'file not in use')
    fileInUse = true
    oldRealPath(...args)
  }
  fsMock.rename = (...args) => {
    t.true(fileInUse, 'file in use')
    fileInUse = false
    oldRename(...args)
  }
  const {writeFile: writeFileAtomic} = requireInject('../dist', { fs: fsMock });
  for (let i = 0; i < ops; i++) {
    writeFileAtomic('test', 'test', err => {
      if (err) t.fail(err)
      else t.pass('wrote without error')
    })
  }
  setTimeout(() => {
    writeFileAtomic('test', 'test', err => {
      if (err) t.fail(err)
      else t.pass('successive writes after delay')
    })
  }, 500)
})

test('allow write to multiple files in parallel, but same file writes are serial', t => {
  const filesInUse = []
  const ops = 5
  let wasParallel = false
  fsMock.realpath = (filename, ...args) => {
    filesInUse.push(filename)
    const firstOccurence = filesInUse.indexOf(filename)
    t.equal(filesInUse.indexOf(filename, firstOccurence + 1), -1, 'serial writes') // check for another occurence after the first
    if (filesInUse.length > 1) wasParallel = true // remember that a parallel operation took place
    oldRealPath(filename, ...args)
  }
  fsMock.rename = (filename, ...args) => {
    filesInUse.splice(filesInUse.indexOf(filename), 1)
    oldRename(filename, ...args)
  }
  const {writeFile: writeFileAtomic} = requireInject('../dist', { fs: fsMock });
  t.plan(ops * 2 * 2 + 1)
  let opCount = 0
  for (let i = 0; i < ops; i++) {
    writeFileAtomic('test', 'test', err => {
      if (err) t.fail(err, 'wrote without error')
      else t.pass('wrote without error')
    })
    writeFileAtomic('test2', 'test', err => {
      opCount++
      if (opCount === ops) t.true(wasParallel, 'parallel writes')

      if (err) t.fail(err, 'wrote without error')
      else t.pass('wrote without error')
    })
  }
})

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0047 ]--