#endif
- if (const int csize = data.readBuf->contentSize()) {
+ if (data.readBuf != NULL && data.readBuf->hasContent()) {
+ const mb_size_t csize = data.readBuf->contentSize();
debugs(9, 5, HERE << "writing " << csize << " bytes to the reply");
addVirginReplyBody(data.readBuf->content(), csize);
data.readBuf->consume(csize);
scheduleReadControlReply(0);
}
+void
+ServerStateData::initReadBuf()
+{
+ if (data.readBuf == NULL) {
+ data.readBuf = new MemBuf;
+ data.readBuf->init(4096, SQUID_TCP_SO_RCVBUF);
+ }
+}
+
/**
* Close the FTP server connection(s). Used by serverComplete().
*/
if (data.read_pending)
return;
- if (data.readBuf == NULL) {
- data.readBuf = new MemBuf;
- data.readBuf->init(4096, SQUID_TCP_SO_RCVBUF);
- }
+ initReadBuf();
+
const int read_sz = replyBodySpace(*data.readBuf, 0);
debugs(11,9, HERE << "FTP may read up to " << read_sz << " bytes");
protected:
virtual void start();
+ void initReadBuf();
virtual void closeServer();
virtual bool doneWithServer() const;
virtual void failedErrorMessage(err_type error, int xerrno);