MB-24426: Use virtual destructors for some of the DCP classes 34/78334/3
authorManu Dhundi <manu@couchbase.com>
Thu, 18 May 2017 21:35:42 +0000 (14:35 -0700)
committerDave Rigby <daver@couchbase.com>
Fri, 19 May 2017 07:53:15 +0000 (07:53 +0000)
DCP classes like 'DCPProducer', 'DCPConsumer', 'Consumer',
'ActiveStream' and 'PassiveStream' have subclasses derived from them.
It is appropriate to use virtual destructors to avoid any memory
leaks during object deletion.

Change-Id: I8b8457095b7c9914ca2c3d4b18a2251833e6c770
Reviewed-on: http://review.couchbase.org/78334
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
src/dcp/consumer.h
src/dcp/producer.h
src/dcp/stream.h
src/tapconnection.h

index 230a94a..8e25511 100644 (file)
@@ -38,7 +38,7 @@ public:
     DcpConsumer(EventuallyPersistentEngine &e, const void *cookie,
                 const std::string &n);
 
-    ~DcpConsumer();
+    virtual ~DcpConsumer();
 
     ENGINE_ERROR_CODE addStream(uint32_t opaque, uint16_t vbucket,
                                 uint32_t flags) override;
index 1bb97e3..2b77289 100644 (file)
@@ -61,7 +61,7 @@ enum class MutationType {
                 bool startTask,
                 MutationType mutType);
 
-    ~DcpProducer();
+    virtual ~DcpProducer();
 
     ENGINE_ERROR_CODE streamRequest(uint32_t flags, uint32_t opaque,
                                     uint16_t vbucket, uint64_t start_seqno,
index 4a0168a..dad5fbf 100644 (file)
@@ -223,7 +223,7 @@ public:
                  uint64_t vb_uuid, uint64_t snap_start_seqno,
                  uint64_t snap_end_seqno, bool isKeyOnly);
 
-    ~ActiveStream();
+    virtual ~ActiveStream();
 
     DcpResponse* next();
 
@@ -535,7 +535,7 @@ public:
                   uint64_t vb_uuid, uint64_t snap_start_seqno,
                   uint64_t snap_end_seqno, uint64_t vb_high_seqno);
 
-    ~PassiveStream();
+    virtual ~PassiveStream();
 
     process_items_error_t processBufferedMessages(uint32_t &processed_bytes,
                                                   size_t batchSize);
index 77e07e8..837b49e 100644 (file)
@@ -694,6 +694,8 @@ private:
 public:
     Consumer(EventuallyPersistentEngine &theEngine, const void* cookie,
              const std::string& name);
+    virtual ~Consumer() {
+    }
     virtual void processedEvent(uint16_t event, ENGINE_ERROR_CODE ret);
     virtual void addStats(ADD_STAT add_stat, const void *c);
     virtual const char *getType() const { return "consumer"; };
@@ -842,6 +844,9 @@ public:
         totalBackfillBacklogs(0),
         reconnects(0) {}
 
+    virtual ~Producer() {
+    }
+
     void addStats(ADD_STAT add_stat, const void *c);
 
     bool isReconnected() const {
@@ -872,8 +877,6 @@ public:
         return vbucketFilter;
     }
 
-    virtual ~Producer() {}
-
 protected:
     friend class ConnMap;