Posted to tcl by sebres at Fri Apr 26 16:24:23 GMT 2019view raw
- ### --------------------------------------------------------------
- ### part of test-cases for bug-b9bfaf5fdb
- ### (here my class-architecture and test-suite are used, but I hope it is approximately clear)
- ### --------------------------------------------------------------
- ## === before fix of bug-[b9bfaf5fdb]:
- method read {ch size} {
- while 1 {
- ## returns buffer read from channel (or "" for eof), or throws EAGAIN if no data currently:
- set buf [::fcgi::readb [$this . reqid] $size]
- ## if no data, we will signal the higher layers that EOF has been reached on the channel:
- if {![set len [string length $buf]] && ![fcgi::eof [$this . reqid]]} {
- ## todo: correct this tcl-error (see [b9bfaf5fdb]):
- ## reflected channel should also accept return code EAGAIN in blocking mode also
- ## (and wait in the main worker processing channel or in core, but not in this thread) ...
- if {[$this . blocking : 0]} {
- ## main channel is in blocking mode, don't return - vwait here for read
- ## (caution, we can process another request in this fcgi-thread, so don't really block)...
- vwait [$this . reqid]
- continue
- }
- ## not eof, retry later:
- return -code error EAGAIN
- }
- return $buf
- }
- }
- ## === after fix of bug-[b9bfaf5fdb]:
- method read {ch size} {
- while 1 {
- ## returns buffer read from channel (or "" for eof), or throws EAGAIN if no data currently:
- set buf [::fcgi::readb [$this . reqid] $size]
- ## if no data, we will signal the higher layers that EOF has been reached on the channel:
- if {![set len [string length $buf]] && ![fcgi::eof [$this . reqid]]} {
- ## not eof, retry later:
- return -code error EAGAIN
- }
- return $buf
- }
- }
Comments
Posted by sebres at Fri Apr 26 17:15:27 GMT 2019 [text] [code]
basically I forgot to remove "while 1 {" in my test-cases here (after fix), there is no cycle in second case: either it throws EGAIN or it returns a buffer (or even "" for EOF).