Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSFilterでバッファーがあふれると,TSFilter._write()が呼び出されなくなる #57

Closed
masnagam opened this issue Apr 26, 2019 · 0 comments

Comments

@masnagam
Copy link
Contributor

Environment

  • Version of Mirakurun: 2.10.1
  • Version of Node: v10.15.3
  • Version of NPM: x6.4.1
  • Platform: 理論上どこでも発生

Issue

TSFilterでバッファーがあふれたとき,callbackを呼び出していません.そのため,chunkはまだ処理中であるとNode.jsは判断し,TSFilter._write()は二度と呼び出されなくなります.

TSFilter. _overflowTimerは常にタイムアウトし,オーバーフロー状態が回復することはありません.

確認方法

ソースコードを書き換えるのが一番簡単です.以下はコンパイル後のTSFilter.js

        this.highWaterMark = 1024 * 1024 * 0;  // 大抵の場合,すぐにデータが読み出されるので,これでも動きます
        this._overflowTimeLimit = 1000 * 5;  // 30s待ちたくないので..
    ...
    _write(chunk, encoding, callback) {
        if (this._closed === true) {
            callback(new Error("TSFilter has closed already"));
            return;
        }
        if (this._overflowTimer !== null) {
            // オーバーフローすると上記条件になります
            // 再び_writeが呼び出されるなら,以下が出力されるはず...
            log.info("==================================");
        }

サービスのスキャンやEGP情報の収集などが一段落して落ち着いてきたら,ストリームをリクエスト

$ curl -sSL http://mirakurun:40772/api/channels/GR/26/stream?encode=1 >/dev/null

TSFilter._writeが呼び出されないことが確認できます.

2019-04-26T22:40:47.655+09:00 info: TSFilter has created (serviceId=null, eventId=null)
2019-04-26T22:40:47.658+09:00 debug: TunerDevice#0 start stream for user `172.17.0.1:35010` (priority=0)...
2019-04-26T22:40:47.660+09:00 debug: TunerDevice#0 spawn...
2019-04-26T22:40:47.681+09:00 info: TunerDevice#0 process has spawned by command `node lib/remote mirakurun-remote 40772 GR 26` (pid=637)
2019-04-26T22:40:47.684+09:00 info: TunerDevice#0 streaming to user `172.17.0.1:35010` (priority=0)
2019-04-26T22:40:48.458+09:00 info: TunerDevice#0 > remote: { host: 'mirakurun-remote',
  port: 40772,
  type: 'GR',
  channel: '26',
  decode: false }
2019-04-26T22:40:49.429+09:00 debug: TSFilter detected NIT PID=16
2019-04-26T22:40:49.431+09:00 debug: TSFilter detected PMT PID=496 as serviceId=1032 (NHKEテレ1東京)
2019-04-26T22:40:49.432+09:00 debug: TSFilter parsing serviceId=1032 (NHKEテレ1東京)
2019-04-26T22:40:49.434+09:00 debug: TSFilter parsing serviceId=1033 (NHKEテレ2東京)
2019-04-26T22:40:49.435+09:00 debug: TSFilter parsing serviceId=1034 (NHKEテレ3東京)
2019-04-26T22:40:49.437+09:00 debug: TSFilter parsing serviceId=1416 (NHK携帯2)
2019-04-26T22:40:49.438+09:00 debug: TSFilter detected PMT PID=1008 as serviceId=1033 (NHKEテレ2東京)
2019-04-26T22:40:49.439+09:00 debug: TSFilter detected PMT PID=1264 as serviceId=1034 (NHKEテレ3東京)
2019-04-26T22:40:49.441+09:00 debug: TSFilter detected PMT PID=8136 as serviceId=1416 (NHK携帯2)
2019-04-26T22:40:50.257+09:00 warn: TSFilter is overflowing the buffer...
2019-04-26T22:40:53.242+09:00 debug: saving programs...
2019-04-26T22:40:53.246+09:00 info: save db `/usr/local/var/db/mirakurun/programs.json` w/ integirty (xxx=)
2019-04-26T22:40:55.258+09:00 error: TSFilter will closing because reached time limit of overflowing the buffer...
2019-04-26T22:40:55.261+09:00 info: TSFilter has closed (serviceId=null, eventId=null)
2019-04-26T22:40:55.263+09:00 debug: TunerDevice#0 end stream for user `172.17.0.1:35010` (priority=0)...
2019-04-26T22:40:55.264+09:00 info: TunerDevice#0 end streaming to user `172.17.0.1:35010` (priority=0)
2019-04-26T22:40:55.272+09:00 info: 172.17.0.1 - GET /api/channels/GR/26/stream?encode=1 HTTP/1.1 200 - - 1965.872 ms curl/7.54.0
2019-04-26T22:40:58.265+09:00 debug: TunerDevice#0 kill...
2019-04-26T22:40:58.271+09:00 info: TunerDevice#0 > remote: exit.
2019-04-26T22:40:58.301+09:00 info: TunerDevice#0 process has closed with exit code=0 by signal `null` (pid=637)
2019-04-26T22:40:58.418+09:00 debug: TunerDevice#0 released

修正方法

chunkは捨てられるのでcallbackを呼び出だすだけでOK(後ほどPRを出します).

kanreisa pushed a commit that referenced this issue May 12, 2019
Calling `callback()` is required for receiving subsequent chunks even
when the chunk is dropped.

This change can fix the issue #57.
@kanreisa kanreisa assigned kanreisa and unassigned kanreisa May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants