<hannes>
so, create_connection tcp dst >>= fun flow -> .. read/write flow >>= fun () -> .. close flow
<argent_smith>
hannes i use both (ll 26, 27 of the gist)
<hannes>
argent_smith: the connect () / disconnect () is part of the Mirage_device API (https://github.com/mirage/mirage-device) -- you should use the create_connection .. read/write .. close (mostly Mirage_flow API).
<hannes>
how do you know / experience the leak? can you run it as unix process using the socket stack, and figure with ktrace (system call tracing) whether the open/socket call that creates a file descriptor is at the end of the communication being close()d?
<hannes>
in your error handling (read/write) I fail to see any calls to close() <-- this may leak fd's
<hannes>
and then the bizarre thing is in l25 -- so created a TCP connection (l18), send/recv some data (l23), then you sleep (l24) and call loop (l25) again -- when do you expect l26 (the TCP close) being executed?
<hannes>
I'd suggest to move l26 just after the l23, before l24 -- i.e. once you send and received data, and no longer need the TCP flow
<hannes>
(does this make sense?)
<argent_smith>
ah, yes, l25 is not in its place!
<argent_smith>
will fix it, thnx!
mahmudov has joined #mirage
<argent_smith>
hannes fixed. thnx )
<argent_smith>
also, I removed disconnect
<hannes>
connect .. disconnect is about the lifetime of the tcp layer (and afaict, connect is only ever called once, mainly by code generated by mirage), and disconnect is some sort of overengineering for purposes not really clear to me
<hannes>
i think at some point someone decided that when you boot a system, you also would like a clean shutdown... reality of mirageos is slightly different atm.. but good that your code is fixed now :)
<argent_smith>
so, i use create_connection >>= ... >>= close flow. right?
<hannes>
yes
mahmudov has quit [Remote host closed the connection]