Skip to content

Commit

Permalink
DKIM async issue #1693 (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
smfreegard authored and msimerson committed Sep 10, 2017
1 parent b0d60d1 commit 529b0e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* connection/transaction notes now have get/set #2082
* Fixes
* haraka cli will now create folders if they don't exist #2088
* dkim: prevent dkim_verify from causing 'cannot pipe' #1693

## 2.8.14 - Jul 26, 2017

Expand Down
19 changes: 14 additions & 5 deletions dkim.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,10 @@ DKIMVerifyStream.prototype.handle_buf = function (buf) {

self.debug(JSON.stringify(result));

if (self.pending === 0 && self.cb) {
return self.cb(null, self.result, self.results);
if (self.pending === 0 && self.b) {
return process.nextTick(function () {
self.cb(null, self.result, self.results);
});
}
};

Expand Down Expand Up @@ -507,7 +509,9 @@ DKIMVerifyStream.prototype.handle_buf = function (buf) {
}
if (!this.header_idx['dkim-signature']) {
this._no_signatures_found = true;
return this.cb(null, this.result, this.results);
return process.nextTick(function () {
self.cb(null, self.result, self.results);
});
}
else {
// Create new DKIM objects for each header
Expand All @@ -518,7 +522,9 @@ DKIMVerifyStream.prototype.handle_buf = function (buf) {
this.dkim_objects.push(new DKIMObject(dkim_headers[d], this.header_idx, callback, this.timeout));
}
if (this.pending === 0) {
if (this.cb) this.cb(new Error('no signatures found'));
process.nextTick(function () {
if (self.cb) self.cb(new Error('no signatures found'));
});
}
}
continue; // while()
Expand Down Expand Up @@ -559,7 +565,10 @@ DKIMVerifyStream.prototype.end = function (buf) {
this.dkim_objects[d].end();
}
if (this.pending === 0 && this._no_signatures_found === false) {
this.cb(null, this.result, this.results);
var self = this;
process.nextTick(function () {
self.cb(null, self.result, self.results);
});
}
};

Expand Down

0 comments on commit 529b0e4

Please sign in to comment.