mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
*** empty log message ***
This commit is contained in:
parent
b0ecbec7ed
commit
a3c5838dea
@ -606,7 +606,7 @@ parse_record_header(uchar *start, int size) {
|
||||
|
||||
DatagramIterator di(_datagram);
|
||||
PN_int32 record_length = di.get_int32();
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "Parsed record header length: " << record_length << endl;
|
||||
|
||||
// If we got all the way here, must be done
|
||||
@ -666,7 +666,7 @@ parse_fr(uchar *start, int size) {
|
||||
fr->_name = di.extract_bytes(fr_name_length);
|
||||
fr->_version = di.get_int32();
|
||||
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "Parsed file record: " << fr->_name
|
||||
<< " version: " << fr->_version
|
||||
<< " hash: " << fr->_hash
|
||||
@ -1017,7 +1017,7 @@ write_version_map(ofstream &write_stream) {
|
||||
_master_datagram.add_int32(_versions.size());
|
||||
for (vmi = _versions.begin(); vmi != _versions.end(); ++vmi) {
|
||||
string name = (*vmi).first;
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "DownloadDb::write_version_map() - writing file: "
|
||||
<< name << " of length: " << name.length() << endl;
|
||||
_master_datagram.add_int32(name.length());
|
||||
@ -1059,7 +1059,7 @@ read_version_map(ifstream &read_stream) {
|
||||
_master_datagram.append_data(buffer, sizeof(PN_int32));
|
||||
DatagramIterator di2(_master_datagram);
|
||||
int name_length = di2.get_int32();
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "DownloadDb::read_version_map() - name length: " << name_length
|
||||
<< endl;
|
||||
|
||||
@ -1070,7 +1070,7 @@ read_version_map(ifstream &read_stream) {
|
||||
_master_datagram.append_data(namebuffer, name_length);
|
||||
DatagramIterator di4(_master_datagram);
|
||||
string name = di4.extract_bytes(name_length);
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "DownloadDb::read_version_map() - name: " << name << endl;
|
||||
|
||||
// Get number of hash values for name
|
||||
@ -1079,7 +1079,7 @@ read_version_map(ifstream &read_stream) {
|
||||
_master_datagram.append_data(buffer, sizeof(PN_int32));
|
||||
DatagramIterator di5(_master_datagram);
|
||||
int length = di5.get_int32();
|
||||
downloader_cat.debug()
|
||||
downloader_cat.spam()
|
||||
<< "DownloadDb::read_version_map() - number of values: " << length
|
||||
<< endl;
|
||||
|
||||
|
@ -540,6 +540,7 @@ download(const string &file_name, Filename file_dest,
|
||||
DownloadStatus status(_buffer->_buffer, event_name, first_byte, last_byte,
|
||||
total_bytes, partial_content, id);
|
||||
bool got_any_data = false;
|
||||
bool timeout_updated_bytes_in_buffer = false;
|
||||
|
||||
for (;;) {
|
||||
if (_download_enabled) {
|
||||
@ -573,13 +574,51 @@ download(const string &file_name, Filename file_dest,
|
||||
// Handle receive timeouts by trying again
|
||||
if (ans == RS_timeout) {
|
||||
int extra_bytes = 0;
|
||||
|
||||
if (bytes > 0) {
|
||||
status._bytes_in_buffer += bytes;
|
||||
status._next_in += bytes;
|
||||
got_any_data = true;
|
||||
timeout_updated_bytes_in_buffer = true;
|
||||
}
|
||||
|
||||
// Ensure we have enough room in the buffer to download read_size
|
||||
// If we don't have enough room, write the buffer to disk
|
||||
if (status._bytes_in_buffer + read_size > _buffer_size) {
|
||||
if (downloader_cat.is_debug())
|
||||
downloader_cat.debug()
|
||||
<< "Downloader::download() - Flushing buffer" << endl;
|
||||
if (write_to_disk(status) == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int r = 0; r < downloader_timeout_retries; r++) {
|
||||
extra_bytes = 0;
|
||||
|
||||
// Ensure we have enough room in the buffer to download read_size
|
||||
// If we don't have enough room, write the buffer to disk
|
||||
if (status._bytes_in_buffer + read_size > _buffer_size) {
|
||||
if (downloader_cat.is_debug())
|
||||
downloader_cat.debug()
|
||||
<< "Downloader::download() - Flushing buffer" << endl;
|
||||
if (write_to_disk(status) == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
ans = safe_receive(_socket, status._next_in, read_size,
|
||||
(long)downloader_timeout, extra_bytes);
|
||||
|
||||
if (extra_bytes > 0) {
|
||||
bytes += extra_bytes;
|
||||
status._bytes_in_buffer += bytes;
|
||||
status._next_in += bytes;
|
||||
got_any_data = true;
|
||||
timeout_updated_bytes_in_buffer = true;
|
||||
}
|
||||
|
||||
if (ans != RS_timeout)
|
||||
break;
|
||||
}
|
||||
bytes += extra_bytes;
|
||||
|
||||
if (ans == RS_timeout) {
|
||||
// We've really timed out - throw an event
|
||||
@ -641,9 +680,17 @@ download(const string &file_name, Filename file_dest,
|
||||
if (downloader_cat.is_debug())
|
||||
downloader_cat.debug()
|
||||
<< "Downloader::download() - Got: " << bytes << " bytes" << endl;
|
||||
|
||||
// If the timeout read data and already updated these variables
|
||||
// we do not want to update them again
|
||||
if (timeout_updated_bytes_in_buffer == true) {
|
||||
// reset this variable and do not update the byte count
|
||||
timeout_updated_bytes_in_buffer = false;
|
||||
} else {
|
||||
status._bytes_in_buffer += bytes;
|
||||
status._next_in += bytes;
|
||||
got_any_data = true;
|
||||
}
|
||||
|
||||
// Sleep for the requested frequency
|
||||
nap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user