Posted to tcl by sebres at Fri Apr 26 16:24:23 GMT 2019view raw

  1. ### --------------------------------------------------------------
  2. ### part of test-cases for bug-b9bfaf5fdb
  3. ### (here my class-architecture and test-suite are used, but I hope it is approximately clear)
  4. ### --------------------------------------------------------------
  5.  
  6. ## === before fix of bug-[b9bfaf5fdb]:
  7.  
  8. method read {ch size} {
  9. while 1 {
  10. ## returns buffer read from channel (or "" for eof), or throws EAGAIN if no data currently:
  11. set buf [::fcgi::readb [$this . reqid] $size]
  12. ## if no data, we will signal the higher layers that EOF has been reached on the channel:
  13. if {![set len [string length $buf]] && ![fcgi::eof [$this . reqid]]} {
  14. ## todo: correct this tcl-error (see [b9bfaf5fdb]):
  15. ## reflected channel should also accept return code EAGAIN in blocking mode also
  16. ## (and wait in the main worker processing channel or in core, but not in this thread) ...
  17. if {[$this . blocking : 0]} {
  18. ## main channel is in blocking mode, don't return - vwait here for read
  19. ## (caution, we can process another request in this fcgi-thread, so don't really block)...
  20. vwait [$this . reqid]
  21. continue
  22. }
  23. ## not eof, retry later:
  24. return -code error EAGAIN
  25. }
  26. return $buf
  27. }
  28. }
  29.  
  30. ## === after fix of bug-[b9bfaf5fdb]:
  31.  
  32. method read {ch size} {
  33. while 1 {
  34. ## returns buffer read from channel (or "" for eof), or throws EAGAIN if no data currently:
  35. set buf [::fcgi::readb [$this . reqid] $size]
  36. ## if no data, we will signal the higher layers that EOF has been reached on the channel:
  37. if {![set len [string length $buf]] && ![fcgi::eof [$this . reqid]]} {
  38. ## not eof, retry later:
  39. return -code error EAGAIN
  40. }
  41. return $buf
  42. }
  43. }
  44.  

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).