Panda3D
config_downloader.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file config_downloader.cxx
10 * @author mike
11 * @date 2000-03-19
12 */
13
14#include "dconfig.h"
15#include "config_downloader.h"
16#include "httpChannel.h"
17#include "virtualFileHTTP.h"
19#include "pandaSystem.h"
20
21
22#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DOWNLOADER)
23 #error Buildsystem error: BUILDING_PANDA_DOWNLOADER not defined
24#endif
25
26ConfigureDef(config_downloader);
27NotifyCategoryDef(downloader, "");
28
29ConfigVariableInt downloader_byte_rate
30("downloader-byte-rate", 500000,
31 PRC_DESC("Specifies the default max bytes per second of throughput that is "
32 "supported by any HTTP connections with download-throttle enabled. "
33 "This may also be set on a per-channel basis with "
34 "HTTPChannel::set_max_bytes_per_second(). It has no effect unless "
35 "download-throttle (or HTTPChannel::set_download_throttle) is true."));
36
37ConfigVariableBool download_throttle
38("download-throttle", false,
39 PRC_DESC("When this is true, all HTTP channels will be bandwidth-limited "
40 "so as not to consume more than downloader-byte-rate bytes per "
41 "second."));
42
43ConfigVariableDouble downloader_frequency
44("downloader-frequency", 0.2,
45 PRC_DESC("Frequency of download chunk requests in seconds (or fractions of) "
46 "(Estimated 200 msec round-trip to server)."));
47
48ConfigVariableInt downloader_timeout
49("downloader-timeout", 15);
50
51ConfigVariableInt downloader_timeout_retries
52("downloader-timeout-retries", 5);
53
54ConfigVariableDouble decompressor_step_time
55("decompressor-step-time", 0.005,
56 PRC_DESC("Specifies the maximum amount of time that should be consumed by "
57 "a single call to Decompressor::run()."));
58
59ConfigVariableDouble extractor_step_time
60("extractor-step-time", 0.005,
61 PRC_DESC("Specifies the maximum amount of time that should be consumed by "
62 "a single call to Extractor::step()."));
63
64ConfigVariableInt patcher_buffer_size
65("patcher-buffer-size", 16384,
66 PRC_DESC("Limits the size of the buffer used in a single call to "
67 "Patcher::run(). Increasing this may help the Patcher "
68 "perform more work before returning."));
69
70ConfigVariableBool http_proxy_tunnel
71("http-proxy-tunnel", false,
72 PRC_DESC("This specifies the default value for HTTPChannel::set_proxy_tunnel(). "
73 "If this is true, we will tunnel through a proxy for all connections, "
74 "instead of asking the proxy to serve documents normally."));
75
76ConfigVariableDouble http_connect_timeout
77("http-connect-timeout", 10.0,
78 PRC_DESC("This is the default amount of time to wait for a TCP/IP connection "
79 "to be established, in seconds."));
80
81ConfigVariableDouble http_timeout
82("http-timeout", 20.0,
83 PRC_DESC("This is the default amount of time to wait for the HTTP server (or "
84 "proxy) to finish sending its response to our request, in seconds. "
85 "It starts counting after the TCP connection has been established "
86 "(http_connect_timeout, above) and the request has been sent."));
87
88ConfigVariableInt http_skip_body_size
89("http-skip-body-size", 8192,
90 PRC_DESC("This is the maximum number of bytes in a received "
91 "(but unwanted) body that will be skipped past, in "
92 "order to reset to a new request. "
93 "See HTTPChannel::set_skip_body_size()."));
94
95ConfigVariableDouble http_idle_timeout
96("http-idle-timeout", 5.0,
97 PRC_DESC("This the amount of time, in seconds, in which a "
98 "previously-established connection is allowed to remain open "
99 "and unused. If a previous connection has remained unused for "
100 "at least this number of seconds, it will be closed and a new "
101 "connection will be opened; otherwise, the same connection "
102 "will be reused for the next request (for a particular "
103 "HTTPChannel)."));
104
105ConfigVariableInt http_max_connect_count
106("http-max-connect-count", 10,
107 PRC_DESC("This is the maximum number of times to try reconnecting to the "
108 "server on any one document attempt. This is just a failsafe to "
109 "prevent the code from attempting runaway connections; this limit "
110 "should never be reached in practice."));
111
112ConfigVariableInt tcp_header_size
113("tcp-header-size", 2,
114 PRC_DESC("Specifies the number of bytes to use to specify the datagram "
115 "length when writing a datagram on a TCP stream. This may be "
116 "0, 2, or 4. The server and client must agree on this value."));
117
118ConfigVariableBool support_ipv6
119("support-ipv6", true,
120 PRC_DESC("Specifies whether IPv6 support should be enabled. This should "
121 "be true unless you are experiencing issues with Panda's IPv6 "
122 "support or are using a misconfigured system."));
123
124ConfigureFn(config_downloader) {
126}
127
128/**
129 * Initializes the library. This must be called at least once before any of
130 * the functions or classes in this library can be used. Normally it will be
131 * called by the static initializers and need not be called explicitly, but
132 * special cases exist.
133 */
134void
136 static bool initialized = false;
137 if (initialized) {
138 return;
139 }
140 initialized = true;
141
142#ifdef HAVE_OPENSSL
143 HTTPChannel::init_type();
144 VirtualFileHTTP::init_type();
145 VirtualFileMountHTTP::init_type();
146
147 VirtualFileMountHTTP::reload_vfs_mount_url();
148
149 // We need to define this here, rather than above, to guarantee that it has
150 // been initialized by the time we check it.
151 ConfigVariableBool early_random_seed
152 ("early-random-seed", false,
153 PRC_DESC("Configure this true to compute the SSL random seed "
154 "early on in the application (specifically, when the libpandaexpress "
155 "library is loaded), or false to defer this until it is actually "
156 "needed (which will be the first time you open an https connection "
157 "or otherwise use encryption services). You can also call "
158 "HTTPClient::init_random_seed() to "
159 "do this when you are ready. The issue is that on Windows, "
160 "OpenSSL will attempt to "
161 "randomize its seed by crawling through the entire heap of "
162 "allocated memory, which can be extremely large in a Panda "
163 "application, especially if you have already opened a window and "
164 "started rendering; and so this can take as much as 30 seconds "
165 "or more. For this reason it is best to initialize the random "
166 "seed at startup, when the application is still very small."));
167 if (early_random_seed) {
168 HTTPClient::init_random_seed();
169 }
170
172 ps->add_system("OpenSSL");
173#endif // HAVE_OPENSSL
174}
This is a convenience class to specialize ConfigVariable as a boolean type.
This is a convenience class to specialize ConfigVariable as a floating- point type.
This is a convenience class to specialize ConfigVariable as an integer type.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:26
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
void add_system(const std::string &system)
Intended for use by each subsystem to register itself at startup.
void init_libdownloader()
Initializes the library.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.