Commit d32d05f52e85c2ac870cb260d27fb9dace236387
1 parent
17cf44b9
Revert "try for a threaded server, but not very much luck now."
This reverts commit c0b33ec7.
Showing
16 changed files
with
10 additions
and
236 deletions
@@ -40,8 +40,5 @@ test-driver | @@ -40,8 +40,5 @@ test-driver | ||
40 | /assets/html/_documentation.html | 40 | /assets/html/_documentation.html |
41 | tags | 41 | tags |
42 | /trcomm.h* | 42 | /trcomm.h* |
43 | -/testers/testserver | ||
44 | -/testers/testserver2 | ||
45 | -/testers/testserver_thread | ||
46 | -/testers/testudp | ||
47 | -/testers/testtcp | 43 | +/testers/testserver* |
44 | +/testers/testclient* |
@@ -18,5 +18,5 @@ nobase_include_HEADERS = trcomm.h \ | @@ -18,5 +18,5 @@ nobase_include_HEADERS = trcomm.h \ | ||
18 | tr/simple_client.h \ | 18 | tr/simple_client.h \ |
19 | tr/interface/comm_end_point.h \ | 19 | tr/interface/comm_end_point.h \ |
20 | tr/interface/comm_manager.h \ | 20 | tr/interface/comm_manager.h \ |
21 | - tr/interface/protocol.h \ | ||
22 | - tr/threaded_server.h | 21 | + tr/interface/protocol.h |
22 | + |
include/tr/threaded_server.h
deleted
100644 → 0
1 | -/** | ||
2 | - * \file | ||
3 | - * | ||
4 | - * \author Georg Hopp | ||
5 | - * | ||
6 | - * \copyright | ||
7 | - * Copyright © 2014 Georg Hopp | ||
8 | - * | ||
9 | - * This program is free software: you can redistribute it and/or modify | ||
10 | - * it under the terms of the GNU General Public License as published by | ||
11 | - * the Free Software Foundation, either version 3 of the License, or | ||
12 | - * (at your option) any later version. | ||
13 | - * | ||
14 | - * This program is distributed in the hope that it will be useful, | ||
15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | - * GNU General Public License for more details. | ||
18 | - * | ||
19 | - * You should have received a copy of the GNU General Public License | ||
20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | - */ | ||
22 | - | ||
23 | -#ifndef __TR_THREADED_SERVER_H__ | ||
24 | -#define __TR_THREADED_SERVER_H__ | ||
25 | - | ||
26 | -#include <sys/types.h> | ||
27 | - | ||
28 | -#include "trbase.h" | ||
29 | -#include "trevent.h" | ||
30 | - | ||
31 | -#include "tr/server.h" | ||
32 | - | ||
33 | -TR_CLASS(TR_ThreadedServer) { | ||
34 | - TR_EXTENDS(TR_Server); | ||
35 | - | ||
36 | - TR_EventThread * threads; | ||
37 | - size_t n_threads; | ||
38 | -}; | ||
39 | -TR_INSTANCE_INIT(TR_ThreadedServer); | ||
40 | -TR_CLASSVARS_DECL(TR_ThreadedServer) {}; | ||
41 | - | ||
42 | -void TR_threadedServerStart(TR_ThreadedServer, unsigned long); | ||
43 | - | ||
44 | -#endif // __TR_THREADED_SERVER_H__ | ||
45 | - | ||
46 | -// vim: set ts=4 sw=4: | ||
47 | - |
@@ -21,7 +21,6 @@ | @@ -21,7 +21,6 @@ | ||
21 | #include "tr/interface/comm_end_point.h" | 21 | #include "tr/interface/comm_end_point.h" |
22 | #include "tr/interface/comm_manager.h" | 22 | #include "tr/interface/comm_manager.h" |
23 | #include "tr/interface/protocol.h" | 23 | #include "tr/interface/protocol.h" |
24 | -#include "tr/threaded_server.h" | ||
25 | 24 | ||
26 | #endif // __TR_COMM_H__ | 25 | #endif // __TR_COMM_H__ |
27 | 26 |
@@ -25,8 +25,6 @@ TRCOMM = cet_accept.c \ | @@ -25,8 +25,6 @@ TRCOMM = cet_accept.c \ | ||
25 | protocol_message_raw.c \ | 25 | protocol_message_raw.c \ |
26 | protocol_raw.c \ | 26 | protocol_raw.c \ |
27 | server.c \ | 27 | server.c \ |
28 | - threaded_server.c \ | ||
29 | - threaded_server_start.c \ | ||
30 | server_bind_tcp.c \ | 28 | server_bind_tcp.c \ |
31 | server_bind_udp.c \ | 29 | server_bind_udp.c \ |
32 | server_start.c \ | 30 | server_start.c \ |
@@ -103,8 +103,6 @@ static | @@ -103,8 +103,6 @@ static | ||
103 | void | 103 | void |
104 | commManagerCvInit(TR_class_ptr cls) | 104 | commManagerCvInit(TR_class_ptr cls) |
105 | { | 105 | { |
106 | - TR_CLASSVARS(TR_EventHandler, cls)->event_methods->tree = TR_new(TR_Tree); | ||
107 | - | ||
108 | TR_EVENT_HANDLER_SET_METHOD( | 106 | TR_EVENT_HANDLER_SET_METHOD( |
109 | cls, TR_EventDispatcher, | 107 | cls, TR_EventDispatcher, |
110 | TR_DISPATCHER_EVENT_DATA_WAIT, | 108 | TR_DISPATCHER_EVENT_DATA_WAIT, |
@@ -92,13 +92,11 @@ static | @@ -92,13 +92,11 @@ static | ||
92 | void | 92 | void |
93 | connectorCvInit(TR_class_ptr cls) | 93 | connectorCvInit(TR_class_ptr cls) |
94 | { | 94 | { |
95 | - TR_CLASSVARS(TR_EventHandler, cls)->event_methods->tree = TR_new(TR_Tree); | ||
96 | - | ||
97 | - TR_EVENT_HANDLER_SET_METHOD( | ||
98 | - cls, | ||
99 | - TR_ConnEntryPoint, | ||
100 | - TR_CET_EVENT_ACC_READY, | ||
101 | - connectorAccept); | 95 | + TR_EVENT_HANDLER_SET_METHOD( |
96 | + cls, | ||
97 | + TR_ConnEntryPoint, | ||
98 | + TR_CET_EVENT_ACC_READY, | ||
99 | + connectorAccept); | ||
102 | } | 100 | } |
103 | 101 | ||
104 | TR_INSTANCE(TR_Hash, connectorEventMethods); | 102 | TR_INSTANCE(TR_Hash, connectorEventMethods); |
@@ -158,8 +158,6 @@ static | @@ -158,8 +158,6 @@ static | ||
158 | void | 158 | void |
159 | ioHandlerCvInit(TR_class_ptr cls) | 159 | ioHandlerCvInit(TR_class_ptr cls) |
160 | { | 160 | { |
161 | - TR_CLASSVARS(TR_EventHandler, cls)->event_methods->tree = TR_new(TR_Tree); | ||
162 | - | ||
163 | TR_EVENT_HANDLER_SET_METHOD( | 161 | TR_EVENT_HANDLER_SET_METHOD( |
164 | cls, | 162 | cls, |
165 | TR_CommEndPoint, | 163 | TR_CommEndPoint, |
@@ -125,8 +125,6 @@ static | @@ -125,8 +125,6 @@ static | ||
125 | void | 125 | void |
126 | protocolHandlerCvInit(TR_class_ptr cls) | 126 | protocolHandlerCvInit(TR_class_ptr cls) |
127 | { | 127 | { |
128 | - TR_CLASSVARS(TR_EventHandler, cls)->event_methods->tree = TR_new(TR_Tree); | ||
129 | - | ||
130 | TR_EVENT_HANDLER_SET_METHOD( | 128 | TR_EVENT_HANDLER_SET_METHOD( |
131 | cls, | 129 | cls, |
132 | TR_CommEndPoint, | 130 | TR_CommEndPoint, |
@@ -135,8 +135,6 @@ static | @@ -135,8 +135,6 @@ static | ||
135 | void | 135 | void |
136 | simpleClientCvInit(TR_class_ptr cls) | 136 | simpleClientCvInit(TR_class_ptr cls) |
137 | { | 137 | { |
138 | - TR_CLASSVARS(TR_EventHandler, cls)->event_methods->tree = TR_new(TR_Tree); | ||
139 | - | ||
140 | TR_EVENT_HANDLER_SET_METHOD( | 138 | TR_EVENT_HANDLER_SET_METHOD( |
141 | cls, | 139 | cls, |
142 | TR_EventDispatcher, | 140 | TR_EventDispatcher, |
src/threaded_server.c
deleted
100644 → 0
1 | -/** | ||
2 | - * \file | ||
3 | - * | ||
4 | - * \author Georg Hopp | ||
5 | - * | ||
6 | - * \copyright | ||
7 | - * Copyright © 2014 Georg Hopp | ||
8 | - * | ||
9 | - * This program is free software: you can redistribute it and/or modify | ||
10 | - * it under the terms of the GNU General Public License as published by | ||
11 | - * the Free Software Foundation, either version 3 of the License, or | ||
12 | - * (at your option) any later version. | ||
13 | - * | ||
14 | - * This program is distributed in the hope that it will be useful, | ||
15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | - * GNU General Public License for more details. | ||
18 | - * | ||
19 | - * You should have received a copy of the GNU General Public License | ||
20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | - */ | ||
22 | - | ||
23 | -#include <stdarg.h> | ||
24 | - | ||
25 | -#include <sys/types.h> | ||
26 | - | ||
27 | -#include "trbase.h" | ||
28 | -#include "trio.h" | ||
29 | -#include "trevent.h" | ||
30 | - | ||
31 | -#include "tr/threaded_server.h" | ||
32 | - | ||
33 | -static | ||
34 | -int | ||
35 | -threadedServerCtor(void * _this, va_list * params) | ||
36 | -{ | ||
37 | - TR_ThreadedServer this = _this; | ||
38 | - int i; | ||
39 | - | ||
40 | - TR_PARENTCALL(TR_ThreadedServer, _this, TR_Class, ctor, params); | ||
41 | - | ||
42 | - this->n_threads = va_arg(*params, size_t); | ||
43 | - this->threads = TR_malloc(sizeof(TR_EventThread) * this->n_threads); | ||
44 | - | ||
45 | - for (i=0; i<this->n_threads; i++) { | ||
46 | - this->threads[i] = TR_new( | ||
47 | - TR_EventThread, | ||
48 | - ((TR_Server)this)->dispatcher); | ||
49 | - } | ||
50 | - | ||
51 | - return 0; | ||
52 | -} | ||
53 | - | ||
54 | -static | ||
55 | -void | ||
56 | -threadedServerDtor(void * _this) | ||
57 | -{ | ||
58 | - TR_ThreadedServer this = _this; | ||
59 | - int i; | ||
60 | - | ||
61 | - for (i=0; i<this->n_threads; i++) { | ||
62 | - TR_delete(this->threads[i]); | ||
63 | - } | ||
64 | - | ||
65 | - TR_PARENTCALL(TR_ThreadedServer, _this, TR_Class, dtor); | ||
66 | -} | ||
67 | - | ||
68 | -TR_INIT_IFACE(TR_Class, threadedServerCtor, threadedServerDtor, NULL); | ||
69 | -TR_CREATE_CLASS(TR_ThreadedServer, TR_Server, NULL, TR_IF(TR_Class)); | ||
70 | - | ||
71 | -// vim: set ts=4 sw=4: |
src/threaded_server_start.c
deleted
100644 → 0
1 | -/** | ||
2 | - * \file | ||
3 | - * | ||
4 | - * \author Georg Hopp | ||
5 | - * | ||
6 | - * \copyright | ||
7 | - * Copyright © 2014 Georg Hopp | ||
8 | - * | ||
9 | - * This program is free software: you can redistribute it and/or modify | ||
10 | - * it under the terms of the GNU General Public License as published by | ||
11 | - * the Free Software Foundation, either version 3 of the License, or | ||
12 | - * (at your option) any later version. | ||
13 | - * | ||
14 | - * This program is distributed in the hope that it will be useful, | ||
15 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | - * GNU General Public License for more details. | ||
18 | - * | ||
19 | - * You should have received a copy of the GNU General Public License | ||
20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | - */ | ||
22 | - | ||
23 | -#include "trbase.h" | ||
24 | -#include "trevent.h" | ||
25 | - | ||
26 | -#include "tr/threaded_server.h" | ||
27 | - | ||
28 | -void | ||
29 | -TR_threadedServerStart(TR_ThreadedServer this, unsigned long heartbeat) | ||
30 | -{ | ||
31 | - int i; | ||
32 | - | ||
33 | - TR_eventDispatcherSetHeartbeat(((TR_Server)this)->dispatcher, heartbeat); | ||
34 | - | ||
35 | - for (i=0; i<this->n_threads; i++) { | ||
36 | - TR_eventThreadStart(this->threads[i]); | ||
37 | - } | ||
38 | - | ||
39 | - for (i=0; i<this->n_threads; i++) { | ||
40 | - TR_eventThreadJoin(this->threads[i]); | ||
41 | - } | ||
42 | -} | ||
43 | - | ||
44 | -// vim: set ts=4 sw=4: |
@@ -7,4 +7,3 @@ gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver testse | @@ -7,4 +7,3 @@ gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver testse | ||
7 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver2 testserver2.c test_handler.o ${TRLIBS} | 7 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testserver2 testserver2.c test_handler.o ${TRLIBS} |
8 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testtcp testclient.c ${TRLIBS} | 8 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -o testtcp testclient.c ${TRLIBS} |
9 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -DUDP=1 -o testudp testclient.c ${TRLIBS} | 9 | gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -DUDP=1 -o testudp testclient.c ${TRLIBS} |
10 | -gcc ${CFLAGS} -I/usr/local/include -L/usr/local/lib ${LIBS} -lpthread -o testserver_thread testserver_thread.c test_handler.o ${TRLIBS} |
@@ -98,8 +98,6 @@ static | @@ -98,8 +98,6 @@ static | ||
98 | void | 98 | void |
99 | testHandlerCvInit(TR_class_ptr class) | 99 | testHandlerCvInit(TR_class_ptr class) |
100 | { | 100 | { |
101 | - TR_CLASSVARS(TR_EventHandler, class)->event_methods->tree = TR_new(TR_Tree); | ||
102 | - | ||
103 | TR_EVENT_HANDLER_SET_METHOD( | 101 | TR_EVENT_HANDLER_SET_METHOD( |
104 | class, | 102 | class, |
105 | TR_EventDispatcher, | 103 | TR_EventDispatcher, |
@@ -31,7 +31,6 @@ main (int argc, char * argv[]) | @@ -31,7 +31,6 @@ main (int argc, char * argv[]) | ||
31 | int i, j=0; | 31 | int i, j=0; |
32 | 32 | ||
33 | TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger2); | 33 | TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger2); |
34 | - | ||
35 | protocol = TR_new(TR_ProtocolRaw); | 34 | protocol = TR_new(TR_ProtocolRaw); |
36 | #if UDP | 35 | #if UDP |
37 | socket = TR_new(TR_UdpSocket, TR_logger, "127.0.0.1", 5678, 0); | 36 | socket = TR_new(TR_UdpSocket, TR_logger, "127.0.0.1", 5678, 0); |
@@ -57,7 +56,7 @@ main (int argc, char * argv[]) | @@ -57,7 +56,7 @@ main (int argc, char * argv[]) | ||
57 | message = (TR_ProtoMessageRaw)TR_simpleClientIssue( | 56 | message = (TR_ProtoMessageRaw)TR_simpleClientIssue( |
58 | client, | 57 | client, |
59 | (TR_ProtoMessage)message, | 58 | (TR_ProtoMessage)message, |
60 | - 100000000000000000); | 59 | + 100); |
61 | 60 | ||
62 | if (! message) break; | 61 | if (! message) break; |
63 | #if 0 | 62 | #if 0 |
testers/testserver_thread.c
deleted
100644 → 0
1 | -#include <stdio.h> | ||
2 | -#include <string.h> | ||
3 | -#include <inttypes.h> | ||
4 | - | ||
5 | -#include "trbase.h" | ||
6 | -#include "trcomm.h" | ||
7 | -#include "trio.h" | ||
8 | -#include "trevent.h" | ||
9 | - | ||
10 | -#include "test_handler.h" | ||
11 | - | ||
12 | -TR_INSTANCE(TR_LoggerSyslog, mylogger, {TR_LOGGER_INFO}); | ||
13 | -TR_INSTANCE(TR_LoggerStderr, mylogger2, {TR_LOGGER_INFO}); | ||
14 | - | ||
15 | -int | ||
16 | -main (int argc, char * argv[]) | ||
17 | -{ | ||
18 | - TR_ThreadedServer server = TR_new(TR_ThreadedServer, 2); | ||
19 | - TR_Protocol protocol = TR_new(TR_ProtocolRaw); | ||
20 | - TestHandler test_handler = TR_new(TestHandler); | ||
21 | - | ||
22 | - //TR_logger = TR_INSTANCE_CAST(TR_Logger, mylogger2); | ||
23 | - | ||
24 | - TR_serverAddHandler((TR_Server)server, (TR_EventHandler)test_handler); | ||
25 | - TR_serverBindTcp((TR_Server)server, "0.0.0.0", 5678, protocol); | ||
26 | - TR_serverBindUdp((TR_Server)server, "0.0.0.0", 5678, protocol); | ||
27 | - | ||
28 | - TR_threadedServerStart(server, 1000); | ||
29 | - | ||
30 | - puts("cleanup..."); | ||
31 | - | ||
32 | - TR_delete(server); | ||
33 | - TR_delete(test_handler); | ||
34 | - TR_delete(protocol); | ||
35 | - | ||
36 | - TR_eventHandlerClassCleanup(TestHandler); | ||
37 | - TR_serverClassCleanup(); | ||
38 | - | ||
39 | - TR_cleanup(); | ||
40 | - | ||
41 | - return 0; | ||
42 | -} | ||
43 | - | ||
44 | -// vim: set ts=4 sw=4: |
Please
register
or
login
to post a comment