diff options
Diffstat (limited to 'lib/Handle.cc')
-rw-r--r-- | lib/Handle.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Handle.cc b/lib/Handle.cc index 8ef2408..c1fbc8c 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -20,7 +20,7 @@ int Handle::GetHandle() { return h; } -ssize_t Handle::write(const void *buf, size_t count) throw (IOException) { +ssize_t Handle::write(const void *buf, size_t count) throw (IOGeneral) { ssize_t r, tr = 0; bool done, full = false; @@ -58,16 +58,19 @@ ssize_t Handle::write(const void *buf, size_t count) throw (IOException) { return r + tr; } -ssize_t Handle::read(void *buf, size_t count) throw (IOException) { +ssize_t Handle::read(void *buf, size_t count) throw (IOGeneral) { ssize_t r; errno = 0; if ((r = ::read(h, buf, count)) < 0) { + cerr << "read: throwing exception...\n"; if ((!errno) || (errno = EAGAIN)) { // Avant de déclarer une erreur, on vérifie si ce n'est pas un // problème lié au fait qu'il n'y a plus d'octets. + cerr << "Throwing a 'again' exception.\n"; throw IOAgain(); } else { + cerr << "Throwing an unknow exception.\n"; throw IOException(GetName(), IO_READ, count); } } @@ -89,10 +92,10 @@ bool Handle::IsNonBlock(void) { } void Handle::SetNonBlock(void) { - nonblock = true; - if (h >= 0) { + if ((h >= 0) || !nonblock) { fcntl(h, F_SETFL, O_NONBLOCK); } + nonblock = true; } Handle & operator<<(Handle & h, const String & s) { @@ -108,6 +111,8 @@ Handle & operator>>(Handle & h, String & s) { char t[BUFSIZ]; int i = 0, r; + cerr << "Into 'Handle & >> String &'...\n"; + while ((r = h.read(&(t[i]), 1)) && (i != (BUFSIZ - 1))) { // Il y a souvent des \r\n dans les sockets par exemple, // ou bien en lisant des fichiers au format MS-DOS. On |