some more explicit control over connection parameters
This commit is contained in:
parent
17ff7d3f82
commit
abbbb21a8e
|
|
@ -24,8 +24,9 @@ class ClientRepository(ClientRepositoryBase):
|
|||
|
||||
doNotDeallocateChannel = True
|
||||
|
||||
def __init__(self, dcFileNames = None, dcSuffix = ''):
|
||||
ClientRepositoryBase.__init__(self, dcFileNames = dcFileNames, dcSuffix = dcSuffix)
|
||||
def __init__(self, dcFileNames = None, dcSuffix = '', connectMethod = None,
|
||||
threadedNet = None):
|
||||
ClientRepositoryBase.__init__(self, dcFileNames = dcFileNames, dcSuffix = dcSuffix, connectMethod = connectMethod, threadedNet = threadedNet)
|
||||
self.setHandleDatagramsInternally(False)
|
||||
|
||||
# The doId allocator. The CMU LAN server may choose to
|
||||
|
|
|
|||
|
|
@ -25,8 +25,11 @@ class ClientRepositoryBase(ConnectionRepository):
|
|||
"""
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepositoryBase")
|
||||
|
||||
def __init__(self, dcFileNames = None, dcSuffix = ''):
|
||||
ConnectionRepository.__init__(self, ConnectionRepository.CM_HTTP, base.config, hasOwnerView=True)
|
||||
def __init__(self, dcFileNames = None, dcSuffix = '',
|
||||
connectMethod = None, threadedNet = None):
|
||||
if connectMethod is None:
|
||||
connectMethod = self.CM_HTTP
|
||||
ConnectionRepository.__init__(self, connectMethod, base.config, hasOwnerView = True, threadedNet = threadedNet)
|
||||
self.dcSuffix = dcSuffix
|
||||
if hasattr(self, 'setVerbose'):
|
||||
if self.config.GetBool('verbose-clientrepository'):
|
||||
|
|
|
|||
|
|
@ -33,13 +33,18 @@ class ConnectionRepository(
|
|||
GarbageCollectTaskName = "allowGarbageCollect"
|
||||
GarbageThresholdTaskName = "adjustGarbageCollectThreshold"
|
||||
|
||||
def __init__(self, connectMethod, config, hasOwnerView=False):
|
||||
def __init__(self, connectMethod, config, hasOwnerView = False,
|
||||
threadedNet = None):
|
||||
assert self.notify.debugCall()
|
||||
if threadedNet is None:
|
||||
# Default value.
|
||||
threadedNet = config.GetBool('threaded-net', False)
|
||||
|
||||
# let the C connection repository know whether we're supporting
|
||||
# 'owner' views of distributed objects (i.e. 'receives ownrecv',
|
||||
# 'I own this object and have a separate view of it regardless of
|
||||
# where it currently is located')
|
||||
CConnectionRepository.__init__(self, hasOwnerView)
|
||||
CConnectionRepository.__init__(self, hasOwnerView, threadedNet)
|
||||
self.setWantMessageBundling(config.GetBool('want-message-bundling', 1))
|
||||
# DoInterestManager.__init__ relies on CConnectionRepository being
|
||||
# initialized
|
||||
|
|
|
|||
|
|
@ -78,12 +78,20 @@ class ServerRepository:
|
|||
# record its current fields. That is left to the clients.
|
||||
|
||||
|
||||
def __init__(self, tcpPort, udpPort = None, dcFileNames = None):
|
||||
def __init__(self, tcpPort, udpPort = None, dcFileNames = None,
|
||||
threadedNet = None):
|
||||
if threadedNet is None:
|
||||
# Default value.
|
||||
threadedNet = config.GetBool('threaded-net', False)
|
||||
|
||||
# Set up networking interfaces.
|
||||
numThreads = 0
|
||||
if threadedNet:
|
||||
numThreads = 1
|
||||
self.qcm = QueuedConnectionManager()
|
||||
self.qcl = QueuedConnectionListener(self.qcm, 0)
|
||||
self.qcr = QueuedConnectionReader(self.qcm, 0)
|
||||
self.cw = ConnectionWriter(self.qcm, 0)
|
||||
self.qcl = QueuedConnectionListener(self.qcm, numThreads)
|
||||
self.qcr = QueuedConnectionReader(self.qcm, numThreads)
|
||||
self.cw = ConnectionWriter(self.qcm, numThreads)
|
||||
self.tcpRendezvous = self.qcm.openTCPServerRendezvous(tcpPort, 10)
|
||||
self.qcl.addConnection(self.tcpRendezvous)
|
||||
taskMgr.add(self.listenerPoll, "serverListenerPollTask")
|
||||
|
|
@ -137,6 +145,21 @@ class ServerRepository:
|
|||
|
||||
return task.again
|
||||
|
||||
def setTcpHeaderSize(self, headerSize):
|
||||
"""Sets the header size of TCP packets. At the present, legal
|
||||
values for this are 0, 2, or 4; this specifies the number of
|
||||
bytes to use encode the datagram length at the start of each
|
||||
TCP datagram. Sender and receiver must independently agree on
|
||||
this."""
|
||||
self.qcr.setTcpHeaderSize(headerSize)
|
||||
self.cw.setTcpHeaderSize(headerSize)
|
||||
|
||||
def getTcpHeaderSize(self):
|
||||
"""Returns the current setting of TCP header size. See
|
||||
setTcpHeaderSize(). """
|
||||
return self.qcr.getTcpHeaderSize()
|
||||
|
||||
|
||||
def importModule(self, dcImports, moduleName, importSymbols):
|
||||
""" Imports the indicated moduleName and all of its symbols
|
||||
into the current namespace. This more-or-less reimplements
|
||||
|
|
|
|||
|
|
@ -111,6 +111,17 @@ get_handle_datagrams_internally() const {
|
|||
return _handle_datagrams_internally;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CConnectionRepository::get_tcp_header_size
|
||||
// Access: Public
|
||||
// Description: Returns the current setting of TCP header size.
|
||||
// See set_tcp_header_size().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int CConnectionRepository::
|
||||
get_tcp_header_size() const {
|
||||
return _tcp_header_size;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CConnectionRepository::set_python_repository
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "dcPacker.h"
|
||||
|
||||
#include "config_distributed.h"
|
||||
#include "config_downloader.h"
|
||||
#include "httpChannel.h"
|
||||
#include "urlSpec.h"
|
||||
#include "datagramIterator.h"
|
||||
|
|
@ -44,7 +45,7 @@ PStatCollector CConnectionRepository::_update_pcollector("App:Show code:readerPo
|
|||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CConnectionRepository::
|
||||
CConnectionRepository(bool has_owner_view) :
|
||||
CConnectionRepository(bool has_owner_view, bool threaded_net) :
|
||||
_lock("CConnectionRepository::_lock"),
|
||||
#ifdef HAVE_PYTHON
|
||||
_python_repository(NULL),
|
||||
|
|
@ -54,8 +55,8 @@ CConnectionRepository(bool has_owner_view) :
|
|||
_http_conn(NULL),
|
||||
#endif
|
||||
#ifdef HAVE_NET
|
||||
_cw(&_qcm, 0),
|
||||
_qcr(&_qcm, 0),
|
||||
_cw(&_qcm, threaded_net ? 1 : 0),
|
||||
_qcr(&_qcm, threaded_net ? 1 : 0),
|
||||
#endif
|
||||
#ifdef WANT_NATIVE_NET
|
||||
_bdc(4096000,4096000,1400),
|
||||
|
|
@ -79,7 +80,7 @@ CConnectionRepository(bool has_owner_view) :
|
|||
_qcr.start_delay(min_lag, max_lag);
|
||||
}
|
||||
#endif
|
||||
|
||||
_tcp_header_size = tcp_header_size;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
PyObject * PyDitterator = DTool_CreatePyInstance(&_di,Dtool_DatagramIterator,false,false);
|
||||
|
|
@ -99,6 +100,31 @@ CConnectionRepository::
|
|||
disconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CConnectionRepository::set_tcp_header_size
|
||||
// Access: Public
|
||||
// Description: Sets the header size of TCP packets. At the present,
|
||||
// legal values for this are 0, 2, or 4; this specifies
|
||||
// the number of bytes to use encode the datagram length
|
||||
// at the start of each TCP datagram. Sender and
|
||||
// receiver must independently agree on this.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CConnectionRepository::
|
||||
set_tcp_header_size(int tcp_header_size) {
|
||||
_tcp_header_size = tcp_header_size;
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
if (_http_conn != (SocketStream *)NULL) {
|
||||
_http_conn->set_tcp_header_size(tcp_header_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NET
|
||||
_cw.set_tcp_header_size(tcp_header_size);
|
||||
_qcr.set_tcp_header_size(tcp_header_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CConnectionRepository::set_connection_http
|
||||
|
|
@ -115,6 +141,7 @@ set_connection_http(HTTPChannel *channel) {
|
|||
disconnect();
|
||||
nassertv(channel->is_connection_ready());
|
||||
_http_conn = channel->get_connection();
|
||||
_http_conn->set_tcp_header_size(_tcp_header_size);
|
||||
#ifdef SIMULATE_NETWORK_DELAY
|
||||
if (min_lag != 0.0 || max_lag != 0.0) {
|
||||
_http_conn->start_delay(min_lag, max_lag);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ class SocketStream;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_DIRECT CConnectionRepository {
|
||||
PUBLISHED:
|
||||
CConnectionRepository(bool has_owner_view = false);
|
||||
CConnectionRepository(bool has_owner_view = false,
|
||||
bool threaded_net = false);
|
||||
~CConnectionRepository();
|
||||
|
||||
INLINE DCFile &get_dc_file();
|
||||
|
|
@ -76,6 +77,9 @@ PUBLISHED:
|
|||
INLINE void set_handle_datagrams_internally(bool handle_datagrams_internally);
|
||||
INLINE bool get_handle_datagrams_internally() const;
|
||||
|
||||
void set_tcp_header_size(int tcp_header_size);
|
||||
INLINE int get_tcp_header_size() const;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
INLINE void set_python_repository(PyObject *python_repository);
|
||||
#endif
|
||||
|
|
@ -192,6 +196,7 @@ private:
|
|||
bool _handle_c_updates;
|
||||
bool _client_datagram;
|
||||
bool _handle_datagrams_internally;
|
||||
int _tcp_header_size;
|
||||
bool _simulated_disconnect;
|
||||
bool _verbose;
|
||||
bool _in_quiet_zone;
|
||||
|
|
|
|||
Loading…
Reference in New Issue