]> git.saurik.com Git - apt.git/blobdiff - methods/http.cc
Added subprocess to segfault error
[apt.git] / methods / http.cc
index 34f2f1af5bebd432cf14c2e9ba4fdad11937582c..7a9a97a1dc2545c430b0f6e7783ca7f633a1cd2e 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: http.cc,v 1.39 1999/10/18 03:18:40 jgg Exp $
+// $Id: http.cc,v 1.43 1999/12/10 23:40:29 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -635,7 +635,7 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
    if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
    {
       // In this case we send an if-range query with a range header
-      sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",SBuf.st_size - 1,
+      sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf.st_size - 1,
              TimeRFC1123(SBuf.st_mtime).c_str());
       Req += Buf;
    }
@@ -671,10 +671,9 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
                               ToFile == false))
       return false;
    
-   fd_set rfds,wfds,efds;
+   fd_set rfds,wfds;
    FD_ZERO(&rfds);
    FD_ZERO(&wfds);
-   FD_ZERO(&efds);
    
    // Add the server
    if (Srv->Out.WriteSpace() == true && Srv->ServerFd != -1) 
@@ -693,12 +692,6 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
    // Add stdin
    FD_SET(STDIN_FILENO,&rfds);
          
-   // Error Set
-   if (FileFD != -1)
-      FD_SET(FileFD,&efds);
-   if (Srv->ServerFd != -1)
-      FD_SET(Srv->ServerFd,&efds);
-
    // Figure out the max fd
    int MaxFd = FileFD;
    if (MaxFd < Srv->ServerFd)
@@ -709,7 +702,7 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
    tv.tv_sec = TimeOut;
    tv.tv_usec = 0;
    int Res = 0;
-   if ((Res = select(MaxFd+1,&rfds,&wfds,&efds,&tv)) < 0)
+   if ((Res = select(MaxFd+1,&rfds,&wfds,0,&tv)) < 0)
       return _error->Errno("select","Select failed");
    
    if (Res == 0)
@@ -718,11 +711,6 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
       return ServerDie(Srv);
    }
    
-   // Some kind of exception (error) on the sockets, die
-   if ((FileFD != -1 && FD_ISSET(FileFD,&efds)) || 
-       (Srv->ServerFd != -1 && FD_ISSET(Srv->ServerFd,&efds)))
-      return _error->Error("Socket Exception");
-
    // Handle server IO
    if (Srv->ServerFd != -1 && FD_ISSET(Srv->ServerFd,&rfds))
    {
@@ -910,7 +898,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
 void HttpMethod::SigTerm(int)
 {
    if (FailFd == -1)
-      exit(100);
+      _exit(100);
    close(FailFd);
    
    // Timestamp
@@ -919,7 +907,7 @@ void HttpMethod::SigTerm(int)
    UBuf.modtime = FailTime;
    utime(FailFile.c_str(),&UBuf);
    
-   exit(100);
+   _exit(100);
 }
                                                                        /*}}}*/
 // HttpMethod::Fetch - Fetch an item                                   /*{{{*/
@@ -934,8 +922,13 @@ bool HttpMethod::Fetch(FetchItem *)
    // Queue the requests
    int Depth = -1;
    bool Tail = false;
-   for (FetchItem *I = Queue; I != 0 && Depth < (signed)PipelineDepth; I = I->Next, Depth++)
+   for (FetchItem *I = Queue; I != 0 && Depth < (signed)PipelineDepth; 
+       I = I->Next, Depth++)
    {
+      // If pipelining is disabled, we only queue 1 request
+      if (Server->Pipeline == false && Depth >= 0)
+        break;
+      
       // Make sure we stick with the same server
       if (Server->Comp(I->Uri) == false)
         break;
@@ -946,7 +939,7 @@ bool HttpMethod::Fetch(FetchItem *)
         QueueBack = I->Next;
         SendReq(I,Server->Out);
         continue;
-      }         
+      }
    }
    
    return true;
@@ -1041,7 +1034,8 @@ int HttpMethod::Loop()
            FailCounter++;
            _error->Discard();
            Server->Close();
-
+           Server->Pipeline = false;
+           
            if (FailCounter >= 2)
            {
               Fail("Connection failed",true);