From 3ff3f7bfc7d1b4d7d3bea7895fac861e24ea74ce Mon Sep 17 00:00:00 2001 From: Adam Yi Date: Mon, 6 Jul 2020 09:59:19 +0000 Subject: [PATCH] fix file descriptor leak in example http server code --- examples/http/minified_server.bf | 13 +++++++------ examples/http/server.bf | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/examples/http/minified_server.bf b/examples/http/minified_server.bf index bd69b03..2c8b99f 100644 --- a/examples/http/minified_server.bf +++ b/examples/http/minified_server.bf @@ -51,9 +51,10 @@ +><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>+>>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<>>+>>>++>->-><<<<< -<<<<<<<<<<%[-]>[-]>[-]>[-]<<<+++>+>>+<<<%>>>>>>>>>>>>>>>>>>[>]>>[-]<<<[[-]<]<<<[-]<[-]<[ --]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<< -<<<<<[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>> ->>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>[-]+++>[-]>[-]+>[-]++>[-]> -[-]+>[-]+>[-]>[-]+>[-]>[-]+++>[-]>[-]+>>>>>>>>>>>>>>>>>>>>[-]>>[-]++++++++++++++++>[-]>[ --]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+] +<<<<<<<<<<%[-]>[-]>[-]>[-]<<<+++>+>>+<<<%>>>[-]>[-]>[-]>[-]<<<+++>+>>+<<<%<<<>>>>>>>>>>> +>>>>>>>[>]>>[-]<<<[[-]<]<<<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[ +-]<[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<< +<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<[-]>[-]+++>[-]>[-]+>[-]++>[-]>[-]+>[-]+>[-]>[-]+>[-]>[-]+++>[-]>[-]+>>>>>>>>>>>>>> +>>>>>>[-]>>[-]++++++++++++++++>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<+] diff --git a/examples/http/server.bf b/examples/http/server.bf index 7c5329d..f704aba 100644 --- a/examples/http/server.bf +++ b/examples/http/server.bf @@ -556,6 +556,35 @@ close() ======================================================================= Call close() % +close() ======================================================================= + + Move to cell 51 + >>> + + Close the opened file + + The current cell is 49 + The source file descriptor is in cell 53 + + Zero all cells 49 to 52 + [-]>[-]>[-]>[-]<<< + + +++ > close(): 3 + + > Arg count: 1 + + Arg 1: int fd + (0) > Arg type: 0 + + Arg len: 1 + (Arg value is already filled in) + <<< + + Call close() + % + + Move back to cell 48 + <<< + + Clean up and prepare to loop back to listen() ================================= >>>>>>>>>>>>>>>>>>[>]>>[-]<<<[[-]<]