Bojan Smojver wrote: >I'm proposing to add two extra fields to request_rec structure: > >apr_off_t bytes_in >apr_off_t bytes_out > >These babies would be used to record the number of bytes received and sent (on >the wire) per each request. I'm writing a little filter module (with a lot of >help from Justin :-), to do the actual counting. The logging of these numbers >would require a patch to mod_log_config.c, which is already done. There would >also be some other changes required throughout Apache 2.0, mainly to do with >making sure that connection filter have a valid value of f->r. >
The one problem I see is that, because the response data might not be written until after the request has been logged--in the case of a keep-alive request--the bytes_out field will need to be updated *before* setting aside any output in core_output_filter(). I.e., output bytes should be counted when they're passed to the core out filter, not when they're actually written. That's somewhat complicated, because the core output filter code is so convoluted. But if you can make that work, then we probably can also stop computing r->bytes_sent in the content-length filter on streamed requests, which will save one more scan through the brigade on each request. >I wanted to find out if there would be enough support for such a change as it >makes a significant difference to the code of the module. > >The unfortunate side effect would be yet another MMN bump. > Fortunately, this only requires an increment for the minor number. (Put the new fields at the end of the structure to maintain backward compatibility.) So, +1 on the proposal. Brian
