From 3ab2bfeed4ef1c2fd49ef05f5525580c3d8f32d6 Mon Sep 17 00:00:00 2001 From: Ronald Landheer-Cieslak Date: Thu, 25 Jun 2009 11:52:26 -0400 Subject: [PATCH] Add setReadTimeout --- lib/Spin/Connection.cpp | 12 ++++++++++++ lib/Spin/Connection.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/lib/Spin/Connection.cpp b/lib/Spin/Connection.cpp index ec23cfa..03fda64 100644 --- a/lib/Spin/Connection.cpp +++ b/lib/Spin/Connection.cpp @@ -223,6 +223,18 @@ read_entry_point: return Details::Address(peer_addr.sin_addr.s_addr); } + void Connection::setReadTimeout(unsigned int seconds) + { + AGELENA_DEBUG_2("void Connection(%1%)::setReadTimeout(unsigned int %2%)", this, seconds); + boost::recursive_mutex::scoped_lock sentinel(bio_lock_); + if (!bio_) + throw Exceptions::Connection::UnusableConnection(); + else + { /* all is well */ } + int socket_fd(fd_); + ::setsockopt(fd_, SOL_SOCKET, SO_RCVTIMEO, (const char *)&seconds, sizeof(unsigned int)); + } + Connection::Connection(Scorpion::BIO * bio) : bio_(bio), data_handler_(0), diff --git a/lib/Spin/Connection.h b/lib/Spin/Connection.h index 30a7c3b..1b4b3db 100644 --- a/lib/Spin/Connection.h +++ b/lib/Spin/Connection.h @@ -133,6 +133,9 @@ namespace Spin //! Get the peer's address Details::Address getPeerAddress() const; + //! Set the number of seconds the implementation should wait for a read + void setReadTimeout(unsigned int seconds); + bool usable() const { return bio_; } private : -- 2.11.4.GIT