Skip to content
Browse files

pull pause/resume logic down into EventableDescriptor

Fixes pause/resume support on PipeDescriptor and possibly other
connection types. See #245 for more info.
  • Loading branch information...
1 parent eae9baa commit fcaa1a379a0c256d738dac552a014e265b6ea016 @tmm1 tmm1 committed with rtomayko Sep 1, 2011
Showing with 11 additions and 12 deletions.
  1. +3 −3 ext/cmain.cpp
  2. +2 −2 ext/ed.cpp
  3. +4 −5 ext/ed.h
  4. +2 −2 ext/pipe.cpp
View
6 ext/cmain.cpp
@@ -220,7 +220,7 @@ evma_pause
extern "C" int evma_pause (const unsigned long binding)
{
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
+ EventableDescriptor *cd = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
if (cd)
return cd->Pause() ? 1 : 0;
@@ -233,7 +233,7 @@ evma_resume
extern "C" int evma_resume (const unsigned long binding)
{
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
+ EventableDescriptor *cd = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
if (cd)
return cd->Resume() ? 1 : 0;
@@ -246,7 +246,7 @@ evma_is_paused
extern "C" int evma_is_paused (const unsigned long binding)
{
- ConnectionDescriptor *cd = dynamic_cast <ConnectionDescriptor*> (Bindable_t::GetObject (binding));
+ EventableDescriptor *cd = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
if (cd)
return cd->IsPaused() ? 1 : 0;
View
4 ext/ed.cpp
@@ -63,7 +63,8 @@ EventableDescriptor::EventableDescriptor (int sd, EventMachine_t *em):
MaxOutboundBufSize(0),
MyEventMachine (em),
PendingConnectTimeout(20000000),
- InactivityTimeout (0)
+ InactivityTimeout (0),
+ bPaused (false)
{
/* There are three ways to close a socket, all of which should
* automatically signal to the event machine that this object
@@ -363,7 +364,6 @@ ConnectionDescriptor::ConnectionDescriptor
ConnectionDescriptor::ConnectionDescriptor (int sd, EventMachine_t *em):
EventableDescriptor (sd, em),
- bPaused (false),
bConnectPending (false),
bNotifyReadable (false),
bNotifyWritable (false),
View
9 ext/ed.h
@@ -88,9 +88,9 @@ class EventableDescriptor: public Bindable_t
virtual void StopProxy();
virtual void SetProxiedFrom(EventableDescriptor*, const unsigned long);
virtual int SendOutboundData(const char*,int){ return -1; }
- virtual bool IsPaused(){ return false; }
- virtual bool Pause(){ return false; }
- virtual bool Resume(){ return false; }
+ virtual bool IsPaused(){ return bPaused; }
+ virtual bool Pause(){ bPaused = true; return bPaused; }
+ virtual bool Resume(){ bPaused = false; return bPaused; }
void SetUnbindReasonCode(int code){ UnbindReasonCode = code; }
virtual int ReportErrorStatus(){ return 0; }
@@ -127,6 +127,7 @@ class EventableDescriptor: public Bindable_t
uint64_t InactivityTimeout;
uint64_t LastActivity;
uint64_t NextHeartbeat;
+ bool bPaused;
};
@@ -170,7 +171,6 @@ class ConnectionDescriptor: public EventableDescriptor
void SetNotifyWritable (bool);
void SetWatchOnly (bool);
- bool IsPaused(){ return bPaused; }
bool Pause();
bool Resume();
@@ -217,7 +217,6 @@ class ConnectionDescriptor: public EventableDescriptor
};
protected:
- bool bPaused;
bool bConnectPending;
bool bNotifyReadable;
View
4 ext/pipe.cpp
@@ -282,7 +282,7 @@ bool PipeDescriptor::SelectForRead()
* a pending state, so this is simpler than for the
* ConnectionDescriptor object.
*/
- return true;
+ return bPaused ? false : true;
}
/******************************
@@ -295,7 +295,7 @@ bool PipeDescriptor::SelectForWrite()
* a pending state, so this is simpler than for the
* ConnectionDescriptor object.
*/
- return (GetOutboundDataSize() > 0);
+ return (GetOutboundDataSize() > 0) && !bPaused ? true : false;
}

0 comments on commit fcaa1a3

Please sign in to comment.
Something went wrong with that request. Please try again.