// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-worker.cc,v 1.5 1998/10/23 00:49:58 jgg Exp $
+// $Id: acquire-worker.cc,v 1.10 1998/11/05 07:21:39 jgg Exp $
/* ######################################################################
Acquire Worker
close(Pipes[I]);
return false;
}
-
+ for (int I = 0; I != 4; I++)
+ SetCloseExec(Pipes[0],true);
+
// Fork off the process
Process = fork();
if (Process < 0)
dup2(Pipes[1],STDOUT_FILENO);
dup2(Pipes[2],STDIN_FILENO);
dup2(((filebuf *)clog.rdbuf())->fd(),STDERR_FILENO);
- for (int I = 0; I != 4; I++)
- close(Pipes[I]);
SetCloseExec(STDOUT_FILENO,false);
SetCloseExec(STDIN_FILENO,false);
SetCloseExec(STDERR_FILENO,false);
return _error->Error("Method %s did not start correctly",Method.c_str());
RunMessages();
- SendConfiguration();
+ if (OwnerQ != 0)
+ SendConfiguration();
return true;
}
if (End == Message.c_str())
return _error->Error("Invalid message from method %s: %s",Access.c_str(),Message.c_str());
+ string URI = LookupTag(Message,"URI");
+ pkgAcquire::Queue::QItem *Itm = 0;
+ if (URI.empty() == false)
+ Itm = OwnerQ->FindItem(URI,this);
+
// Determine the message number and dispatch
switch (Number)
{
// 200 URI Start
case 200:
- break;
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 200 URI Start message");
+ break;
+ }
+ CurrentItem = Itm;
+ CurrentSize = 0;
+ TotalSize = atoi(LookupTag(Message,"Size","0").c_str());
+
+ break;
+ }
// 201 URI Done
case 201:
- break;
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 201 URI Done message");
+ break;
+ }
+
+ pkgAcquire::Item *Owner = Itm->Owner;
+ OwnerQ->ItemDone(Itm);
+ Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
+ LookupTag(Message,"MD5-Hash"));
+ break;
+ }
// 400 URI Failure
case 400:
- break;
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 400 URI Failure message");
+ break;
+ }
+
+ pkgAcquire::Item *Owner = Itm->Owner;
+ OwnerQ->ItemDone(Itm);
+ Owner->Failed(Message);
+ break;
+ }
// 401 General Failure
case 401: