error checking :)

This commit is contained in:
Bill Currie 2007-03-24 14:20:20 +00:00 committed by Jeff Teunissen
parent a4f9363566
commit 12535ec1f9
2 changed files with 33 additions and 4 deletions

View file

@ -101,10 +101,24 @@ void
CL_HTTP_Update (void)
{
int running_handles;
int messages_in_queue;
CURLMsg *msg;
curl_multi_perform (multi_handle, &running_handles);
if (!running_handles) {
curl_multi_remove_handle (multi_handle, easy_handle);
CL_FinishDownload ();
while ((msg = curl_multi_info_read (multi_handle, &messages_in_queue))) {
if (msg->msg == CURLMSG_DONE) {
long response_code;
curl_easy_getinfo (msg->easy_handle, CURLINFO_RESPONSE_CODE,
&response_code);
if (response_code == 200) {
CL_FinishDownload ();
} else {
Con_Printf ("download failed: %ld\n", response_code);
CL_FailDownload ();
}
curl_multi_remove_handle (multi_handle, easy_handle);
}
}
}

View file

@ -456,6 +456,19 @@ CL_FinishDownload (void)
CL_RequestNextDownload ();
}
void
CL_FailDownload (void)
{
if (cls.download) {
Qclose (cls.download);
cls.download = NULL;
}
dstring_clearstr (cls.downloadname);
dstring_clearstr (cls.downloadtempname);
dstring_clearstr (cls.downloadurl);
CL_RequestNextDownload ();
}
static int
CL_OpenDownload (void)
{
@ -505,11 +518,12 @@ CL_ParseDownload (void)
// read the data
size = MSG_ReadShort (net_message);
percent = MSG_ReadByte (net_message);
Con_Printf ("%d %d\n", size, percent);
if (cls.demoplayback) {
if (size > 0)
net_message->readcount += size;
dstring_clearstr (cls.downloadname);
dstring_clearstr (cls.downloadtempname);
dstring_clearstr (cls.downloadurl);
return; // not in demo playback
}
@ -522,6 +536,7 @@ Con_Printf ("%d %d\n", size, percent);
cls.download = NULL;
}
dstring_clearstr (cls.downloadname);
dstring_clearstr (cls.downloadtempname);
dstring_clearstr (cls.downloadurl);
CL_RequestNextDownload ();
return;