Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
lib: don't use emitter.listeners(type).length
Browse files Browse the repository at this point in the history
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
JacksonTian authored and trevnorris committed Aug 12, 2014
1 parent 0718426 commit 931cbc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/_tls_wrap.js
Expand Up @@ -27,6 +27,7 @@ var crypto = require('crypto');
var net = require('net');
var tls = require('tls');
var util = require('util');
var listenerCount = require('events').listenerCount;
var common = require('_tls_common');

var Timer = process.binding('timer_wrap').Timer;
Expand Down Expand Up @@ -131,7 +132,7 @@ function requestOCSP(self, hello, ctx, cb) {
if (ctx.context)
ctx = ctx.context;

if (self.server.listeners('OCSPRequest').length === 0) {
if (listenerCount(self.server, 'OCSPRequest') === 0) {
return cb(null);
} else {
self.server.emit('OCSPRequest',
Expand Down Expand Up @@ -311,9 +312,9 @@ TLSSocket.prototype._init = function(socket) {
this.ssl.handshakes = 0;

if (this.server &&
(this.server.listeners('resumeSession').length > 0 ||
this.server.listeners('newSession').length > 0 ||
this.server.listeners('OCSPRequest').length > 0)) {
(listenerCount(this.server, 'resumeSession') > 0 ||
listenerCount(this.server, 'newSession') > 0 ||
listenerCount(this.server, 'OCSPRequest') > 0)) {
this.ssl.enableSessionCallbacks();
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/node.js
Expand Up @@ -670,7 +670,7 @@
if (isSignal(type)) {
assert(signalWraps.hasOwnProperty(type));

if (this.listeners(type).length === 0) {
if (EventEmitter.listenerCount(this, type) === 0) {
signalWraps[type].close();
delete signalWraps[type];
}
Expand Down

0 comments on commit 931cbc1

Please sign in to comment.