quickfix_ruby_ud 2.0.7-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,274 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef SHARED_ARRAY
|
23
|
+
#define SHARED_ARRAY
|
24
|
+
|
25
|
+
#include "config-all.h"
|
26
|
+
|
27
|
+
#include <atomic>
|
28
|
+
#include <cstdlib>
|
29
|
+
#include <cstring>
|
30
|
+
#include <new>
|
31
|
+
|
32
|
+
namespace FIX {
|
33
|
+
/// Shared array with atomic reference count
|
34
|
+
#ifndef NO_UNALIGNED_ACCESS
|
35
|
+
template <typename T> class shared_array {
|
36
|
+
enum {
|
37
|
+
data_offset = (sizeof(std::atomic<long>) / sizeof(T) + 1)
|
38
|
+
};
|
39
|
+
|
40
|
+
public:
|
41
|
+
shared_array()
|
42
|
+
: m_size(0),
|
43
|
+
m_buffer(0) {}
|
44
|
+
|
45
|
+
shared_array(const shared_array &rhs)
|
46
|
+
: m_size(rhs.m_size),
|
47
|
+
m_buffer(rhs.m_buffer) {
|
48
|
+
rhs.attach();
|
49
|
+
}
|
50
|
+
|
51
|
+
shared_array(shared_array &&rhs)
|
52
|
+
: m_size(rhs.m_size),
|
53
|
+
m_buffer(rhs.m_buffer) {
|
54
|
+
rhs.m_size = 0;
|
55
|
+
rhs.m_buffer = 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
~shared_array() { release(); }
|
59
|
+
|
60
|
+
shared_array &operator=(shared_array &&rhs) noexcept {
|
61
|
+
if (&rhs == this) {
|
62
|
+
return *this;
|
63
|
+
}
|
64
|
+
|
65
|
+
release();
|
66
|
+
|
67
|
+
m_size = rhs.m_size;
|
68
|
+
m_buffer = rhs.m_buffer;
|
69
|
+
|
70
|
+
rhs.m_size = 0;
|
71
|
+
rhs.m_buffer = 0;
|
72
|
+
|
73
|
+
return *this;
|
74
|
+
}
|
75
|
+
|
76
|
+
shared_array &operator=(const shared_array &rhs) {
|
77
|
+
if (&rhs == this) {
|
78
|
+
return *this;
|
79
|
+
}
|
80
|
+
|
81
|
+
rhs.attach();
|
82
|
+
release();
|
83
|
+
|
84
|
+
m_size = rhs.m_size;
|
85
|
+
m_buffer = rhs.m_buffer;
|
86
|
+
|
87
|
+
return *this;
|
88
|
+
}
|
89
|
+
|
90
|
+
std::size_t size() const { return m_size; }
|
91
|
+
|
92
|
+
bool empty() const { return m_buffer == 0; }
|
93
|
+
|
94
|
+
operator T *() const { return &m_buffer[data_offset]; }
|
95
|
+
|
96
|
+
// optimized function to allocate storage for buffer and counter object at once
|
97
|
+
static shared_array create(const std::size_t nSize) {
|
98
|
+
if (nSize == 0) {
|
99
|
+
return shared_array();
|
100
|
+
}
|
101
|
+
|
102
|
+
// verify the needed buffer size to allocate counter object and nSize elements
|
103
|
+
const std::size_t sizeToAllocate = data_offset + nSize;
|
104
|
+
|
105
|
+
// allocate and zero-fill the buffer
|
106
|
+
T *storage = new T[sizeToAllocate];
|
107
|
+
memset(reinterpret_cast<void *>(storage), 0, sizeToAllocate * sizeof(T));
|
108
|
+
|
109
|
+
// create the counter object at the end of the storage
|
110
|
+
// with initial reference count set to 1
|
111
|
+
new (storage) std::atomic<long>(1);
|
112
|
+
|
113
|
+
return shared_array(storage, nSize);
|
114
|
+
}
|
115
|
+
|
116
|
+
private:
|
117
|
+
shared_array(T *buff, std::size_t nSize)
|
118
|
+
: m_size(nSize),
|
119
|
+
m_buffer(buff) {}
|
120
|
+
|
121
|
+
std::atomic<long> *get_counter() const { return reinterpret_cast<std::atomic<long> *>(m_buffer); }
|
122
|
+
|
123
|
+
void increment_reference_count() const {
|
124
|
+
std::atomic<long> *counter = get_counter();
|
125
|
+
++(*counter);
|
126
|
+
}
|
127
|
+
|
128
|
+
long decrement_reference_count() const {
|
129
|
+
std::atomic<long> *counter = get_counter();
|
130
|
+
return --(*counter);
|
131
|
+
}
|
132
|
+
|
133
|
+
void attach() const {
|
134
|
+
if (!empty()) {
|
135
|
+
increment_reference_count();
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
void release() {
|
140
|
+
if (empty()) {
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
144
|
+
// free object if reference count has decreased to zero
|
145
|
+
if (decrement_reference_count() == 0) {
|
146
|
+
T *tmpBuff = m_buffer;
|
147
|
+
std::atomic<long> *tmpCounter = get_counter();
|
148
|
+
|
149
|
+
m_buffer = 0;
|
150
|
+
m_size = 0;
|
151
|
+
|
152
|
+
// explicitly call destructor for the counter object
|
153
|
+
tmpCounter->~atomic<long>();
|
154
|
+
|
155
|
+
delete[] tmpBuff;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
std::size_t m_size;
|
160
|
+
T *m_buffer;
|
161
|
+
};
|
162
|
+
#else
|
163
|
+
template <typename T> class shared_array {
|
164
|
+
public:
|
165
|
+
shared_array()
|
166
|
+
: m_size(0),
|
167
|
+
m_buffer(0),
|
168
|
+
m_pCtr(0) {}
|
169
|
+
|
170
|
+
shared_array(const shared_array &rhs)
|
171
|
+
: m_size(rhs.m_size),
|
172
|
+
m_buffer(rhs.m_buffer),
|
173
|
+
m_pCtr(rhs.m_pCtr) {
|
174
|
+
rhs.attach();
|
175
|
+
}
|
176
|
+
|
177
|
+
~shared_array() { release(); }
|
178
|
+
|
179
|
+
shared_array &operator=(const shared_array &rhs) {
|
180
|
+
if (&rhs == this) {
|
181
|
+
return *this;
|
182
|
+
}
|
183
|
+
|
184
|
+
rhs.attach();
|
185
|
+
release();
|
186
|
+
|
187
|
+
m_size = rhs.m_size;
|
188
|
+
m_buffer = rhs.m_buffer;
|
189
|
+
m_pCtr = rhs.m_pCtr;
|
190
|
+
|
191
|
+
return *this;
|
192
|
+
}
|
193
|
+
|
194
|
+
std::size_t size() const { return m_size; }
|
195
|
+
|
196
|
+
bool empty() const { return m_buffer == 0; }
|
197
|
+
|
198
|
+
operator T *() const { return m_buffer; }
|
199
|
+
|
200
|
+
// optimized function to allocate storage for buffer and counter object at once
|
201
|
+
static shared_array create(const std::size_t nSize) {
|
202
|
+
if (nSize <= 0) {
|
203
|
+
return shared_array();
|
204
|
+
}
|
205
|
+
|
206
|
+
// verify the needed buffer size to allocate counter object and nSize elements
|
207
|
+
const std::size_t sizeToAllocate = (nSize * sizeof(T)) + sizeof(std::atomic<long>) + 15;
|
208
|
+
|
209
|
+
// allocate and zero-fill the buffer
|
210
|
+
void *buf = std::malloc(sizeToAllocate);
|
211
|
+
memset(buf, 0, sizeToAllocate);
|
212
|
+
|
213
|
+
// create the counter object at the end of the storage
|
214
|
+
// with initial reference count set to 1
|
215
|
+
/* round up to multiple of alignment : add (alignment - 1) and then round down by masking */
|
216
|
+
void *ptr = (void *)(((uintptr_t)(buf) + nSize * sizeof(T) + 15) & ~(uintptr_t)0x0F);
|
217
|
+
new (ptr) std::atomic<long>(1);
|
218
|
+
|
219
|
+
T *storage = reinterpret_cast<T *>(buf);
|
220
|
+
return shared_array(storage, nSize, ptr);
|
221
|
+
}
|
222
|
+
|
223
|
+
private:
|
224
|
+
shared_array(T *buff, std::size_t nSize, void *pCtr)
|
225
|
+
: m_size(nSize),
|
226
|
+
m_buffer(buff),
|
227
|
+
m_pCtr(pCtr) {}
|
228
|
+
|
229
|
+
std::atomic<long> *get_counter() const { return reinterpret_cast<std::atomic<long> *>(m_pCtr); }
|
230
|
+
|
231
|
+
void increment_reference_count() const {
|
232
|
+
std::atomic<long> *counter = get_counter();
|
233
|
+
++(*counter);
|
234
|
+
}
|
235
|
+
|
236
|
+
long decrement_reference_count() const {
|
237
|
+
std::atomic<long> *counter = get_counter();
|
238
|
+
return --(*counter);
|
239
|
+
}
|
240
|
+
|
241
|
+
void attach() const {
|
242
|
+
if (!empty()) {
|
243
|
+
increment_reference_count();
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
void release() {
|
248
|
+
if (empty()) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
|
252
|
+
// free object if reference count has decreased to zero
|
253
|
+
if (decrement_reference_count() == 0) {
|
254
|
+
T *tmpBuff = m_buffer;
|
255
|
+
std::atomic<long> *tmpCounter = get_counter();
|
256
|
+
|
257
|
+
m_buffer = 0;
|
258
|
+
m_size = 0;
|
259
|
+
|
260
|
+
// explicitly call destructor for the counter object
|
261
|
+
tmpCounter->~atomic<long>();
|
262
|
+
|
263
|
+
std::free(tmpBuff);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
std::size_t m_size;
|
268
|
+
T *m_buffer;
|
269
|
+
void *m_pCtr;
|
270
|
+
};
|
271
|
+
#endif
|
272
|
+
} // namespace FIX
|
273
|
+
|
274
|
+
#endif
|
@@ -0,0 +1,216 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
** Copyright (c) 2001-2014
|
3
|
+
**
|
4
|
+
** This file is part of the QuickFIX FIX Engine
|
5
|
+
**
|
6
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
7
|
+
** license as defined by quickfixengine.org and appearing in the file
|
8
|
+
** LICENSE included in the packaging of this file.
|
9
|
+
**
|
10
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
11
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
12
|
+
**
|
13
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
14
|
+
**
|
15
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
16
|
+
** not clear to you.
|
17
|
+
**
|
18
|
+
****************************************************************************/
|
19
|
+
|
20
|
+
#ifdef _MSC_VER
|
21
|
+
#include "stdafx.h"
|
22
|
+
#else
|
23
|
+
#include "config.h"
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#include "Exceptions.h"
|
27
|
+
#include "Session.h"
|
28
|
+
#include "Settings.h"
|
29
|
+
#include "SocketAcceptor.h"
|
30
|
+
#include "Utility.h"
|
31
|
+
|
32
|
+
namespace FIX {
|
33
|
+
SocketAcceptor::SocketAcceptor(Application &application, MessageStoreFactory &factory, const SessionSettings &settings)
|
34
|
+
EXCEPT(ConfigError)
|
35
|
+
: Acceptor(application, factory, settings),
|
36
|
+
m_pServer(0) {}
|
37
|
+
|
38
|
+
SocketAcceptor::SocketAcceptor(
|
39
|
+
Application &application,
|
40
|
+
MessageStoreFactory &factory,
|
41
|
+
const SessionSettings &settings,
|
42
|
+
LogFactory &logFactory) EXCEPT(ConfigError)
|
43
|
+
: Acceptor(application, factory, settings, logFactory),
|
44
|
+
m_pServer(0) {}
|
45
|
+
|
46
|
+
SocketAcceptor::~SocketAcceptor() {
|
47
|
+
SocketConnections::iterator iter;
|
48
|
+
for (iter = m_connections.begin(); iter != m_connections.end(); ++iter) {
|
49
|
+
delete iter->second;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
void SocketAcceptor::onConfigure(const SessionSettings &sessionSettings) EXCEPT(ConfigError) {
|
54
|
+
for (const SessionID &sessionID : sessionSettings.getSessions()) {
|
55
|
+
const Dictionary &settings = sessionSettings.get(sessionID);
|
56
|
+
settings.getInt(SOCKET_ACCEPT_PORT);
|
57
|
+
if (settings.has(SOCKET_REUSE_ADDRESS)) {
|
58
|
+
settings.getBool(SOCKET_REUSE_ADDRESS);
|
59
|
+
}
|
60
|
+
if (settings.has(SOCKET_NODELAY)) {
|
61
|
+
settings.getBool(SOCKET_NODELAY);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
void SocketAcceptor::onInitialize(const SessionSettings &sessionSettings) EXCEPT(RuntimeError) {
|
67
|
+
uint16_t port = 0;
|
68
|
+
|
69
|
+
try {
|
70
|
+
m_pServer = new SocketServer(1);
|
71
|
+
|
72
|
+
for (const SessionID &sessionID : sessionSettings.getSessions()) {
|
73
|
+
const Dictionary &settings = sessionSettings.get(sessionID);
|
74
|
+
port = (short)settings.getInt(SOCKET_ACCEPT_PORT);
|
75
|
+
|
76
|
+
const bool reuseAddress = settings.has(SOCKET_REUSE_ADDRESS) ? settings.getBool(SOCKET_REUSE_ADDRESS) : true;
|
77
|
+
|
78
|
+
const bool noDelay = settings.has(SOCKET_NODELAY) ? settings.getBool(SOCKET_NODELAY) : false;
|
79
|
+
|
80
|
+
const int sendBufSize = settings.has(SOCKET_SEND_BUFFER_SIZE) ? settings.getInt(SOCKET_SEND_BUFFER_SIZE) : 0;
|
81
|
+
|
82
|
+
const int rcvBufSize = settings.has(SOCKET_RECEIVE_BUFFER_SIZE) ? settings.getInt(SOCKET_RECEIVE_BUFFER_SIZE) : 0;
|
83
|
+
|
84
|
+
socket_handle acceptSocket = m_pServer->add(port, reuseAddress, noDelay, sendBufSize, rcvBufSize);
|
85
|
+
m_portToSessions[socket_hostport(acceptSocket)].insert(sessionID);
|
86
|
+
m_sessionToPort[sessionID] = socket_hostport(acceptSocket);
|
87
|
+
}
|
88
|
+
} catch (SocketException &e) {
|
89
|
+
delete m_pServer;
|
90
|
+
m_pServer = 0;
|
91
|
+
throw RuntimeError(
|
92
|
+
"Unable to create, bind, or listen to port " + IntConvertor::convert((unsigned short)port) + " (" + e.what()
|
93
|
+
+ ")");
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
void SocketAcceptor::onStart() {
|
98
|
+
while (!isStopped() && m_pServer && m_pServer->block(*this)) {}
|
99
|
+
|
100
|
+
if (!m_pServer) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
time_t start = 0;
|
105
|
+
time_t now = 0;
|
106
|
+
|
107
|
+
::time(&start);
|
108
|
+
while (isLoggedOn()) {
|
109
|
+
m_pServer->block(*this);
|
110
|
+
if (::time(&now) - 5 >= start) {
|
111
|
+
break;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
m_pServer->close();
|
116
|
+
delete m_pServer;
|
117
|
+
m_pServer = 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
bool SocketAcceptor::onPoll() {
|
121
|
+
if (!m_pServer) {
|
122
|
+
return false;
|
123
|
+
}
|
124
|
+
|
125
|
+
time_t start = 0;
|
126
|
+
time_t now = 0;
|
127
|
+
|
128
|
+
if (isStopped()) {
|
129
|
+
if (start == 0) {
|
130
|
+
::time(&start);
|
131
|
+
}
|
132
|
+
if (!isLoggedOn()) {
|
133
|
+
start = 0;
|
134
|
+
return false;
|
135
|
+
}
|
136
|
+
if (::time(&now) - 5 >= start) {
|
137
|
+
start = 0;
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
m_pServer->block(*this, true);
|
143
|
+
return true;
|
144
|
+
}
|
145
|
+
|
146
|
+
void SocketAcceptor::onStop() {
|
147
|
+
if (m_pServer) {
|
148
|
+
m_pServer->close();
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
void SocketAcceptor::onConnect(SocketServer &server, socket_handle a, socket_handle s) {
|
153
|
+
if (!socket_isValid(s)) {
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
SocketConnections::iterator i = m_connections.find(s);
|
157
|
+
if (i != m_connections.end()) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
uint16_t port = server.socketToPort(a);
|
161
|
+
Sessions sessions = m_portToSessions[port];
|
162
|
+
m_connections[s] = new SocketConnection(s, sessions, &server.getMonitor());
|
163
|
+
|
164
|
+
std::stringstream stream;
|
165
|
+
stream << "Accepted connection from " << socket_peername(s) << " on port " << port;
|
166
|
+
|
167
|
+
if (getLog()) {
|
168
|
+
getLog()->onEvent(stream.str());
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
void SocketAcceptor::onWrite(SocketServer &server, socket_handle s) {
|
173
|
+
SocketConnections::iterator i = m_connections.find(s);
|
174
|
+
if (i == m_connections.end()) {
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
SocketConnection *pSocketConnection = i->second;
|
178
|
+
if (pSocketConnection->processQueue()) {
|
179
|
+
pSocketConnection->unsignal();
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
bool SocketAcceptor::onData(SocketServer &server, socket_handle s) {
|
184
|
+
SocketConnections::iterator i = m_connections.find(s);
|
185
|
+
if (i == m_connections.end()) {
|
186
|
+
return false;
|
187
|
+
}
|
188
|
+
SocketConnection *pSocketConnection = i->second;
|
189
|
+
return pSocketConnection->read(*this, server);
|
190
|
+
}
|
191
|
+
|
192
|
+
void SocketAcceptor::onDisconnect(SocketServer &, socket_handle s) {
|
193
|
+
SocketConnections::iterator i = m_connections.find(s);
|
194
|
+
if (i == m_connections.end()) {
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
SocketConnection *pSocketConnection = i->second;
|
198
|
+
|
199
|
+
Session *pSession = pSocketConnection->getSession();
|
200
|
+
if (pSession) {
|
201
|
+
pSession->disconnect();
|
202
|
+
}
|
203
|
+
|
204
|
+
delete pSocketConnection;
|
205
|
+
m_connections.erase(s);
|
206
|
+
}
|
207
|
+
|
208
|
+
void SocketAcceptor::onError(SocketServer &) {}
|
209
|
+
|
210
|
+
void SocketAcceptor::onTimeout(SocketServer &) {
|
211
|
+
SocketConnections::iterator i;
|
212
|
+
for (i = m_connections.begin(); i != m_connections.end(); ++i) {
|
213
|
+
i->second->onTimeout();
|
214
|
+
}
|
215
|
+
}
|
216
|
+
} // namespace FIX
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/* -*- C++ -*- */
|
2
|
+
|
3
|
+
/****************************************************************************
|
4
|
+
** Copyright (c) 2001-2014
|
5
|
+
**
|
6
|
+
** This file is part of the QuickFIX FIX Engine
|
7
|
+
**
|
8
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
9
|
+
** license as defined by quickfixengine.org and appearing in the file
|
10
|
+
** LICENSE included in the packaging of this file.
|
11
|
+
**
|
12
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
13
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
**
|
15
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
16
|
+
**
|
17
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
18
|
+
** not clear to you.
|
19
|
+
**
|
20
|
+
****************************************************************************/
|
21
|
+
|
22
|
+
#ifndef FIX_SOCKETACCEPTOR_H
|
23
|
+
#define FIX_SOCKETACCEPTOR_H
|
24
|
+
|
25
|
+
#ifdef _MSC_VER
|
26
|
+
#pragma warning(disable : 4503 4355 4786 4290)
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "Acceptor.h"
|
30
|
+
#include "SocketConnection.h"
|
31
|
+
#include "SocketServer.h"
|
32
|
+
|
33
|
+
namespace FIX {
|
34
|
+
/// Socket implementation of Acceptor.
|
35
|
+
class SocketAcceptor : public Acceptor, SocketServer::Strategy {
|
36
|
+
friend class SocketConnection;
|
37
|
+
|
38
|
+
public:
|
39
|
+
typedef std::map<SessionID, uint16_t> SessionToPort;
|
40
|
+
|
41
|
+
SocketAcceptor(Application &, MessageStoreFactory &, const SessionSettings &) EXCEPT(ConfigError);
|
42
|
+
SocketAcceptor(Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) EXCEPT(ConfigError);
|
43
|
+
|
44
|
+
virtual ~SocketAcceptor();
|
45
|
+
|
46
|
+
const SessionToPort &sessionToPort() { return m_sessionToPort; }
|
47
|
+
|
48
|
+
private:
|
49
|
+
bool readSettings(const SessionSettings &);
|
50
|
+
|
51
|
+
typedef std::set<SessionID> Sessions;
|
52
|
+
typedef std::map<uint16_t, Sessions> PortToSessions;
|
53
|
+
typedef std::map<socket_handle, SocketConnection *> SocketConnections;
|
54
|
+
|
55
|
+
void onConfigure(const SessionSettings &) EXCEPT(ConfigError);
|
56
|
+
void onInitialize(const SessionSettings &) EXCEPT(RuntimeError);
|
57
|
+
|
58
|
+
void onStart();
|
59
|
+
bool onPoll();
|
60
|
+
void onStop();
|
61
|
+
|
62
|
+
void onConnect(SocketServer &, socket_handle, socket_handle);
|
63
|
+
void onWrite(SocketServer &, socket_handle);
|
64
|
+
bool onData(SocketServer &, socket_handle);
|
65
|
+
void onDisconnect(SocketServer &, socket_handle);
|
66
|
+
void onError(SocketServer &);
|
67
|
+
void onTimeout(SocketServer &);
|
68
|
+
|
69
|
+
SocketServer *m_pServer;
|
70
|
+
PortToSessions m_portToSessions;
|
71
|
+
SessionToPort m_sessionToPort;
|
72
|
+
SocketConnections m_connections;
|
73
|
+
};
|
74
|
+
/*! @} */
|
75
|
+
} // namespace FIX
|
76
|
+
|
77
|
+
#endif // FIX_SOCKETACCEPTOR_H
|