]> git.saurik.com Git - apt-legacy.git/commitdiff
Added some better error checking to the new CFNetwork APT backend.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Feb 2008 11:25:49 +0000 (11:25 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Feb 2008 11:25:49 +0000 (11:25 +0000)
M cfnetwork.diff

git-svn-id: http://svn.telesphoreo.org/trunk@105 514c082c-b64e-11dc-b46d-3d985efe055d

methods/http.cc
methods/http.cc.orig

index 7e5bbc99b7c10da81a533627e021575ddfdbeee0..012d4506b021b0f9fd030426165cd2cb0de4ec8f 100644 (file)
@@ -1102,24 +1102,32 @@ int HttpMethod::Loop()
 
       URI uri = Queue->Uri;
 
+      FetchResult Res;
+
+      uint8_t data[10240];
+      size_t offset = 0;
+
       Status("Connecting to %s", uri.Host.c_str());
 
       if (!CFReadStreamOpen(rs)) {
+         _error->Error("Unable to open stream");
          Fail(true);
-         continue;
+         goto done;
       }
 
-      uint8_t data[10240];
       CFIndex rd = CFReadStreamRead(rs, data, sizeof(data));
 
-      FetchResult Res;
+      if (rd == -1) {
+         _error->Error("Stream read failure");
+         Fail(true);
+         goto done;
+      }
+
       Res.Filename = Queue->DestFile;
 
       hm = (CFHTTPMessageRef) CFReadStreamCopyProperty(rs, kCFStreamPropertyHTTPResponseHeader);
       UInt32 sc = CFHTTPMessageGetResponseStatusCode(hm);
 
-      size_t offset = 0;
-
       sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Content-Range"));
       if (sr != NULL) {
          size_t ln = CFStringGetLength(sr) + 1;
@@ -1215,9 +1223,10 @@ int HttpMethod::Loop()
 
         URIStart(Res);
 
-         read: if (rd == -1)
+         read: if (rd == -1) {
+            _error->Error("Stream read failure");
             Fail(true);
-         else if (rd == 0) {
+         else if (rd == 0) {
            if (Res.Size == 0)
               Res.Size = File->Size();
 
index 4043eb1064be41e5e1a133bd2fc872a261c1d299..b53b5dabe818221fe8860e739ac6c5936b23f82e 100644 (file)
@@ -1098,24 +1098,32 @@ int HttpMethod::Loop()
 
       URI uri = Queue->Uri;
 
+      FetchResult Res;
+
+      uint8_t data[10240];
+      size_t offset = 0;
+
       Status("Connecting to %s", uri.Host.c_str());
 
       if (!CFReadStreamOpen(rs)) {
+         _error->Error("Unable to open stream");
          Fail(true);
-         continue;
+         goto done;
       }
 
-      uint8_t data[10240];
       CFIndex rd = CFReadStreamRead(rs, data, sizeof(data));
 
-      FetchResult Res;
+      if (rd == -1) {
+         _error->Error("Stream read failure");
+         Fail(true);
+         goto done;
+      }
+
       Res.Filename = Queue->DestFile;
 
       hm = (CFHTTPMessageRef) CFReadStreamCopyProperty(rs, kCFStreamPropertyHTTPResponseHeader);
       UInt32 sc = CFHTTPMessageGetResponseStatusCode(hm);
 
-      size_t offset = 0;
-
       sr = CFHTTPMessageCopyHeaderFieldValue(hm, CFSTR("Content-Range"));
       if (sr != NULL) {
          size_t ln = CFStringGetLength(sr) + 1;
@@ -1211,9 +1219,10 @@ int HttpMethod::Loop()
 
         URIStart(Res);
 
-         read: if (rd == -1)
+         read: if (rd == -1) {
+            _error->Error("Stream read failure");
             Fail(true);
-         else if (rd == 0) {
+         else if (rd == 0) {
            if (Res.Size == 0)
               Res.Size = File->Size();