@@ -192,10 +192,6 @@ ZongJi.prototype.start = function (options = {}) {
192
192
this . _options ( options ) ;
193
193
this . _filters ( options ) ;
194
194
195
- // Don't start listener if it has already explicitly been stopped
196
- if ( this . stopped ) {
197
- return ;
198
- }
199
195
const testChecksum = ( resolve , reject ) => {
200
196
this . _isChecksumEnabled ( ( err , checksumEnabled ) => {
201
197
if ( err ) {
@@ -258,41 +254,38 @@ ZongJi.prototype.start = function (options = {}) {
258
254
this . emit ( 'binlog' , event ) ;
259
255
} ;
260
256
261
- if ( ! this . stopped ) {
262
- let promises = [ new Promise ( testChecksum ) ] ;
257
+ let promises = [ new Promise ( testChecksum ) ] ;
263
258
264
- if ( this . options . startAtEnd ) {
265
- promises . push ( new Promise ( findBinlogEnd ) ) ;
266
- }
267
-
268
- Promise . all ( promises )
269
- . then ( ( ) => {
270
- this . BinlogClass = initBinlogClass ( this ) ;
271
- if ( ! this . stopped ) {
272
- this . connection . _protocol . _enqueue ( new this . BinlogClass ( binlogHandler ) ) ;
273
- this . ready = true ;
274
- this . emit ( 'ready' ) ;
275
- }
276
- } )
277
- . catch ( ( err ) => {
278
- // Don't emit errors if the listener is already stopped
279
- if ( ! this . stopped ) {
280
- this . emit ( 'error' , err ) ;
281
- }
282
- } ) ;
259
+ if ( this . options . startAtEnd ) {
260
+ promises . push ( new Promise ( findBinlogEnd ) ) ;
283
261
}
262
+
263
+ Promise . all ( promises )
264
+ . then ( ( ) => {
265
+ this . BinlogClass = initBinlogClass ( this ) ;
266
+ if ( ! this . stopped ) {
267
+ this . connection . _protocol . _enqueue ( new this . BinlogClass ( binlogHandler ) ) ;
268
+ this . ready = true ;
269
+ this . emit ( 'ready' ) ;
270
+ }
271
+ } )
272
+ . catch ( ( err ) => {
273
+ this . emit ( 'error' , err ) ;
274
+ } ) ;
284
275
} ;
285
276
286
277
ZongJi . prototype . stop = function ( ) {
287
- // Binary log connection does not end with destroy()
288
- this . connection . destroy ( ) ;
289
- this . ctrlConnection . query ( 'KILL ' + this . connection . threadId , ( ) => {
290
- if ( this . ctrlConnectionOwner ) {
291
- this . ctrlConnection . destroy ( ) ;
292
- }
293
- this . emit ( 'stopped' ) ;
294
- } ) ;
295
- this . stopped = true ;
278
+ if ( ! this . stopped ) {
279
+ this . stopped = true ;
280
+ // Binary log connection does not end with destroy()
281
+ this . connection . destroy ( ) ;
282
+ this . ctrlConnection . query ( 'KILL ' + this . connection . threadId , ( ) => {
283
+ if ( this . ctrlConnectionOwner ) {
284
+ this . ctrlConnection . destroy ( ) ;
285
+ }
286
+ this . emit ( 'stopped' ) ;
287
+ } ) ;
288
+ }
296
289
} ;
297
290
298
291
ZongJi . prototype . pause = function ( ) {
0 commit comments