Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
songbingyu committed Nov 3, 2014
1 parent bb68ba6 commit ed2b253
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/CircularBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class CircularBuffer

~CircularBuffer()
{
delete []data_;
data_ = NULL;
TINY_DELETE( data_ );
begin_ = 0;
end_ = 0;
count_ = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/Connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Connection::Connection( int fd, EventLoop* loop, struct sockaddr_in& addr ): IC

Connection::~Connection()
{


close();
}

void Connection::send( char* data, int len )
Expand Down Expand Up @@ -67,7 +66,7 @@ void Connection::close()
{
if( state_ == CS_Connecing || state_ == CS_Connected ){
state_ = CS_DisConnecting;
onClose();
onClose();
}
}

Expand Down Expand Up @@ -130,6 +129,7 @@ int Connection::onConnFinish()
int Connection::onConnDestory()
{
if( state_ == CS_Connected ){

state_ = CS_DisConnected;
ev_.stop();
}
Expand Down
1 change: 0 additions & 1 deletion src/EventEpoll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ EventEpoll::EventEpoll( EventLoop* loop ): IPoller( loop ), epollfd_( -1 ),epoll

EventEpoll::~EventEpoll()
{

close( epollfd_ );
}

Expand Down
31 changes: 28 additions & 3 deletions src/EventLoop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,45 @@
#include "ActiveEvent.h"
#include "PendingEvent.h"

EventLoop::EventLoop(): isRuning_( true ), curPid_(0), signalHelper_(this)
EventLoop::EventLoop(): isRuning_( true ), curPid_(0),
activeCnt_(0),ioBlockTime_(0),signalHelper_(this)
{
poller_ = getRecommendedPoller();
curTime_ = tinyGetTime();
//占位
timers_.push_back( NULL );
}

EventLoop::~EventLoop()
{
isRuning_ = false;

TINY_DELETE( poller_ );

PendingArr::iterator it = pendingEvents_.begin();
for( ; it != pendingEvents_.end(); ++it ){
delete *it;
}
pendingEvents_.clear();
activeFdEvents_.clear();

{
ActiveFdArr::iterator it = activeFdEvents_.begin();
for( ; it!= activeFdEvents_.begin(); ++it ){
delete *it;
}
activeFdEvents_.clear();
}

changeFds_.clear();
timers_.clear();

{
HeapVec::iterator it = timers_.begin();
for( ; it != timers_.end(); ++it ){
delete *it;
}
timers_.clear();
}

rFeeds_.clear();
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public :
tiny_forceinline void updateTime( Timestamp maxBlockTime );
tiny_noinline tiny_cold void timerReSchedule( Timestamp adjust );
tiny_forceinline void timersReify();
private:

private:
typedef std::vector<PendingEvent*> PendingArr;
PendingArr pendingEvents_;
bool isRuning_;
Expand Down
1 change: 1 addition & 0 deletions src/IConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class IConnection: public nocopyable
socketHelper_->close( sockfd_ );
sockfd_ = -1;
loop_ = NULL;

delete socketHelper_;
socketHelper_ = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TcpClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TcpClient::TcpClient( EventLoop* loop, const char* ip, int port ): loop_(loop),
TcpClient::~TcpClient()
{
TINY_DELETE( connector_ );
TINY_DELETE(conn_);
assert( NULL == conn_ );
}

void TcpClient::init()
Expand Down
2 changes: 2 additions & 0 deletions src/TinyDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const static int kHeap0 = 1;
extern Timestamp tinyGetTime();
extern void tinySleep( Timestamp t );
extern void fdInteral( int fd );


#endif


Expand Down

0 comments on commit ed2b253

Please sign in to comment.