#26 [patch] bufferevent: add length arg to read/write callbacks

API
closed
nobody
General (24)
5
2010-01-15
2008-09-15
No

I need a way to know how many new bytes have been read/written in my bufferevent readcb/writecb callbacks. EVBUFFER_LENGTH() tells me the total size, but not the size of what was just added to the buffer.

If you think it would be generally useful, attached is a very simple patch that adds a length argument to the readcb/writecb function signature.

If you don't think this would make a good addition to libevent, is there an alternate way to pump the bufferevent to learn the number of new bytes in the readcb/writecb callbacks?

Discussion

  • Charles Kerr

    Charles Kerr - 2008-09-15

    patch to add length argument to the read/write callbacks

     
  • Niels Provos

    Niels Provos - 2008-11-27

    I don't think we can change the established functions. You could take the buffer length before and after to see how much was added or removed. Could you provide us with your use case so that we have more context around this?

    Thanks,
    Niels.

     
  • Nick Mathewson

    Nick Mathewson - 2009-04-23

    As of 2.0.1-alpha, you can trivially add a callback to the the inbuf and outbuf to tell when bytes are read or written. This may help do what you want.

    As for your suggested, Niels is right. I would not be averse to adding a more sophisticated way to do bufferevent callbacks in the future, but there is no way that we can get away with breaking everybody else's program. Thus, if we're going to change the event signatures on bufferevent callbacks, we'll have to retain support for setting callbacks with the old interface that work like the old callbacks.

     
  • Nick Mathewson

    Nick Mathewson - 2010-01-15

    This is do-able with current libevent, using evbufer callbacks, More complex solutions would require changing the bufferevent callback system completely. I am not categorically opposed to changing callback signatures, but it MUST remain backwards compatible.

    I am closing this feature request, but leaving comments open.

     
  • Nick Mathewson

    Nick Mathewson - 2010-01-15
    • status: open --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks