From e72624ab203439ffea88cd55c145cdbbc57286e4 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 15 Nov 2011 17:00:03 -0800 Subject: Adding a potential event to cancel a forced read/write, such as a timeout. --- src/Handle.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Handle.cc') diff --git a/src/Handle.cc b/src/Handle.cc index 8fa0417..839c58a 100644 --- a/src/Handle.cc +++ b/src/Handle.cc @@ -83,7 +83,7 @@ ssize_t Balau::Handle::write(const void * buf, size_t count) throw (GeneralExcep return -1; } -ssize_t Balau::Handle::forceRead(void * _buf, size_t count) throw (GeneralException) { +ssize_t Balau::Handle::forceRead(void * _buf, size_t count, Events::BaseEvent * evt) throw (GeneralException) { ssize_t total; uint8_t * buf = (uint8_t *) _buf; if (!canRead()) @@ -95,6 +95,8 @@ ssize_t Balau::Handle::forceRead(void * _buf, size_t count) throw (GeneralExcept r = read(buf, count); } catch (EAgain e) { + if (evt && evt->gotSignal()) + return total; Task::yield(e.getEvent()); continue; } @@ -108,7 +110,7 @@ ssize_t Balau::Handle::forceRead(void * _buf, size_t count) throw (GeneralExcept return total; } -ssize_t Balau::Handle::forceWrite(const void * _buf, size_t count) throw (GeneralException) { +ssize_t Balau::Handle::forceWrite(const void * _buf, size_t count, Events::BaseEvent * evt) throw (GeneralException) { ssize_t total; const uint8_t * buf = (const uint8_t *) _buf; if (!canWrite()) @@ -120,6 +122,8 @@ ssize_t Balau::Handle::forceWrite(const void * _buf, size_t count) throw (Genera r = write(buf, count); } catch (EAgain e) { + if (evt && evt->gotSignal()) + return total; Task::yield(e.getEvent()); continue; } -- cgit v1.2.3