Code Monkey home page Code Monkey logo

Comments (4)

KatelynHaworth avatar KatelynHaworth commented on June 29, 2024

Hey Patrick,

I'm glad this library is of some help to someone. With the closing of the *os.File variables, the closing of those files doesn't affect the underlying socket, it just closes the access to the file descriptor definer. Where as calling syscall.Close on the file descriptor will instruct the kernel to close the socket.

See https://godoc.org/net#TCPConn.File

from go-tproxy.

ppacher avatar ppacher commented on June 29, 2024

Hi,

maybe I'm wrong but for my understanding listener.File() returns a clone(3)ed file descriptor pointing to the same socket structure. The defered file.Close() will actually close the file descriptor by invoking close(3), which has the same effect as syscall.Close(). The kernel is not going to do shutdown the socket as long as active file descriptors are attached to it. Since the listener maintains it's own fd, the socket will be kept open. (That's also how childs can inherit sockets from parents). If you really want to force the listener socket to be closed, you'll need to call listener.Close() or shutdown(3) on the clone file-descriptor. May also refer to the manpage of close(3), I think it's "more or less" clear on that.

Please correct me when I'm wrong.

Br,
Patrick

from go-tproxy.

KatelynHaworth avatar KatelynHaworth commented on June 29, 2024

Hey Patrick,

From some reading and going through what I implemented you are correct, I should be calling Close() on the listener instead of the cloned fd when a error occurs. Good catch!

If you want, submit a pull request with the changes and I'll approve them. Also feel free to add a contributes section in the README and add yourself to it.

Kind regards,

Liam Haworth.

from go-tproxy.

KatelynHaworth avatar KatelynHaworth commented on June 29, 2024

Issue resolved via PR #7

from go-tproxy.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.