docker / libchan

Like Go channels over the network
Apache License 2.0
2.47k stars 142 forks source link

http2 fd too many files #43

Closed bit4bit closed 9 years ago

bit4bit commented 9 years ago

hi,

i'm implementing a server with libchan and http2, they work well, but they fail after some minutes with the error fd too many files open,when debug see the descriptor for libchan.Message.Fd create by the http2.StreamReceiver.Receive method used on the server, they grow and grow.. look, simple test, ulimit -n 80 then running de server the Fd grow:

and boom!, i'm find a solution and it's closing the descriptor (msg.Fd.Close()) when then server finish the response,

there a better way?

thanks

bit4bit commented 9 years ago

not work, msg.Fd.Close() another descriptor not close :(

pnasrat commented 9 years ago

Do you have a pointer to the code (or a simplified reproducer of) that you have written and how you are testing?

dmcgowan commented 9 years ago

Work is currently being done to reduce the fds that are used. Message fd is being update to use an io.ReadWriteCloser leaving it up to caller to determine what type the byte stream will be. If you can share the code or use case as @pnasrat suggested, I think that would be helpful to ensure any changes that are being made fit your use case.

bit4bit commented 9 years ago

hi, found a solution, commenting the use of createAttachment in method StreamReceiver.Receiver, then all my tests works.

func (s *StreamReceiver) Receive(mode int) (*libchan.Message, error) {
                ...

                 //var attachErr error
                //attach, attachErr = createAttachment(stream)
                //if attachErr != nil {
                //      return nil, attachErr
                //}
                ret = &StreamSender{stream: stream, streamChans: s.streamChans}

                return &libchan.Message{
                        Data: data,
                        Fd:   nil,
                        Ret:  ret,
                }, nil
              ...
dmcgowan commented 9 years ago

This issue should be fixed with the updated libchan interface