Showing
10 changed files
with
83 additions
and
69 deletions
| 1 | -nobase_include_HEADERS = trcomm.h \ | ||
| 2 | - tr/comm_end_point.h \ | 1 | +nobase_include_HEADERS = tr/comm_end_point.h \ |
| 2 | + tr/comm_manager.h \ | ||
| 3 | + tr/comm_manager_poll.h \ | ||
| 4 | + tr/connect_entry_point.h \ | ||
| 3 | tr/connection.h \ | 5 | tr/connection.h \ |
| 4 | tr/connector.h \ | 6 | tr/connector.h \ |
| 5 | - tr/protocol.h \ | ||
| 6 | tr/proto_message.h \ | 7 | tr/proto_message.h \ |
| 7 | - tr/protocol/raw.h \ | ||
| 8 | - tr/protocol/message_raw.h \ | 8 | + tr/protocol.h \ |
| 9 | tr/interface/comm_end_point.h \ | 9 | tr/interface/comm_end_point.h \ |
| 10 | + tr/interface/comm_manager.h \ | ||
| 10 | tr/interface/protocol.h | 11 | tr/interface/protocol.h |
| 12 | + |
| @@ -28,6 +28,8 @@ | @@ -28,6 +28,8 @@ | ||
| 28 | #include "trbase.h" | 28 | #include "trbase.h" |
| 29 | #include "trevent.h" | 29 | #include "trevent.h" |
| 30 | 30 | ||
| 31 | +#include "tr/comm_end_point.h" | ||
| 32 | + | ||
| 31 | TR_CLASS(TR_CommManager) { | 33 | TR_CLASS(TR_CommManager) { |
| 32 | TR_EXTENDS(TR_EventHandler); | 34 | TR_EXTENDS(TR_EventHandler); |
| 33 | 35 |
| @@ -36,17 +36,17 @@ typedef void (* fptr_TR_commManagerEnableWrite)(void *, TR_Event); | @@ -36,17 +36,17 @@ typedef void (* fptr_TR_commManagerEnableWrite)(void *, TR_Event); | ||
| 36 | typedef void (* fptr_TR_commManagerDisableWrite)(void *, TR_Event); | 36 | typedef void (* fptr_TR_commManagerDisableWrite)(void *, TR_Event); |
| 37 | typedef void (* fptr_TR_commManagerClose)(void *, TR_Event); | 37 | typedef void (* fptr_TR_commManagerClose)(void *, TR_Event); |
| 38 | typedef void (* fptr_TR_commManagerShutdownRead)(void *, TR_Event); | 38 | typedef void (* fptr_TR_commManagerShutdownRead)(void *, TR_Event); |
| 39 | -typedef void (* fptr_TR_commManagerShutdownRead)(void *, TR_Event); | 39 | +typedef void (* fptr_TR_commManagerShutdownWrite)(void *, TR_Event); |
| 40 | 40 | ||
| 41 | TR_INTERFACE(TR_CommManager) { | 41 | TR_INTERFACE(TR_CommManager) { |
| 42 | TR_IFID; | 42 | TR_IFID; |
| 43 | - fptr_TR_commManagerAddEndpoint addEndpoint; | ||
| 44 | - fptr_TR_commManagerSelect select; | ||
| 45 | - fptr_TR_commManagerEnableWrite enableWrite; | ||
| 46 | - fptr_TR_commManagerDisableWrite disableWrite; | ||
| 47 | - fptr_TR_commManagerClose close; | ||
| 48 | - fptr_TR_commManagerShutdownRead shutdownWrite; | ||
| 49 | - fptr_TR_commManagerShutdownRead shutdownRead; | 43 | + fptr_TR_commManagerAddEndpoint addEndpoint; |
| 44 | + fptr_TR_commManagerSelect select; | ||
| 45 | + fptr_TR_commManagerEnableWrite enableWrite; | ||
| 46 | + fptr_TR_commManagerDisableWrite disableWrite; | ||
| 47 | + fptr_TR_commManagerClose close; | ||
| 48 | + fptr_TR_commManagerShutdownRead shutdownWrite; | ||
| 49 | + fptr_TR_commManagerShutdownWrite shutdownRead; | ||
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | void TR_commManagerAddEndpoint(void *, TR_CommEndPoint); | 52 | void TR_commManagerAddEndpoint(void *, TR_CommEndPoint); |
| @@ -2,13 +2,15 @@ | @@ -2,13 +2,15 @@ | ||
| 2 | #define __TR_COMM_H__ | 2 | #define __TR_COMM_H__ |
| 3 | 3 | ||
| 4 | #include "tr/comm_end_point.h" | 4 | #include "tr/comm_end_point.h" |
| 5 | +#include "tr/comm_manager.h" | ||
| 6 | +#include "tr/comm_manager_poll.h" | ||
| 7 | +#include "tr/connect_entry_point.h" | ||
| 5 | #include "tr/connection.h" | 8 | #include "tr/connection.h" |
| 6 | #include "tr/connector.h" | 9 | #include "tr/connector.h" |
| 7 | -#include "tr/protocol.h" | ||
| 8 | #include "tr/proto_message.h" | 10 | #include "tr/proto_message.h" |
| 9 | -#include "tr/protocol/raw.h" | ||
| 10 | -#include "tr/protocol/message_raw.h" | 11 | +#include "tr/protocol.h" |
| 11 | #include "tr/interface/comm_end_point.h" | 12 | #include "tr/interface/comm_end_point.h" |
| 13 | +#include "tr/interface/comm_manager.h" | ||
| 12 | #include "tr/interface/protocol.h" | 14 | #include "tr/interface/protocol.h" |
| 13 | 15 | ||
| 14 | #endif // __TR_COMM_H__ | 16 | #endif // __TR_COMM_H__ |
| @@ -7,16 +7,20 @@ TRCOMM = cep_append_read_data.c \ | @@ -7,16 +7,20 @@ TRCOMM = cep_append_read_data.c \ | ||
| 7 | cep_append_write_data.c \ | 7 | cep_append_write_data.c \ |
| 8 | cet_accept.c \ | 8 | cet_accept.c \ |
| 9 | comm_end_point.c \ | 9 | comm_end_point.c \ |
| 10 | + comm_manager.c \ | ||
| 11 | + comm_manager_poll.c \ | ||
| 12 | + comm_manager_shutdown.c \ | ||
| 10 | con_compose.c \ | 13 | con_compose.c \ |
| 14 | + con_next_message.c \ | ||
| 15 | + conn_entry_point.c \ | ||
| 11 | connection.c \ | 16 | connection.c \ |
| 12 | connector.c \ | 17 | connector.c \ |
| 13 | - conn_entry_point.c \ | ||
| 14 | - con_next_message.c \ | 18 | + proto_message.c \ |
| 15 | protocol.c \ | 19 | protocol.c \ |
| 16 | protocol_message_raw.c \ | 20 | protocol_message_raw.c \ |
| 17 | protocol_raw.c \ | 21 | protocol_raw.c \ |
| 18 | - proto_message.c \ | ||
| 19 | i_comm_end_point.c \ | 22 | i_comm_end_point.c \ |
| 23 | + i_comm_manager.c \ | ||
| 20 | i_protocol.c | 24 | i_protocol.c |
| 21 | 25 | ||
| 22 | lib_LTLIBRARIES = libtrcomm.la | 26 | lib_LTLIBRARIES = libtrcomm.la |
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <unistd.h> | 23 | #include <unistd.h> |
| 24 | +#include <poll.h> | ||
| 24 | 25 | ||
| 25 | #include "trbase.h" | 26 | #include "trbase.h" |
| 26 | #include "trevent.h" | 27 | #include "trevent.h" |
| @@ -58,7 +59,7 @@ commManagerDtor(void * _this) | @@ -58,7 +59,7 @@ commManagerDtor(void * _this) | ||
| 58 | 59 | ||
| 59 | static | 60 | static |
| 60 | int | 61 | int |
| 61 | -TR__commManagerAddEndpoint(void * _this, Event event) | 62 | +TR__commManagerAddEndpoint(void * _this, TR_Event event) |
| 62 | { | 63 | { |
| 63 | TR_commManagerAddEndpoint( | 64 | TR_commManagerAddEndpoint( |
| 64 | (TR_CommManager)_this, | 65 | (TR_CommManager)_this, |
| @@ -71,7 +72,7 @@ void TR_commManagerEnableWrite(void *, TR_Event); | @@ -71,7 +72,7 @@ void TR_commManagerEnableWrite(void *, TR_Event); | ||
| 71 | void TR_commManagerDisableWrite(void *, TR_Event); | 72 | void TR_commManagerDisableWrite(void *, TR_Event); |
| 72 | void TR_commManagerClose(void *, TR_Event); | 73 | void TR_commManagerClose(void *, TR_Event); |
| 73 | void TR_commManagerShutdownRead(void *, TR_Event); | 74 | void TR_commManagerShutdownRead(void *, TR_Event); |
| 74 | -void TR_commManagerShutdownRead(void *, TR_Event); | 75 | +void TR_commManagerShutdownWrite(void *, TR_Event); |
| 75 | 76 | ||
| 76 | static | 77 | static |
| 77 | void | 78 | void |
| @@ -98,13 +99,13 @@ commManagerCvInit(TR_class_ptr cls) | @@ -98,13 +99,13 @@ commManagerCvInit(TR_class_ptr cls) | ||
| 98 | TR_EVENT_HANDLER_SET_METHOD( | 99 | TR_EVENT_HANDLER_SET_METHOD( |
| 99 | cls, | 100 | cls, |
| 100 | TR_Connection, | 101 | TR_Connection, |
| 101 | - TR_CON_EVENT_PENDING_DATA, | 102 | + TR_CEP_EVENT_PENDING_DATA, |
| 102 | TR_commManagerEnableWrite); | 103 | TR_commManagerEnableWrite); |
| 103 | 104 | ||
| 104 | TR_EVENT_HANDLER_SET_METHOD( | 105 | TR_EVENT_HANDLER_SET_METHOD( |
| 105 | cls, | 106 | cls, |
| 106 | TR_Connection, | 107 | TR_Connection, |
| 107 | - TR_CON_EVENT_END_DATA, | 108 | + TR_CEP_EVENT_END_DATA, |
| 108 | TR_commManagerDisableWrite); | 109 | TR_commManagerDisableWrite); |
| 109 | 110 | ||
| 110 | TR_EVENT_HANDLER_SET_METHOD( | 111 | TR_EVENT_HANDLER_SET_METHOD( |
| @@ -126,7 +127,7 @@ commManagerCvInit(TR_class_ptr cls) | @@ -126,7 +127,7 @@ commManagerCvInit(TR_class_ptr cls) | ||
| 126 | TR_commManagerShutdownWrite); | 127 | TR_commManagerShutdownWrite); |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | -TR_INSTANCE(TR_Hash, _event_methods); | 130 | +TR_INSTANCE(TR_Hash, commManagerEventMethods); |
| 130 | TR_INIT_IFACE(TR_Class, commManagerCtor, commManagerDtor, NULL); | 131 | TR_INIT_IFACE(TR_Class, commManagerCtor, commManagerDtor, NULL); |
| 131 | TR_INIT_IFACE(TR_CommManager, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | 132 | TR_INIT_IFACE(TR_CommManager, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| 132 | TR_CREATE_CLASS( | 133 | TR_CREATE_CLASS( |
| @@ -135,7 +136,7 @@ TR_CREATE_CLASS( | @@ -135,7 +136,7 @@ TR_CREATE_CLASS( | ||
| 135 | commManagerCvInit, | 136 | commManagerCvInit, |
| 136 | TR_IF(TR_Class), | 137 | TR_IF(TR_Class), |
| 137 | TR_IF(TR_CommManager)) = { | 138 | TR_IF(TR_CommManager)) = { |
| 138 | - { &(__event_methods.data) } | 139 | + { &(_commManagerEventMethods.data) } |
| 139 | }; | 140 | }; |
| 140 | 141 | ||
| 141 | // vim: set ts=4 sw=4: | 142 | // vim: set ts=4 sw=4: |
| @@ -21,14 +21,17 @@ | @@ -21,14 +21,17 @@ | ||
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <unistd.h> | 23 | #include <unistd.h> |
| 24 | +#include <poll.h> | ||
| 24 | 25 | ||
| 25 | #include "trbase.h" | 26 | #include "trbase.h" |
| 26 | #include "trevent.h" | 27 | #include "trevent.h" |
| 27 | 28 | ||
| 28 | -#include "tr/comm_end_point.h" | ||
| 29 | -#include "tr/connection.h" | ||
| 30 | #include "tr/comm_manager.h" | 29 | #include "tr/comm_manager.h" |
| 30 | +#include "tr/comm_manager_poll.h" | ||
| 31 | #include "tr/interface/comm_manager.h" | 31 | #include "tr/interface/comm_manager.h" |
| 32 | +#include "tr/comm_end_point.h" | ||
| 33 | +#include "tr/connection.h" | ||
| 34 | +#include "tr/connect_entry_point.h" | ||
| 32 | 35 | ||
| 33 | static | 36 | static |
| 34 | int | 37 | int |
| @@ -41,7 +44,9 @@ commManagerPollCtor(void * _this, va_list * params) | @@ -41,7 +44,9 @@ commManagerPollCtor(void * _this, va_list * params) | ||
| 41 | TR_PARENTCALL(_this, TR_Class, ctor, params); | 44 | TR_PARENTCALL(_this, TR_Class, ctor, params); |
| 42 | this->fds = TR_malloc(sizeof(struct pollfd) * cmgr->n_endpoints); | 45 | this->fds = TR_malloc(sizeof(struct pollfd) * cmgr->n_endpoints); |
| 43 | for (i = 0; i < cmgr->n_endpoints; i++) { | 46 | for (i = 0; i < cmgr->n_endpoints; i++) { |
| 44 | - this->fds[i] = {-1, 0, 0}; | 47 | + this->fds[i].fd = -1; |
| 48 | + this->fds[i].events = 0; | ||
| 49 | + this->fds[i].revents = 0; | ||
| 45 | } | 50 | } |
| 46 | 51 | ||
| 47 | return 0; | 52 | return 0; |
| @@ -59,7 +64,7 @@ commManagerPollDtor(void * _this) | @@ -59,7 +64,7 @@ commManagerPollDtor(void * _this) | ||
| 59 | 64 | ||
| 60 | static | 65 | static |
| 61 | void | 66 | void |
| 62 | -TR_commManagerAddEndpoint(void * _this, TR_CommEndPoint endpoint) | 67 | +TR_commManagerPollAddEndpoint(void * _this, TR_CommEndPoint endpoint) |
| 63 | { | 68 | { |
| 64 | TR_CommManagerPoll this = _this; | 69 | TR_CommManagerPoll this = _this; |
| 65 | this->fds[endpoint->transport->handle].fd = endpoint->transport->handle; | 70 | this->fds[endpoint->transport->handle].fd = endpoint->transport->handle; |
| @@ -68,7 +73,7 @@ TR_commManagerAddEndpoint(void * _this, TR_CommEndPoint endpoint) | @@ -68,7 +73,7 @@ TR_commManagerAddEndpoint(void * _this, TR_CommEndPoint endpoint) | ||
| 68 | 73 | ||
| 69 | static | 74 | static |
| 70 | void | 75 | void |
| 71 | -TR_commManagerSelect(void * _this, TR_Event event, int timeout) | 76 | +TR_commManagerPollSelect(void * _this, TR_Event event, int timeout) |
| 72 | { | 77 | { |
| 73 | TR_CommManagerPoll this = _this; | 78 | TR_CommManagerPoll this = _this; |
| 74 | TR_CommManager cmgr = _this; | 79 | TR_CommManager cmgr = _this; |
| @@ -77,33 +82,33 @@ TR_commManagerSelect(void * _this, TR_Event event, int timeout) | @@ -77,33 +82,33 @@ TR_commManagerSelect(void * _this, TR_Event event, int timeout) | ||
| 77 | 82 | ||
| 78 | nevents = poll(this->fds, cmgr->n_endpoints, timeout); | 83 | nevents = poll(this->fds, cmgr->n_endpoints, timeout); |
| 79 | 84 | ||
| 80 | - for (i = 0; i < cmgr->n_endpoints, i++) { | ||
| 81 | - TR_CommEndPoint endpoint = this->endpoints[i]; | 85 | + for (i = 0; i < cmgr->n_endpoints; i++) { |
| 86 | + TR_CommEndPoint endpoint = cmgr->endpoints[i]; | ||
| 82 | 87 | ||
| 83 | - if (this->fds[i].revents & POLLIN == POLLIN) { | 88 | + if ((this->fds[i].revents & POLLIN) == POLLIN) { |
| 84 | nevents--; | 89 | nevents--; |
| 85 | - if (TR_INSTANCE_OF(TR_TcpSocket, endpoints->transport) | 90 | + if (TR_INSTANCE_OF(TR_TcpSocket, endpoint->transport) |
| 86 | && ((TR_TcpSocket)endpoint->transport)->listen) { | 91 | && ((TR_TcpSocket)endpoint->transport)->listen) { |
| 87 | TR_eventHandlerIssueEvent( | 92 | TR_eventHandlerIssueEvent( |
| 88 | (TR_EventHandler)this, | 93 | (TR_EventHandler)this, |
| 89 | - (TR_Connection)endpoint, | ||
| 90 | - TR_CON_EVENT_ACC_READY, | 94 | + (TR_EventSubject)endpoint, |
| 95 | + TR_CET_EVENT_ACC_READY, | ||
| 91 | NULL); | 96 | NULL); |
| 92 | } else { | 97 | } else { |
| 93 | TR_eventHandlerIssueEvent( | 98 | TR_eventHandlerIssueEvent( |
| 94 | (TR_EventHandler)this, | 99 | (TR_EventHandler)this, |
| 95 | - endpoint, | ||
| 96 | - TR_CET_EVENT_READ_READY, | 100 | + (TR_EventSubject)endpoint, |
| 101 | + TR_CEP_EVENT_READ_READY, | ||
| 97 | NULL); | 102 | NULL); |
| 98 | } | 103 | } |
| 99 | } | 104 | } |
| 100 | 105 | ||
| 101 | - if (this->fds[i].revents & POLLOUT == POLLOUT) { | 106 | + if ((this->fds[i].revents & POLLOUT) == POLLOUT) { |
| 102 | nevents--; | 107 | nevents--; |
| 103 | TR_eventHandlerIssueEvent( | 108 | TR_eventHandlerIssueEvent( |
| 104 | (TR_EventHandler)this, | 109 | (TR_EventHandler)this, |
| 105 | - endpoint, | ||
| 106 | - TR_CET_EVENT_WRITE_READY, | 110 | + (TR_EventSubject)endpoint, |
| 111 | + TR_CEP_EVENT_WRITE_READY, | ||
| 107 | NULL); | 112 | NULL); |
| 108 | } | 113 | } |
| 109 | 114 | ||
| @@ -113,56 +118,50 @@ TR_commManagerSelect(void * _this, TR_Event event, int timeout) | @@ -113,56 +118,50 @@ TR_commManagerSelect(void * _this, TR_Event event, int timeout) | ||
| 113 | 118 | ||
| 114 | static | 119 | static |
| 115 | void | 120 | void |
| 116 | -TR_commManagerEnableWrite(void * _this, TR_Event event) | 121 | +TR_commManagerPollEnableWrite(void * _this, TR_Event event) |
| 117 | { | 122 | { |
| 118 | TR_CommManagerPoll this = _this; | 123 | TR_CommManagerPoll this = _this; |
| 119 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; | 124 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
| 120 | 125 | ||
| 121 | if (! TR_socketFinWr(endpoint->transport)) { | 126 | if (! TR_socketFinWr(endpoint->transport)) { |
| 122 | - this->fds[endpoint->transport->handle].event |= POLLOUT; | 127 | + this->fds[endpoint->transport->handle].events |= POLLOUT; |
| 123 | } | 128 | } |
| 124 | } | 129 | } |
| 125 | 130 | ||
| 126 | static | 131 | static |
| 127 | -int | ||
| 128 | -TR_commManagerDisableWrite(void * _this, TR_Event event) | 132 | +void |
| 133 | +TR_commManagerPollDisableWrite(void * _this, TR_Event event) | ||
| 129 | { | 134 | { |
| 130 | TR_CommManagerPoll this = _this; | 135 | TR_CommManagerPoll this = _this; |
| 131 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; | 136 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
| 132 | 137 | ||
| 133 | - this->fds[endpoint->transport->handle].event &= ~POLLOUT; | 138 | + this->fds[endpoint->transport->handle].events &= ~POLLOUT; |
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | static | 141 | static |
| 137 | -int | ||
| 138 | -TR_commManagerClose(void * _this, TR_Event event) | 142 | +void |
| 143 | +TR_commManagerPollClose(void * _this, TR_Event event) | ||
| 139 | { | 144 | { |
| 140 | TR_CommManagerPoll this = _this; | 145 | TR_CommManagerPoll this = _this; |
| 141 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; | 146 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
| 142 | 147 | ||
| 143 | - this->fds[endpoint->transport->handle].event = 0; | ||
| 144 | - this->fds[endpoint->transport->handle].fs = -1; | 148 | + this->fds[endpoint->transport->handle].events = 0; |
| 149 | + this->fds[endpoint->transport->handle].fd = -1; | ||
| 145 | } | 150 | } |
| 146 | 151 | ||
| 147 | static | 152 | static |
| 148 | -int | ||
| 149 | -TR_commManagerDisableRead(void * _this, TR_Event event) | 153 | +void |
| 154 | +TR_commManagerPollDisableRead(void * _this, TR_Event event) | ||
| 150 | { | 155 | { |
| 151 | TR_CommManagerPoll this = _this; | 156 | TR_CommManagerPoll this = _this; |
| 152 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; | 157 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
| 153 | 158 | ||
| 154 | - this->fds[endpoint->transport->handle].event &= ~POLLIN; | ||
| 155 | -} | ||
| 156 | - | ||
| 157 | -static | ||
| 158 | -int | ||
| 159 | -TR_commManagerShutdownRead(void * _this, TR_Event event) | ||
| 160 | -{ | 159 | + this->fds[endpoint->transport->handle].events &= ~POLLIN; |
| 161 | } | 160 | } |
| 162 | 161 | ||
| 163 | static | 162 | static |
| 164 | void | 163 | void |
| 165 | -commManagerPollCvInit(TR_class_ptr cls) { | 164 | +TR_commManagerPollCvInit(TR_class_ptr cls) { |
| 166 | TR_INHERIT_CLASSVARS(TR_CommManagerPoll, TR_CommManager); | 165 | TR_INHERIT_CLASSVARS(TR_CommManagerPoll, TR_CommManager); |
| 167 | } | 166 | } |
| 168 | 167 | ||
| @@ -179,7 +178,7 @@ TR_INIT_IFACE( | @@ -179,7 +178,7 @@ TR_INIT_IFACE( | ||
| 179 | TR_CREATE_CLASS( | 178 | TR_CREATE_CLASS( |
| 180 | TR_CommManagerPoll, | 179 | TR_CommManagerPoll, |
| 181 | TR_CommManager, | 180 | TR_CommManager, |
| 182 | - TR_CommManagerPollCvInit, | 181 | + TR_commManagerPollCvInit, |
| 183 | TR_IF(TR_Class)); | 182 | TR_IF(TR_Class)); |
| 184 | 183 | ||
| 185 | // vim: set ts=4 sw=4: | 184 | // vim: set ts=4 sw=4: |
| @@ -20,6 +20,8 @@ | @@ -20,6 +20,8 @@ | ||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | +#include <poll.h> | ||
| 24 | + | ||
| 23 | #include "trbase.h" | 25 | #include "trbase.h" |
| 24 | #include "trio.h" | 26 | #include "trio.h" |
| 25 | #include "trevent.h" | 27 | #include "trevent.h" |
| @@ -33,10 +35,10 @@ TR_commManagerShutdown(void * _this, TR_Event event) | @@ -33,10 +35,10 @@ TR_commManagerShutdown(void * _this, TR_Event event) | ||
| 33 | nfds_t i; | 35 | nfds_t i; |
| 34 | 36 | ||
| 35 | for (i=0; i<this->n_endpoints; i++) { | 37 | for (i=0; i<this->n_endpoints; i++) { |
| 36 | - if (this->endpoints[handle]) { | 38 | + if (this->endpoints[i]) { |
| 37 | TR_eventHandlerIssueEvent( | 39 | TR_eventHandlerIssueEvent( |
| 38 | (TR_EventHandler)_this, | 40 | (TR_EventHandler)_this, |
| 39 | - (TR_EventSubject)this->endpoints[handle], | 41 | + (TR_EventSubject)this->endpoints[i], |
| 40 | TR_CEP_EVENT_CLOSE, | 42 | TR_CEP_EVENT_CLOSE, |
| 41 | NULL); | 43 | NULL); |
| 42 | } | 44 | } |
| @@ -89,14 +89,14 @@ connectorCvInit(TR_class_ptr cls) | @@ -89,14 +89,14 @@ connectorCvInit(TR_class_ptr cls) | ||
| 89 | connectorAccept); | 89 | connectorAccept); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | -TR_INSTANCE(TR_Hash, _event_methods); | 92 | +TR_INSTANCE(TR_Hash, connectorEventMethods); |
| 93 | TR_INIT_IFACE(TR_Class, connectorCtor, connectorDtor, NULL); | 93 | TR_INIT_IFACE(TR_Class, connectorCtor, connectorDtor, NULL); |
| 94 | TR_CREATE_CLASS( | 94 | TR_CREATE_CLASS( |
| 95 | TR_Connector, | 95 | TR_Connector, |
| 96 | TR_EventHandler, | 96 | TR_EventHandler, |
| 97 | connectorCvInit, | 97 | connectorCvInit, |
| 98 | TR_IF(TR_Class)) = { | 98 | TR_IF(TR_Class)) = { |
| 99 | - { &(__event_methods.data) } | 99 | + { &(_connectorEventMethods.data) } |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | // vim: set ts=4 sw=4: | 102 | // vim: set ts=4 sw=4: |
| @@ -21,19 +21,21 @@ | @@ -21,19 +21,21 @@ | ||
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <errno.h> | 23 | #include <errno.h> |
| 24 | +#include <poll.h> | ||
| 24 | 25 | ||
| 25 | #include "trbase.h" | 26 | #include "trbase.h" |
| 26 | #include "trevent.h" | 27 | #include "trevent.h" |
| 27 | 28 | ||
| 28 | #include "tr/interface/comm_manager.h" | 29 | #include "tr/interface/comm_manager.h" |
| 29 | #include "tr/comm_end_point.h" | 30 | #include "tr/comm_end_point.h" |
| 31 | +#include "tr/comm_manager.h" | ||
| 30 | 32 | ||
| 31 | TR_CREATE_INTERFACE(TR_CommManager, 7); | 33 | TR_CREATE_INTERFACE(TR_CommManager, 7); |
| 32 | 34 | ||
| 33 | void | 35 | void |
| 34 | TR_commManagerAddEndpoint(void * _this, TR_CommEndPoint endpoint) | 36 | TR_commManagerAddEndpoint(void * _this, TR_CommEndPoint endpoint) |
| 35 | { | 37 | { |
| 36 | - TR_ConnManager this = _this; | 38 | + TR_CommManager this = _this; |
| 37 | 39 | ||
| 38 | if (this->endpoints[endpoint->transport->handle]) { | 40 | if (this->endpoints[endpoint->transport->handle]) { |
| 39 | // this should never happen, but if so we assume this is a leftover | 41 | // this should never happen, but if so we assume this is a leftover |
| @@ -92,7 +94,7 @@ TR_commManagerDisableWrite(void * _this, TR_Event event) | @@ -92,7 +94,7 @@ TR_commManagerDisableWrite(void * _this, TR_Event event) | ||
| 92 | int | 94 | int |
| 93 | TR_commManagerClose(void * _this, TR_Event event) | 95 | TR_commManagerClose(void * _this, TR_Event event) |
| 94 | { | 96 | { |
| 95 | - TR_ConnManager this = _this; | 97 | + TR_CommManager this = _this; |
| 96 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; | 98 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
| 97 | 99 | ||
| 98 | TR_socketShutdown(endpoint->transport); | 100 | TR_socketShutdown(endpoint->transport); |
| @@ -114,7 +116,7 @@ TR_commManagerShutdownRead(void * _this, TR_Event event) | @@ -114,7 +116,7 @@ TR_commManagerShutdownRead(void * _this, TR_Event event) | ||
| 114 | event->subject, | 116 | event->subject, |
| 115 | TR_CEP_EVENT_CLOSE, | 117 | TR_CEP_EVENT_CLOSE, |
| 116 | NULL); | 118 | NULL); |
| 117 | - } else if (TR_cepHasPendingData(endpoint)) { | 119 | + } else if (TR_cepHasPendingData((TR_CommEndPoint)event->subject)) { |
| 118 | // handle pending data... close is issued from disableWrite | 120 | // handle pending data... close is issued from disableWrite |
| 119 | TR_eventHandlerIssueEvent( | 121 | TR_eventHandlerIssueEvent( |
| 120 | (TR_EventHandler)_this, | 122 | (TR_EventHandler)_this, |
| @@ -122,7 +124,7 @@ TR_commManagerShutdownRead(void * _this, TR_Event event) | @@ -122,7 +124,7 @@ TR_commManagerShutdownRead(void * _this, TR_Event event) | ||
| 122 | TR_CEP_EVENT_CLOSE, | 124 | TR_CEP_EVENT_CLOSE, |
| 123 | NULL); | 125 | NULL); |
| 124 | } else { | 126 | } else { |
| 125 | - TR_cepSetClose(endpoint); | 127 | + TR_cepSetClose((TR_CommEndPoint)event->subject); |
| 126 | } | 128 | } |
| 127 | 129 | ||
| 128 | return 0; | 130 | return 0; |
Please
register
or
login
to post a comment