diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CopyJob.cc | 4 | ||||
-rw-r--r-- | lib/Handle.cc | 13 | ||||
-rw-r--r-- | lib/HttpServ.cc | 2 | ||||
-rw-r--r-- | lib/Makefile.am | 4 | ||||
-rw-r--r-- | lib/ReadJob.cc | 5 |
5 files changed, 18 insertions, 10 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc index 73864bb..04dff0b 100644 --- a/lib/CopyJob.cc +++ b/lib/CopyJob.cc @@ -16,7 +16,7 @@ int CopyJob::Do() { try { r = s->read(buffer, MIN(COPY_BUFSIZ, tr)); } - catch (IOAgain) { + catch (IOAgain e) { return TASK_WAITING_HANDLE; } current = 0; @@ -24,7 +24,7 @@ int CopyJob::Do() { try { d->write(buffer, r); } - catch (IOAgain) { + catch (IOAgain e) { current = 1; return TASK_WAITING_HANDLE; } 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 diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index 9ec6ba3..84078e0 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -26,6 +26,8 @@ void HttpServ::ProcessRequest(Action * p, Socket s) { Action * f; int len; + s.SetNonBlock(); + c->Run(); delete c; diff --git a/lib/Makefile.am b/lib/Makefile.am index 01cef95..fe512b6 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,7 +1,7 @@ localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ -AM_CFLAGS = -O3 -Wall -Wstrict-prototypes $(CFLAGS) -AM_CXXFLAGS = -O3 -Wall -Wstrict-prototypes $(CXXFLAGS) +AM_CFLAGS = -O3 -Wall -Wstrict-prototypes +AM_CXXFLAGS = -O3 -Wall -Wstrict-prototypes INCLUDES = -I. -I.. -I$(includedir) -I../include lib_LTLIBRARIES = libBaltisot.la diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc index 8de0108..8a4740a 100644 --- a/lib/ReadJob.cc +++ b/lib/ReadJob.cc @@ -14,9 +14,10 @@ int ReadJob::Do() { while (!s->IsClosed()) { if (!current) { try { + cerr << "Trying to read...\n"; *s >> buff; } - catch (IOAgain) { + catch (IOAgain e) { return TASK_WAITING_HANDLE; } current = 0; @@ -24,7 +25,7 @@ int ReadJob::Do() { try { *d << buff << endnl; } - catch (IOAgain) { + catch (IOAgain e) { current = 1; return TASK_WAITING_HANDLE; } |