douping7975 2015-06-29 22:55
浏览 33
已采纳

为什么包括调用stream_flush?

I have written a stream wrapper and when I call include foo://bar my stream_flush implementation gets called. stream_open gets called with rb. So... why is flush called? Since the file is opened read only I do not really have anything to do there if my understanding of stream_flush is correct but then again if my understanding would be correct it wouldn't be called in the first place.

Edit: since this got an "unclear what you are asking" close vote: the question really is, what should I do in my stream_flush implementation when it is called on a read only fie?

  • 写回答

1条回答 默认 最新

  • douchi0028 2015-06-30 02:00
    关注

    stream_flush was generally called when a stream is being closed. I don't really see any reason why it's done always. It makes sense when something was written, but not really when nothing was written at all (aka reading only).

    In code is noted /* make sure everything is saved */, which is totally fine if anything has been written.

    Fixed via http://git.php.net/?p=php-src.git;a=commitdiff;h=6ad9cd5367734276d624d6d2a03406ed0d0cd08b (PHP 7.0 tree) ... stream_flush now only ever is called when either explicitly flushed or upon close while something was written, but not yet flushed. Also clarified in docs http://svn.php.net/viewvc/phpdoc/en/trunk/reference/stream/streamwrapper/stream-flush.xml?r1=337084&r2=337083&pathrev=337084 (may take until Friday that all docs are rebuilt).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题