reactphp / filesystem

Evented filesystem access.
MIT License
135 stars 40 forks source link

Use random bytes API for child process file descriptor #53

Closed ghost closed 5 years ago

ghost commented 5 years ago

This PR changes the file descriptor from the array size to random bytes. Compatibility is guaranteed through random_compat, although PHP5 support is running out in one month.

Using random bytes guarantees no clashing file descriptors, that means re-using and overwriting a currently active file descriptor.

ghost commented 5 years ago

PHP does not re-use numeric integers. If we wanted to re-use IDs we'd have to make our own management for this. The only numeric key PHP re-uses is the PHP_INT_MAX, but only if the key is not already present, otherwise an error will be thrown.