mighty-gerbils / gerbil

Gerbil Scheme
https://cons.io
GNU Lesser General Public License v2.1
1.16k stars 112 forks source link

BufferedReader on Reader on input-port peeks-and-throws, not waiting for input to trickle in #1248

Open metaleap opened 5 months ago

metaleap commented 5 months ago

From chat, by @metaleap:

somehow my use of httpds read-request-headers on a BufferedReader based on stdin immediately raises eof instead of waiting for actual input, what am I missing? (surely any reader backing a BufferedReader will take some time before something can be read!..) minimal repro gist here

Runtime error on the read-request-headers call:

*** ERROR IN _/revrepl/main#main -- This object was raised: eof
*** ERROR IN std/misc/process#run-process__% -- 
*** ERROR IN "misc/process.ss"@28.35-28.46 [ProcessError]: process exited with non-zero status
--- irritants: "revrepl" 17920 (path: "revrepl" arguments: () environment: #f directory: #f stdin-redirection: #f stdout-redirection: #f stderr-redirection: #f pseudo-terminal: #f show-console: #f) 
--- continuation backtrace:
[0] raise                                                                              
[1] std/misc/process#run-process__%                                                                                                                                            ((if (procedure? _%check-status260866%_) _%check-status260866%_ std/misc/proc...

By @vyzo:

so my uderstanding of the problem is that gambit's read-subu8vector treats the need parameter as "don't block" while gerbil's reader treats the need parameter as "error if you can't read that many" so there is impedance mismatch which is not there if peek-u8 is used directly by making a buffered reader directly on top the of the port also looking at the code, the issue is that raw-binary-input-port is missing some methods for BufferedReader