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

Remove leftover debug statements from fileserver #30

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions jennet/fileserver.pony
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use "files"
use "http_server"
use "valbytes"
use "debug"

use @pony_os_errno[I32]()

class _FileServer is RequestHandler
let _filepath: FilePath
Expand Down Expand Up @@ -50,33 +48,19 @@ class _DirServer is RequestHandler

primitive _ReadFile
"""
Read a whole file into an `Array[U8] iso^` doing multiple calls to read in a loop.
Read a whole file into a `ByteArrays` instance doing multiple calls to read in a loop.

This is not optimally friendly to the whole runtime as it is hogging a scheduler thread doing blocking system calls.
"""
fun apply(path: FilePath): ByteArrays ? =>
Debug("Reading file " + path.path + " ...")
with file = OpenFile(path) as File do
file.clear_errno()
let file_size = file.size()

if file_size == -1 then
let err_str = match file.errno()
| FileError => "ERROR"
| FilePermissionDenied => "Permission denied"
| FileBadFileNumber => "Bad file number"
| FileEOF => "EOF"
| FileOK => "OK"
| FileExists => "EXISTS"
end
Debug("ERROR: " + @pony_os_errno().string() + " " + err_str)
error
end
Debug("file_size == " + if file_size == -1 then "-1" else file_size.string() end)
var bs = ByteArrays
var bytes_read = USize(0)
while bytes_read < file_size do
Debug("Reading " + (file_size - bytes_read).string() + " bytes from " + path.path)
let data = file.read(file_size - bytes_read)
bytes_read = bytes_read + data.size()
bs = bs + consume data
Expand Down
Loading