Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2007-10-17 19:30:03


Author: drrngrvy
Date: 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
New Revision: 40141
URL: http://svn.boost.org/trac/boost/changeset/40141

Log:
Merged revisions 40126-40140 via svnmerge from
https://svn.boost.org/svn/boost/sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct@40125

........
  r40127 | drrngrvy | 2007-10-17 16:50:49 +0100 (Wed, 17 Oct 2007) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-39044" from
  https://svn.boost.org/svn/boost/sandbox/SOC/2007/cgi
........
  r40132 | drrngrvy | 2007-10-17 20:00:41 +0100 (Wed, 17 Oct 2007) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "19" from
  https://cgi.svn.sourceforge.net/svnroot/cgi/cgi/branches/scgi_acceptor
........
  r40133 | drrngrvy | 2007-10-17 20:51:02 +0100 (Wed, 17 Oct 2007) | 1 line
  
  [merging from SF] Adding website. It's basic and it does the job, just. Also did some work on the SCGI acceptor.
........
  r40134 | drrngrvy | 2007-10-17 21:10:39 +0100 (Wed, 17 Oct 2007) | 3 lines
  
  Added a basic_client class, that is a level between a request and the connection associated with it, which controls the input and output formatting and scheduling. For instance, in the case of FastCGI - at least as is planned at the time of writing - it is the client which is responsible for wrapping a buffer in the protocol-specific way; it must also ensure that a client holds a connection until it has sent each packet fully. In other words, so a shared connection doesn't steal the connection between a couple of read/write_some`s and break the output (which would essentially compromise safety quite significantly - if output from different sessions is interleaved).
  
  Also added a shareable_tcp_socket which has a boost::mutex and boost::condition to simplify mutiplexing.
........
  r40135 | drrngrvy | 2007-10-17 21:42:43 +0100 (Wed, 17 Oct 2007) | 4 lines
  
  [merging from SF]
  * Fixing fcgi/client.hpp and scgi/client.hpp.
  
  * Test (plus adding blank scgi_init.hpp file)
........
  r40136 | drrngrvy | 2007-10-17 21:55:42 +0100 (Wed, 17 Oct 2007) | 3 lines
  
  Removed merge tracking for "svnmerge" for
  https://cgi.svn.sourceforge.net/svnroot/cgi/cgi/branches/scgi_acceptor
........

Added:
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_client.hpp
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/boost/cgi/basic_client.hpp
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/connections/shareable_tcp_socket.hpp
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/boost/cgi/connections/shareable_tcp_socket.hpp
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/detail/scgi_init.hpp
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/boost/cgi/detail/scgi_init.hpp
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/client.hpp
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/boost/cgi/scgi/client.hpp
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/scgi.hpp
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/boost/cgi/scgi/scgi.hpp
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/
      - copied from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/LICENSE_1_0.txt
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/LICENSE_1_0.txt
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/about.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/about.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/bugs.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/bugs.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/cgi.css
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/cgi.css
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/contact.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/contact.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/credits.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/credits.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/downloads.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/downloads.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/html/
      - copied from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/html/
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/html/index.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/html/index.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/index.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/index.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/license.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/license.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/release_notes.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/release_notes.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/source.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/source.html
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/website/status.html
      - copied unchanged from r40136, /sandbox/SOC/2007/cgi/branches/merge_from_SF_17_oct/libs/cgi/website/status.html
Properties modified:
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/ (props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/acgi/request_service.hpp | 2
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_protocol_service.hpp | 6
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_request_acceptor.hpp | 67 +++++++++++
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/cgi/cgi_service.hpp | 12 +-
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/connections/tcp_socket.hpp | 23 +--
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/header.hpp | 9 +
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/io_service_provider.hpp | 2
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/acceptor_service_impl.hpp | 170 ++++++++++++++++++++++++++++++
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request.hpp | 8 +
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_acceptor_service.hpp | 56 +++++----
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_impl.hpp | 14 +-
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_service.hpp | 17 +-
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service.hpp | 12 +
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service_impl.hpp | 221 ++-------------------------------------
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/tags.hpp | 2
   sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/doc/src/preface.qbk | 2
   16 files changed, 343 insertions(+), 280 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/acgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/acgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/acgi/request_service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -46,7 +46,7 @@
     }
     void construct(implementation_type& impl)
     {
- impl.connection() = async_stdio_connection::create(io_service());
+ impl.connection() = async_stdio_connection::create(this->io_service());
     }
 
     void destroy(implementation_type& impl)

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_protocol_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_protocol_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_protocol_service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -131,13 +131,11 @@
     /// A strand is used for guaranteeing handlers are dispatched sequentially
     //boost::asio::strand strand_;
 
+ /// A std::set of all the requests
     set_type request_set_;
+ /// A std::queue of the pending requests
     queue_type request_queue_;
 
- //gateway_type gateway_;
-
- //friend class basic_gateway<protocol_type>;//gateway_type;
- //friend class basic_acceptor<protocol_type>;//class acceptor_type;
 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
     friend typename traits::request_type;//typename request_type;
 #else

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_request_acceptor.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_request_acceptor.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/basic_request_acceptor.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -13,10 +13,11 @@
 #include <boost/system/error_code.hpp>
 
 #include <boost/asio/basic_io_object.hpp>
-#include "detail/throw_error.hpp"
+#include "boost/detail/throw_error.hpp"
 
 namespace cgi {
 
+ /// The interface class for any *cgi::acceptor.
   template<typename RequestAcceptorService>
   class basic_request_acceptor
     : private boost::noncopyable
@@ -26,16 +27,71 @@
     // typedef impl_type;
     typedef RequestAcceptorService service_type;
     typedef service_type::protocol_type protocol_type;
+ typedef int port_number_type;
 
- explicit basic_request_acceptor(basic_protocol_service<protocol_type>& s)
- : boost::asio::basic_io_object<RequestAcceptorService>(s.io_service())
+ explicit basic_request_acceptor(basic_protocol_service<protocol_type>& ps)
+ : boost::asio::basic_io_object<RequestAcceptorService>(ps.io_service())
     {
+ this->service.set_protocol_service(this->implementation, s);
+ }
+
+ explicit basic_request_acceptor(basic_protocol_service<protocol_type>& ps
+ , port_number_type port_num)
+ : boost::asio::basic_io_object<RequestAcceptorService>(ps.io_service())
+ {
+ this->service.set_protocol_service(this->implementation, ps);
     }
 
     ~basic_request_acceptor()
     {
     }
 
+ /// Check if the acceptor is open
+ bool is_open()
+ {
+ return this->service.is_open(this->implementation);
+ }
+
+ /// Open the acceptor
+ template<typename Protocol>
+ void open(Protocol& protocol)
+ {
+ boost::system::error_code ec;
+ this->service.open(this->implementation, protocol, ec);
+ detail::throw_error(ec);
+ }
+
+ /// Open the acceptor
+ template<typename Protocol>
+ boost::system::error_code
+ open(Protocol& protocol, boost::system::error_code& ec)
+ {
+ return this->service.open(this->implementation, protocol, ec);
+ }
+
+ /// Cancel all asynchronous operations associated with the acceptor.
+ boost::system::error_code
+ cancel()
+ {
+ return this->service.cancel(this->implementation);
+ }
+
+ /// Close the acceptor
+ void close()
+ {
+ boost::system::error_code ec;
+ this->service.close(this->implementation, ec);
+ detail::throw_error(ec);
+ }
+
+ /// Close the acceptor
+ boost::system::error_code
+ close(boost::system::error_code& ec)
+ {
+ return this->service.close(this->implementation, ec);
+ }
+
+ /// Accept one request
     template<typename CommonGatewayRequest>
     void accept(CommonGatewayRequest& request)
     {
@@ -44,12 +100,15 @@
       detail::throw_error(ec);
     }
 
- template<typename CommonGatewayRequest> boost::system::error_code&
+ /// Accept one request
+ template<typename CommonGatewayRequest>
+ boost::system::error_code&
     accept(CommonGatewayRequest& request, boost::system::error_code& ec)
     {
       return this->service.accept(this->implementation, request, ec);
     }
 
+ /// Asynchronously accept one request
     template<typename CommonGatewayRequest, typename Handler>
     void async_accept(CommonGatewayRequest& request, Handler handler)
     {

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/cgi/cgi_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/cgi/cgi_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/cgi/cgi_service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -9,12 +9,12 @@
 #ifndef CGI_CGI_SERVICE_HPP_INCLUDED__
 #define CGI_CGI_SERVICE_HPP_INCLUDED__
 
-#include "../tags.hpp"
-#include "../connections/stdio.hpp"
-#include "../connections/async_stdio.hpp"
-#include "../gateway_impl/acgi_gateway_impl.hpp"
-#include "../gateway_service/acgi_gateway_service.hpp"
-#include "../basic_protocol_service.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/connections/stdio.hpp"
+#include "boost/cgi/connections/async_stdio.hpp"
+#include "boost/cgi/gateway_impl/acgi_gateway_impl.hpp"
+#include "boost/cgi/gateway_service/acgi_gateway_service.hpp"
+#include "boost/cgi/basic_protocol_service.hpp"
 
 namespace cgi {
 

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/connections/tcp_socket.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/connections/tcp_socket.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/connections/tcp_socket.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -11,11 +11,11 @@
 
 #include <boost/shared_ptr.hpp>
 
-#include "../tags.hpp"
-#include "../io_service.hpp"
-#include "../connection_base.hpp"
-#include "../basic_connection.hpp"
-#include "../detail/push_options.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/connection_base.hpp"
+#include "boost/cgi/basic_connection.hpp"
+#include "boost/cgi/detail/push_options.hpp"
 
 namespace cgi {
 
@@ -75,7 +75,7 @@
       sock_.async_write_some(buf, handler);
     }
 
- void stop()
+ void close()
     {
       sock_.close();
     }
@@ -86,15 +86,12 @@
 
   typedef basic_connection<tags::tcp_socket> tcp_connection;
 
-
- //template<typename ProtocolService = detail::fcgi_service>
- //struct tcp_connection
- //{
- // typedef basic_connection<tags::tcp_socket, ProtocolService> type;
- //};
+ namespace connection {
+ typedef basic_connection<tags::tcp_socket> tcp;
+ }// namespace connection
 
 } // namespace cgi
 
-#include "../detail/pop_options.hpp"
+#include "boost/cgi/detail/pop_options.hpp"
 
 #endif // CGI_CONNECTIONS_TCP_SOCKET_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/header.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/header.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/header.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -20,6 +20,9 @@
     {
     }
 
+ /// Templated constructor to allow user-defined types to be converted
+ template<typename T> header(T& t);
+
     header(const std::string& name, const std::string& val)
       : content(name + ": " + val + "\r\n")
     {
@@ -39,6 +42,12 @@
     return header("Location", url);
   }
 
+ inline template<>
+ header::header(cookie& ck)
+ : content(ck.to_string())
+ {
+ }
+
 } // namespace cgi
 
 #endif // CGI_HEADER_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/io_service_provider.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/io_service_provider.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/io_service_provider.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -92,7 +92,7 @@
 
     cgi::io_service& io_service()
     {
- return boost::ref(*current_++);
+ return *current_++;
     }
 
     void run()

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/acceptor_service_impl.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -9,11 +9,179 @@
 #ifndef CGI_SCGI_ACCEPTOR_SERVICE_IMPL_HPP_INCLUDED__
 #define CGI_SCGI_ACCEPTOR_SERVICE_IMPL_HPP_INCLUDED__
 
+#include "boost/cgi/detail/push_options.hpp"
+
+#include <boost/ref.hpp>
+#include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/utility/enable_if.hpp>
+
+//#include "is_async.hpp"
+#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/detail/protocol_traits.hpp"
+#include "boost/cgi/basic_protocol_service_fwd.hpp"
+#include "boost/cgi/detail/service_base.hpp"
+//#include "service_selector.hpp"
+
 namespace cgi {
 
-
+ /// The service_impl class for SCGI basic_request_acceptor<>s
+ /**
+ * Note: this is near enough to being generic. It will hopefully translate
+ * directly to the fcgi_acceptor_service_impl. In other words you would
+ * then have one acceptor_service_impl<>, so you'd use
+ * acceptor_service_impl<scgi> acceptor_service_impl_; // and
+ * acceptor_service_impl<fcgi> acceptor_service_impl_; // etc...
+ *
+ * Note: If the protocol is an asynchronous protocol, which means it requires
+ * access to a boost::asio::io_service instance, then this class becomes a
+ * model of the Service concept (**LINK**) and must only use the constructor
+ * which takes a ProtocolService (**LINK**). If the protocol isn't async then
+ * the class can be used without a ProtocolService.
+ */
+ template<typename Protocol>
+ class scgi_acceptor_service_impl
+ : public detail::service_base<request_service<Protocol> >
+ {
+ public:
+ //typedef scgi_request_acceptor_impl implementation_type;
+ typedef typename implementation_type::protocol_type protocol_type;
+ typedef basic_protocol_service<protocol_type> protocol_service_type;
+ typedef boost::asio::ip::tcp native_protocol_type;
+ typedef acceptor_service_type::native_type native_type;
+ typedef implementation_type::acceptor_service_type acceptor_service_type;
+
+ /// The unique service identifier
+ //static boost::asio::io_service::id id;
+
+ struct implementation_type
+ {
+ typedef Protocol protocol_type;
+ typedef scgi::request request_type;
+ typedef boost::asio::socket_acceptor_service<
+ native_protocol_type> acceptor_service_type;
+
+ acceptor_service_type::implementation_type acceptor_;
+ boost::mutex mutex_;
+ std::queue<boost::shared_ptr<request_type> > waiting_requests_;
+ protocol_service_type* service_;
+ };
+
+ explicit scgi_request_acceptor_service(cgi::io_service& ios)
+ : detail::service_base<request_service<Protocol> >(ios)
+ , acceptor_service_(boost::asio::use_service<acceptor_service_type>(ios)
+ {
+ }
+
+ void set_protocol_service(implementation_type& impl
+ , protocol_service_type& ps)
+ {
+ impl.protocol_service_ = &ps;
+ }
+
+ protocol_service_type&
+ get_protocol_service(implementation_type& impl)
+ {
+ BOOST_ASSERT(impl.service_ != NULL);
+ return *impl.service_;
+ }
 
+ void construct(implementation_type& impl)
+ {
+ acceptor_service_.construct(impl.acceptor_);
+ //impl.acceptor_ptr().reset(impl::acceptor_type(this->io_service()));
+ }
+
+ void destroy(implementation_type& impl)
+ {
+ // close/reject all the waiting requests
+ /***/
+ acceptor_service_.destroy(impl.acceptor_);
+ }
+
+ void shutdown_service()
+ {
+ acceptor_service_.shutdown_service();
+ }
+
+ /// Check if the given implementation is open.
+ bool is_open(implementation_type& impl)
+ {
+ return acceptor_service_.is_open(impl.acceptor_);
+ }
+
+ /// Open a new *socket* acceptor implementation.
+ boost::system::error_code
+ open(implementation_type& impl, const native_protocol_type& protocol
+ , boost::system::error_code& ec)
+ {
+ return acceptor_service_.open(impl.acceptor_, protocol, ec);
+ }
+
+ /// Assign an existing native acceptor to a *socket* acceptor.
+ boost::system::error_code
+ assign(implementation_type& impl, const native_protocol_type& protocol
+ , const native_type& native_acceptor
+ , boost::system::error_code& ec)
+ {
+ return acceptor_service_.assign(impl.acceptor_, protocol, native_acceptor
+ , ec);
+ }
+
+ /// Accepts one request.
+ template<typename CommonGatewayRequest>
+ boost::system::error_code
+ accept(implementation_type& impl, CommonGatewayRequest& request
+ , boost::system::error_code& ec)
+ {
+ {
+ boost::mutex::scoped_lock lk(impl.mutex_);
+ if (!impl.waiting_requests_.empty())
+ {
+ request = *(impl.waiting_requests_.front());
+ impl.waiting_requests_.pop();
+ return ec;
+ }
+ }
+ return impl.acceptor_.accept(request.client().connection(), ec);
+ }
+
+ /// Asynchronously accepts one request.
+ template<typename CommonGatewayRequest, typename Handler>
+ void async_accept(implementation_type& impl, CommonGatewayRequest& request
+ , Handler handler, boost::system::error_code& ec)
+ {
+ this->io_service().post(
+ boost::bind(&scgi_request_acceptor_service::check_for_waiting_request
+ , boost::ref(impl), boost::ref(request), handler, ec));
+ }
+ private:
+ template<typename CommonGatewayRequest, typename Handler>
+ void check_for_waiting_request(implementation_type& impl
+ , CommonGatewayRequest& request
+ , Handler handler)
+ {
+ {
+ boost::mutex::scoped_lock lk(impl.mutex_);
+ if (!impl.waiting_requests_.empty())
+ {
+ request = *(impl.waiting_requests_.front());
+ impl.waiting_requests_.pop();
+ return handler(ec); // this could be `io_service::post`ed again
+ }
+ }
+ return accceptor_service_.async_accept(request.client().connection()
+ , handler);
+ }
+
+ private:
+ /// The underlying socket acceptor service.
+ acceptor_service_type& acceptor_service_;
+ };
 
 } // namespace cgi
 
+#include "boost/cgi/detail/pop_options.hpp"
+
 #endif // CGI_SCGI_ACCEPTOR_SERVICE_IMPL_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -9,8 +9,8 @@
 #ifndef CGI_SCGI_REQUEST_HPP_INCLUDED__
 #define CGI_SCGI_REQUEST_HPP_INCLUDED__
 
-#include "../tags.hpp"
-#include "../basic_request.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/basic_request.hpp"
 
 namespace cgi {
 
@@ -18,6 +18,10 @@
 
   typedef basic_request<scgi_request_service> scgi_request;
 
+ namespace scgi {
+ // typedef for typical usage (SCGI)
+ typedef basic_request<scgi_request_service> request;
+ } // namespace scgi
 } // namespace cgi
 
 #endif // CGI_SCGI_REQUEST_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_acceptor_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_acceptor_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_acceptor_service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -8,22 +8,21 @@
 ////////////////////////////////////////////////////////////////
 #ifndef CGI_REQUEST_SERVICE_HPP_INCLUDED
 #define CGI_REQUEST_SERVICE_HPP_INCLUDED
-
-#include "../detail/push_options.hpp"
+#include "boost/cgi/detail/push_options.hpp"
 
 #include <boost/utility/enable_if.hpp>
 
 //#include "is_async.hpp"
-#include "../io_service.hpp"
-#include "../detail/throw_error.hpp"
-#include "../detail/protocol_traits.hpp"
-#include "../basic_protocol_service_fwd.hpp"
-#include "../detail/service_base.hpp"
+#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/detail/protocol_traits.hpp"
+#include "boost/cgi/basic_protocol_service_fwd.hpp"
+#include "boost/cgi/detail/service_base.hpp"
 //#include "service_selector.hpp"
 
 namespace cgi {
 
- /// The generic service class for basic_request<>s
+ /// The service class for SCGI basic_request_acceptor<>s
   /**
    * Note: If the protocol is an asynchronous protocol, which means it requires
    * access to a boost::asio::io_service instance, then this class becomes a
@@ -38,56 +37,63 @@
   public:
     //typedef typename service_impl_type::impl_type impl_type;
 
- typedef scgi_request_acceptor_impl implementation_type;
- typedef typename implementation_type::protocol_type
- protocol_type;
- typedef basic_protocol_service<Protocol> protocol_service_type;
+ typedef scgi_acceptor_service_impl service_impl_type;
+ typedef service_impl_type::implementation_type implementation_type;
+ typedef implementation_type::protocol_type protocol_type;
+ typedef basic_protocol_service<protocol_type> protocol_service_type;
 
     /// The unique service identifier
     //static boost::asio::io_service::id id;
- //explicit request_service()
- //{
- //}
 
     scgi_request_acceptor_service(cgi::io_service& ios)
       : detail::service_base<request_service<Protocol> >(ios)
     {
     }
 
- /*
- request_service(protocol_service_type& ps)
- : detail::service_base<request_service<Protocol> >(ps.io_service())
- {
- }
- */
-
     void construct(implementation_type& impl)
     {
+ service_impl_.construct(impl);
     }
 
     void destroy(implementation_type& impl)
     {
+ service_impl_.destroy(impl);
     }
 
     void shutdown_service()
     {
+ service_impl_.shutdown_service();
+ }
+
+ bool is_open(implementation_type& impl)
+ {
+ return service_impl_.is_open(impl);
+ }
+
+ void close(implementation_type& impl)
+ {
+ return service_impl_.close(impl);
     }
 
+ template<typename CommonGatewayRequest>
     boost::system::error_code& accept(implementation_type& impl
+ , CommonGatewayRequest& request
                                      , boost::system::error_code& ec)
     {
-
+ return service_impl_.accept(impl, request, ec);
     }
 
     template<typename Handler>
     void async_accept(implementation_type& impl, Handler handler)
     {
-
+ service_impl_.async_accept(impl, handler);
     }
+ private:
+ service_impl_type service_impl_;
   };
 
 } // namespace cgi
 
-#include "../detail/pop_options.hpp"
+#include "boost/cgi/detail/pop_options.hpp"
 
 #endif // CGI_REQUEST_SERVICE_HPP_INCLUDED

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_impl.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -11,14 +11,15 @@
 
 #include <boost/shared_ptr.hpp>
 
-#include "../map.hpp"
-#include "../role_type.hpp"
-#include "../status_type.hpp"
-#include "../http/status_code.hpp"
-#include "../connections/tcp_socket.hpp"
+#include "boost/cgi/map.hpp"
+#include "boost/cgi/role_type.hpp"
+#include "boost/cgi/status_type.hpp"
+#include "boost/cgi/http/status_code.hpp"
+#include "boost/cgi/connections/tcp_socket.hpp"
 
 namespace cgi {
 
+ /// The implementation_type for scgi_request_service
   class scgi_request_impl
   {
   public:
@@ -30,6 +31,7 @@
       : stdin_parsed_(false)
       , http_status_(http::ok)
       , request_status_(unloaded)
+ , request_finished_(false)
     {
     }
 
@@ -57,7 +59,7 @@
     map_type cookie_vars_;
 
     std::string null_str_;
-
+ bool request_finished_;
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/request_service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -11,17 +11,18 @@
 
 #include <boost/system/error_code.hpp>
 
-#include "request_impl.hpp"
-#include "../map.hpp"
-#include "../tags.hpp"
-#include "../role_type.hpp"
-#include "../io_service.hpp"
-#include "../detail/throw_error.hpp"
-#include "../detail/service_base.hpp"
-#include "../detail/extract_params.hpp"
+#include "boost/cgi/scgi/request_impl.hpp"
+#include "boost/cgi/map.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/role_type.hpp"
+#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/detail/service_base.hpp"
+#include "boost/cgi/detail/extract_params.hpp"
 
 namespace cgi {
 
+ /// The IoObjectService class for a SCGI basic_request<>s
   class scgi_request_service
     : public detail::service_base<scgi_request_service>
   {

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -9,13 +9,19 @@
 #ifndef CGI_SCGI_SERVICE_HPP_INCLUDED__
 #define CGI_SCGI_SERVICE_HPP_INCLUDED__
 
-#include "../tags.hpp"
-#include "../basic_protocol_service.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/basic_protocol_service.hpp"
 
 namespace cgi {
 
- typedef basic_protocol_service<tags::scgi> scgi_service;
+ //typedef basic_protocol_service<tags::scgi> scgi_service;
 
+ namespace scgi {
+
+ // typedef for standard scgi::service (a model of ProtocolService)
+ typedef basic_protocol_service<tags::scgi> service;
+
+ }
 } // namespace cgi
 
 #endif // CGI_SCGI_SERVICE_HPP_INCLUDED__

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/scgi/service_impl.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -9,25 +9,31 @@
 #ifndef CGI_SCGI_SERVICE_IMPL_HPP_INCLUDED__
 #define CGI_SCGI_SERVICE_IMPL_HPP_INCLUDED__
 
+/*********************
+
+THIS IS NOT A PART OF 'THE CODEBASE' ATM
+
+*********************/
+
 #include <boost/system/error_code.hpp>
 
-#include "request_impl.hpp"
-#include "../map.hpp"
-#include "../tags.hpp"
-#include "../role_type.hpp"
-#include "../io_service.hpp"
-#include "../detail/throw_error.hpp"
-#include "../detail/service_base.hpp"
-#include "../detail/extract_params.hpp"
+#include "boost/cgi/scgi/request_impl.hpp"
+#include "boost/cgi/map.hpp"
+#include "boost/cgi/tags.hpp"
+#include "boost/cgi/role_type.hpp"
+#include "boost/cgi/io_service.hpp"
+#include "boost/cgi/detail/throw_error.hpp"
+#include "boost/cgi/detail/service_base.hpp"
+#include "boost/cgi/detail/extract_params.hpp"
 
 namespace cgi {
 
- class scgi_request_service_impl
+ // The implementation of the ProtocolService for SCGI
+ class scgi_service_impl
     : public detail::service_base<scgi_service_impl>
   {
   public:
     typedef tags::scgi protocol_type;
- typedef scgi_request_impl implementation_type;
     typedef cgi::map map_type;
 
     scgi_request_service_impl(cgi::io_service& ios)
@@ -40,201 +46,6 @@
     {
     }
 
- void construct(implementation_type& impl)
- {
- impl.connection()
- = implementation_type::connection_type::create(this->io_service());
- }
-
- void destroy(implementation_type& impl)
- {
- //impl.set_state(aborted);
- }
-
- boost::system::error_code& load(implementation_type& impl, bool parse_stdin
- , boost::system::error_code& ec)
- {
- const std::string& request_method = meta_env(impl, "REQUEST_METHOD", ec);
- if (request_method == "GET")
- if (parse_get_vars(impl, ec))
- return ec;
- else
- if (request_method == "POST" && parse_stdin)
- if (parse_post_vars(impl, ec))
- return ec;
-
- parse_cookie_vars(impl, ec);
- return ec;
- }
-
- template<typename MutableBufferSequence>
- std::size_t read_some(implementation_type& impl
- , const MutableBufferSequence& buf
- , boost::system::error_code& ec)
- {
- std::size_t s = impl.connection()->read_some(buf, ec);
- return s;
- }
-
- template<typename ConstBufferSequence>
- std::size_t write_some(implementation_type& impl
- , const ConstBufferSequence& buf
- , boost::system::error_code& ec)
- {
- return impl.connection()->write_some(buf, ec);
- }
-
- //template<typename VarType> map_type& var(implementation_type&) const;
-
- std::string meta_get(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.get_vars_, name, ec);
- }
-
- map_type& meta_get(implementation_type& impl)
- {
- return impl.get_vars_;
- }
-
- /// Find the post meta-variable matching name
- /**
- * @param greedy This determines whether more data can be read to find
- * the variable. The default is true to cause least surprise in the common
- * case of having not parsed any of the POST data.
-
- -----------------------------------------------
- Should this return a pair of iterators instead?
- What about url_decoding?
- -----------------------------------------------
-
- */
- std::string meta_post(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec
- , bool greedy = true)
- {
- const std::string& val = var(impl.post_vars_, name, ec);
- if (val.empty() && greedy && !ec)
- {
-
- }
-
- return val;
- }
-
- map_type& meta_post(implementation_type& impl)
- {
- return impl.post_vars_;
- }
-
-
- /// Find the cookie meta-variable matching name
- std::string cookie(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.cookie_vars_, name, ec);
- }
-
- map_type& meta_cookie(implementation_type& impl)
- {
- return impl.cookie_vars_;
- }
-
-
- /// Find the environment meta-variable matching name
- std::string meta_env(implementation_type& impl, const std::string& name
- , boost::system::error_code& ec)
- {
- return var(impl.env_vars_, name, ec);
- }
-
-
- role_type get_role(implementation_type& impl)
- {
- return responder;
- }
-
- protected:
- /// Extract the var value from
- std::string var(map_type& meta_data, const std::string& name
- , boost::system::error_code& ec)
- {
- /* Alt:
- if ((typename map_type::iterator pos = meta_data.find(name))
- != meta_data.end())
- {
- return *pos;
- }
- return std::string();
- **/
-
- if( meta_data.find(name) != meta_data.end() )
- return meta_data[name];
- return "";
- }
-
- /// Read and parse the cgi GET meta variables
- boost::system::error_code&
- parse_get_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- detail::extract_params(meta_env(impl, "QUERY_STRING", ec)
- , impl.get_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
- /// Read and parse the HTTP_COOKIE meta variable
- template<typename RequestImpl>
- boost::system::error_code&
- parse_cookie_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.cookie_vars_.empty() );
-
- std::string vars = meta_env(impl, "HTTP_COOKIE", ec);
- if (vars.empty())
- return ec;
-
- detail::extract_params(meta_env(impl, "HTTP_COOKIE", ec)
- , impl.cookie_vars_
- , boost::char_separator<char>
- ("", "=&", boost::keep_empty_tokens)
- , ec);
-
- return ec;
- }
-
- /// Read and parse the cgi POST meta variables (greedily)
- template<typename RequestImpl>
- boost::system::error_code&
- parse_post_vars(implementation_type& impl, boost::system::error_code& ec)
- {
- // Make sure this function hasn't already been called
- //BOOST_ASSERT( impl.post_vars_.empty() );
-
- //# error "Not implemented"
-
- if (impl.stdin_parsed_)
- {
- }
-
- return ec;
- }
-
- /// Read and parse a single cgi POST meta variable (greedily)
- template<typename RequestImpl>
- boost::system::error_code&
- parse_one_post_var(implementation_type& impl, boost::system::error_code& ec)
- {
- //# error "Not implemented"
- return ec;
- }
-
- private:
- cgi::io_service& io_service_;
   };
 
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/tags.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/tags.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/boost/cgi/tags.hpp 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -31,6 +31,8 @@
    struct stdio {};
    struct async_stdio {};
    struct tcp_socket {};
+ // A shareable tcp_socket (ie. one that can be locked)
+ struct shareable_tcp_socket {};
 
  } // namespace tags
 } // namespace cgi

Modified: sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/doc/src/preface.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/doc/src/preface.qbk (original)
+++ sandbox/SOC/2007/cgi/branches/merge_F_and_new_trunk/libs/cgi/doc/src/preface.qbk 2007-10-17 19:30:02 EDT (Wed, 17 Oct 2007)
@@ -25,7 +25,7 @@
 
 * C++ has a very large and professional user base, providing a wealth of expertise and experience.
 
-* Billions of lines of C++ code can be reused to reduce development/testing times.
+* Millions of lines of C++ code can be reused to reduce development/testing times.
 
 * In places where RAD (rapid application development) is of the utmost importance, scripting languages can still be used, for instance by using [link __boost_python__ Boost.Python] - though it could be argued that C++ and RAD are not mutually exclusive.
 


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