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