pistacheio / pistache

A high-performance REST toolkit written in C++
https://pistacheio.github.io/pistache/
Apache License 2.0
3.12k stars 685 forks source link

WriteEntry Constructor called with Incorrect Parameters in Transport::asyncWriteImpl #1168

Open dgreatwood opened 7 months ago

dgreatwood commented 7 months ago

There is a fragment of code in transport.cc:

                        // pop_front kills buffer - so we cannot continue loop or use buffer
                        // after this point
                        wq.pop_front();
                        wq.push_front(WriteEntry(std::move(deferred), bufferHolder, flags));

BUT the WriteEntry constructor is:

WriteEntry(Async::Deferred<ssize_t> deferred_, BufferHolder buffer_,
                       Fd peerFd_, int flags_ = 0)

So this invocation of the WriteEntry constructor is passing variable flags as the input to _Fd peerFd__. This only compiles because both flags and type Fd have type int, and then the missing WriteEntry constructor parameter (_flags__) has a default value.

Can it be changed to: wq.push_front(WriteEntry(std::move(deferred), bufferHolder, fd, flags)); (I think the parameter to add is fd? Not buffer.fd() or something else?)

Thanks!