Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-02-11 15:00:54


Author: drrngrvy
Date: 2008-02-11 15:00:54 EST (Mon, 11 Feb 2008)
New Revision: 43225
URL: http://svn.boost.org/trac/boost/changeset/43225

Log:
Cleaned up return_ macro.
Text files modified:
   sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp | 37 ++++++++++++++++++++-----------------
   1 files changed, 20 insertions(+), 17 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/boost/cgi/return.hpp 2008-02-11 15:00:54 EST (Mon, 11 Feb 2008)
@@ -16,34 +16,37 @@
  namespace common {
 
    template<typename Response, typename Request>
- int return_helper(Response& resp, Request& req, int program_status)
+ boost::system::error_code
+ return_helper(Response& resp, Request& req, int program_status)
    {
      boost::system::error_code ec;
- resp.send(req, ec);
+ resp.send(req.client(), ec);
      if (ec) return ec;
 
      req.close(resp.status(), program_status);
 
- return program_status;
+ return ec;
    }
 
- template<typename R1, typename R2>
- void send_helper(R1& resp, R2& req)
- {
- resp.send(req.client());
- }
+ } // namespace common
+} // namespace cgi
 
- void close_helper(response& resp, boost::fcgi::request& req, int prog_status)
- {
- req.close(resp.status(), prog_status);
- }
+/// If an error occurs during the sending or closing then `status` will be
+// incremented by the value of this macro.
+#ifndef BOOST_CGI_RETURN_ERROR_INCREMENT
+# define BOOST_CGI_RETURN_ERROR_INCREMENT 100
+#endif
+
+#define BOOST_CGI_RETURN(resp, req, status) \
+ if ( ::cgi::common::return_helper(resp, req, status)) \
+ /** error **/ \
+ return status + BOOST_CGI_RETURN_ERROR_INCREMENT; \
+ return status;
 
-#define return_(RESP, REQ, STATUS) \
- send_helper(RESP, REQ); \
- ::cgi::common::close_helper(RESP, REQ, STATUS); \
- return STATUS;
+namespace cgi {
+ namespace common {
 
-//return return_helper(resp, req, status)
+#define return_(resp, req, status) BOOST_CGI_RETURN(resp, req, status)
 
  } // namespace common
 } // namespace cgi


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk