Running on Termux asserts
Tried to run it on termux proot-distro and got such kinds of errors:
/data/data/com.termux/files/home/.../odin-http/server.odin(141:2) runtime assertion: errno == os.ERROR_NONE
/data/data/com.termux/files/home/.../odin-http/nbio/_io_uring/os.odin(94:2) runtime assertion: (params.features & IORING_FEAT_SINGLE_MMAP) != 0
It probably doesn't support IO Uring.
It's in the plans to have an alternative backend to choose from but that's a bit away.
It appears to be supported
$ sudo grep io_uring_setup /proc/kallsyms
0000000000000000 T __arm64_sys_io_uring_setup
0000000000000000 t __arm64_sys_io_uring_setup.cfi_jt
0000000000000000 d _eil_addr___arm64_sys_io_uring_setup
But
#include <errno.h>
#include <linux/io_uring.h>
#include <stddef.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv) {
if (syscall(__NR_io_uring_register, 0, IORING_UNREGISTER_BUFFERS, NULL, 0) && errno == ENOSYS) {
printf("No io_uring\n");
} else {
printf("Ye io_uring\n");
}
}
is not accessible from proot-distro
[root@localhost ...]# ./test_io_uring.o
No io_uring
while not working in usual mode, and working in sudo
$ ./test_io_uring.o
Bad system call
$ sudo ./test_io_uring.o
Ye io_uring
Oh how fun it is working from android ;)
Aha, so it doesn't assert when running in sudo then?
Unfortunately I cannot check for this right now. I cannot get odin to compile on regular termux, because its libllvm is version 19, which is not supported by odin. I didn't have enough time to look into the underlying reason/hack it.
After some modifications to the odin, I was able to get this working. The only thing that confused me at first is that the example server does not serve the / which made me first think that the server was not properly running. Second thing is that it's not cancallable with Ctrl-C. That's quite bad to have to go to ps aux to shut down the server immideately. While pressing Ctrl-D will print [2024-11-06 18:07:29] [server.odin:289:_server_thread_shutdown()] shutdown: done but the program remained running for quite some time, finally stopping after about a minute.
But overall looking fowrard to using it.
So / and /index serve an html file. Wold be nice to mention that in the readme!
What do you mean?
Example in the readme serves an html file for /index. So just compiling and running the example can lead to confusion, as the index will error 404
index :: proc(req: ^http.Request, res: ^http.Response) {
http.respond_file(res, "examples/complete/static/index.html")
}