summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:52:53 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:52:53 +0000
commit1084d58ae9a56d7d4c8a274112128f56302a3edc (patch)
tree6cc50b6b025f3dab1392e1fbfcdf1acf3b47f69f /apt-pkg
parentfc9d4b7b18e1c3c9fbcdf6766d21180c0db88b24 (diff)
Fixed WaitFD
Author: jgg Date: 1999-02-16 04:18:35 GMT Fixed WaitFD
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc16
-rw-r--r--apt-pkg/contrib/fileutl.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 5b7c76496..b6a64926d 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.20 1999/02/12 20:47:41 doogie Exp $
+// $Id: fileutl.cc,v 1.21 1999/02/16 04:18:35 jgg Exp $
/* ######################################################################
File Utilities
@@ -165,7 +165,7 @@ void SetNonBlock(int Fd,bool Block)
// ---------------------------------------------------------------------
/* This waits for a FD to become readable using select. It is usefull for
applications making use of non-blocking sockets. */
-bool WaitFd(int Fd, bool write = false, long timeout = 0)
+bool WaitFd(int Fd,bool write,unsigned long timeout)
{
fd_set Set;
struct timeval tv;
@@ -173,13 +173,17 @@ bool WaitFd(int Fd, bool write = false, long timeout = 0)
FD_SET(Fd,&Set);
tv.tv_sec = timeout / 1000000;
tv.tv_usec = timeout % 1000000;
- if(write) {
- if (select(Fd+1,&Set,0,0,&tv) <= 0)
+ if (write == true)
+ {
+ if (select(Fd+1,0,&Set,0,(timeout != 0?&tv:0)) <= 0)
return false;
- } else {
- if (select(Fd+1,0,&Set,0,&tv) <= 0)
+ }
+ else
+ {
+ if (select(Fd+1,&Set,0,0,(timeout != 0?&tv:0)) <= 0)
return false;
}
+
return true;
}
/*}}}*/
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index faec10c2d..7bb3fc446 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.h,v 1.13 1999/02/12 20:47:41 doogie Exp $
+// $Id: fileutl.h,v 1.14 1999/02/16 04:18:35 jgg Exp $
/* ######################################################################
File Utilities
@@ -66,7 +66,7 @@ bool FileExists(string File);
string SafeGetCWD();
void SetCloseExec(int Fd,bool Close);
void SetNonBlock(int Fd,bool Block);
-bool WaitFd(int Fd, bool write = false, long timeout = 0);
+bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0);
// File string manipulators
string flNotDir(string File);