mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-11 07:34:48 +08:00
Fix DEFLATE for short messages that weren't flushed to socket
This commit is contained in:
parent
9c68053987
commit
ba2a57e670
2 changed files with 14 additions and 1 deletions
|
@ -49,7 +49,10 @@ module.exports = {
|
||||||
|
|
||||||
this.writeStream.unpipe(this._socket);
|
this.writeStream.unpipe(this._socket);
|
||||||
this._deflate.pipe(this._socket);
|
this._deflate.pipe(this._socket);
|
||||||
|
let reading = false;
|
||||||
let readNext = () => {
|
let readNext = () => {
|
||||||
|
reading = true;
|
||||||
|
|
||||||
let chunk;
|
let chunk;
|
||||||
while ((chunk = this.writeStream.read()) !== null) {
|
while ((chunk = this.writeStream.read()) !== null) {
|
||||||
if (this._deflate && this._deflate.write(chunk) === false) {
|
if (this._deflate && this._deflate.write(chunk) === false) {
|
||||||
|
@ -60,8 +63,14 @@ module.exports = {
|
||||||
if (this._deflate) {
|
if (this._deflate) {
|
||||||
this._deflate.flush();
|
this._deflate.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reading = false;
|
||||||
};
|
};
|
||||||
this.writeStream.on('readable', readNext);
|
this.writeStream.on('readable', () => {
|
||||||
|
if (!reading) {
|
||||||
|
readNext();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this._socket.unpipe(this._parser);
|
this._socket.unpipe(this._parser);
|
||||||
this._socket.pipe(this._inflate).pipe(this._parser);
|
this._socket.pipe(this._inflate).pipe(this._parser);
|
||||||
|
|
|
@ -126,6 +126,10 @@ class IMAPConnection extends EventEmitter {
|
||||||
send(payload, callback) {
|
send(payload, callback) {
|
||||||
if (this._socket && this._socket.writable) {
|
if (this._socket && this._socket.writable) {
|
||||||
this[!this.compression ? '_socket' : '_deflate'].write(payload + '\r\n', 'binary', callback);
|
this[!this.compression ? '_socket' : '_deflate'].write(payload + '\r\n', 'binary', callback);
|
||||||
|
if(this.compression){
|
||||||
|
// make sure we transmit the message immediatelly
|
||||||
|
this._deflate.flush();
|
||||||
|
}
|
||||||
this._server.logger.debug({
|
this._server.logger.debug({
|
||||||
tnx: 'send',
|
tnx: 'send',
|
||||||
cid: this.id
|
cid: this.id
|
||||||
|
|
Loading…
Add table
Reference in a new issue