Browse Source

some more small fixes

1.0.0
Georg Hopp 11 years ago
parent
commit
2c3acbb3a9
  1. 14
      include/tr/interface/comm_manager.h
  2. 13
      src/comm_manager.c
  3. 8
      src/io_handler.c

14
include/tr/interface/comm_manager.h

@ -30,13 +30,13 @@
#include "tr/comm_end_point.h" #include "tr/comm_end_point.h"
typedef void (* fptr_TR_commManagerAddEndpoint)(void *, TR_CommEndPoint);
typedef void (* fptr_TR_commManagerSelect)(void *, TR_Event, int);
typedef void (* fptr_TR_commManagerEnableWrite)(void *, TR_Event);
typedef void (* fptr_TR_commManagerDisableWrite)(void *, TR_Event);
typedef void (* fptr_TR_commManagerClose)(void *, TR_Event);
typedef void (* fptr_TR_commManagerShutdownRead)(void *, TR_Event);
typedef void (* fptr_TR_commManagerShutdownWrite)(void *, TR_Event);
typedef TR_EventDone (* fptr_TR_commManagerAddEndpoint)(void *, TR_CommEndPoint);
typedef TR_EventDone (* fptr_TR_commManagerSelect)(void *, TR_Event, int);
typedef TR_EventDone (* fptr_TR_commManagerEnableWrite)(void *, TR_Event);
typedef TR_EventDone (* fptr_TR_commManagerDisableWrite)(void *, TR_Event);
typedef TR_EventDone (* fptr_TR_commManagerClose)(void *, TR_Event);
typedef TR_EventDone (* fptr_TR_commManagerShutdownRead)(void *, TR_Event);
typedef TR_EventDone (* fptr_TR_commManagerShutdownWrite)(void *, TR_Event);
TR_INTERFACE(TR_CommManager) { TR_INTERFACE(TR_CommManager) {
TR_IFID; TR_IFID;

13
src/comm_manager.c

@ -85,47 +85,40 @@ commManagerCvInit(TR_class_ptr cls)
TR_EventDispatcher, TR_EventDispatcher,
TR_DISPATCHER_EVENT_DATA_WAIT, TR_DISPATCHER_EVENT_DATA_WAIT,
TR_commManagerSelect); TR_commManagerSelect);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_EventDispatcher, TR_EventDispatcher,
TR_DISPATCHER_EVENT_SHUTDOWN, TR_DISPATCHER_EVENT_SHUTDOWN,
TR_commManagerShutdown); TR_commManagerShutdown);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_Connection, TR_Connection,
TR_CON_EVENT_NEW_CON, TR_CON_EVENT_NEW_CON,
TR__commManagerAddEndpoint); TR__commManagerAddEndpoint);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_Connection,
TR_CommEndPoint,
TR_CEP_EVENT_PENDING_DATA, TR_CEP_EVENT_PENDING_DATA,
TR_commManagerEnableWrite); TR_commManagerEnableWrite);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_Connection,
TR_CommEndPoint,
TR_CEP_EVENT_END_DATA, TR_CEP_EVENT_END_DATA,
TR_commManagerDisableWrite); TR_commManagerDisableWrite);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_CommEndPoint, TR_CommEndPoint,
TR_CEP_EVENT_CLOSE, TR_CEP_EVENT_CLOSE,
TR_commManagerClose); TR_commManagerClose);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_CommEndPoint, TR_CommEndPoint,
TR_CEP_EVENT_SHUT_READ, TR_CEP_EVENT_SHUT_READ,
TR_commManagerShutdownRead); TR_commManagerShutdownRead);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
cls, cls,
TR_CommEndPoint, TR_CommEndPoint,
TR_CEP_EVENT_SHUT_READ,
TR_CEP_EVENT_SHUT_WRITE,
TR_commManagerShutdownWrite); TR_commManagerShutdownWrite);
} }

8
src/io_handler.c

@ -44,14 +44,12 @@ static
TR_EventDone TR_EventDone
ioHandlerRead(void * _this, TR_Event event) ioHandlerRead(void * _this, TR_Event event)
{ {
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject;
switch (TR_cepBufferRead(endpoint)) {
switch (TR_cepBufferRead((TR_CommEndPoint)event->subject)) {
default: default:
case FALSE: case FALSE:
break; break;
case -1:
case -1: // error
TR_eventHandlerIssueEvent( TR_eventHandlerIssueEvent(
(TR_EventHandler)_this, (TR_EventHandler)_this,
TR_eventSubjectEmit( TR_eventSubjectEmit(
@ -60,7 +58,7 @@ ioHandlerRead(void * _this, TR_Event event)
NULL)); NULL));
break; break;
case -2:
case -2: // remote close
TR_eventHandlerIssueEvent( TR_eventHandlerIssueEvent(
(TR_EventHandler)_this, (TR_EventHandler)_this,
TR_eventSubjectEmit( TR_eventSubjectEmit(

Loading…
Cancel
Save