icewind1991 / files_inotify

Adds support detecting changes in local external storages with occ files_external:notify
29 stars 3 forks source link

Message loop: No stream arrays were passed at #7

Closed helmo closed 6 years ago

helmo commented 6 years ago

After installing I collected 20GB of log with just this line in a matter of hours.

{"reqId":"WN0Ln3m33RFBhC7pk2TR","level":3,"time":"2018-05-13T18:09:04+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"stream_select(): No stream arrays were passed at \/www\/cloud\/apps\/files_inotify\/lib\/Storage\/NotifyHandler.php#181","userAgent":"--","version":"13.0.0.14"}

I'm not sure how the $read array becomes invalid, but adding ' && !empty($read)' in the while statement seems to help.

tmolitor-stud-tu commented 5 years ago

This is plainly wrong and doesn't fix the underlying bug but hides it! stream_select() changes the arrays passed by reference to only include those streams readable: https://www.php.net/manual/de/function.stream-select.php

The bug reported here resulted from the timeout in stream_select(). If $this->fd listed in $read is not readable after 60 seconds, stream_select() will return and $read is then modified to list all streams readable (none in this case). Subsequent calls to stream_select() operate on an empty $read array afterwards. That's the underlying bug.

Your "fix" made matters worse because the files_external:notify command now terminates after ~60 seconds instead of running continuously (as stated in the docs).

Correct fix would be to set $read = [$this->fd] before every stream_select() call, I'll do a pull request.