From: Ebersold Andre Date: Fri, 24 Jun 2022 20:28:12 +0000 (+0200) Subject: Continued on fcgi X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=cf352666e45aca0997dc5c4d903e4e9c2551e4cd;p=aebutils.git Continued on fcgi --- diff --git a/aeb/fcgi/fcgi.h b/aeb/fcgi/fcgi.h index 8511368..54adef6 100644 --- a/aeb/fcgi/fcgi.h +++ b/aeb/fcgi/fcgi.h @@ -8,7 +8,7 @@ namespace fcgi { /** * */ -template +template class acceptor : public basic_socket_acceptor { public: @@ -32,12 +32,12 @@ class acceptor : public basic_socket_acceptor if (s != aeb::net::detail::invalid_socket) { - m_r = request_handler::ptr(new request_handler(s)) ; + m_r = RequestHandler::ptr(new RequestHandler(s)) ; m_r->add_ref(); //because request_handler will kill himself } }; protected: - request_handler::ptr m_r; + RequestHandler::ptr m_r; }; diff --git a/aeb/fcgi/fcgi_handler.h b/aeb/fcgi/fcgi_handler.h new file mode 100644 index 0000000..79b1456 --- /dev/null +++ b/aeb/fcgi/fcgi_handler.h @@ -0,0 +1,69 @@ +#ifndef __FCGI_H__ +#define __FCGI_H__ + +namespace aeb { +namespace fcgi { + +/** + * \brief The handler is reponsible to act as an interface between the + * socket and a request. There is one handler per socket. However, there can + * be multiple requests per socket. + * The handler is responsible to dispatch the read message to the right + * request handler. Hence this class is more a kind of fcgi message handler + * on top of which we will have the Request handler. :w + * + */ + +class handler : public event_handler +{ + private: + int m_ref; + public: + + typedef basic_socket_stream Stream; + /// aeb::ssl::stream ? or detail::socket_type + typedef basic_socket_stream SSLStream; + + typedef aeb::intrusive_ptr ptr; + + inline void add_ref() {m_ref++;}; + + inline void release() { + if (--m_ref == 0) delete this; + }; + bool available () const; + + public: + handler(detail::socket_type s); + + virtual ~handler() ; + + virtual void onClose(unsigned short _code) ; + + void on_write() ; + + void on_read() ; + + void on_accept(); + + void io_register(); + + void io_unregister(); + // reuse handler with a new socket + void reuse(aeb::net::detail::socket_type s); + + protected: + handler(const ws_handler &p) ; + // Should own an endpoint + long m_max_frame_size; +}; + +/** +vim:et:sw=2:ts=2 + */ + + +#endif /*WS_HANDLER_H*/ +} +} + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 58dd560..9d16ee8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,6 +9,10 @@ ADD_EXECUTABLE(ip4_server ip4_server.cpp ) + ADD_EXECUTABLE(fcgi_hello + fcgi_helloworld.cpp + ) + ADD_EXECUTABLE(intrusive_ptr intrusive_ptr.cpp ) diff --git a/tests/fcgi_helloworld.cpp b/tests/fcgi_helloworld.cpp new file mode 100644 index 0000000..78b0d53 --- /dev/null +++ b/tests/fcgi_helloworld.cpp @@ -0,0 +1,47 @@ +#if 0 +#include +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include +#include +#if defined(__MINGW32__) ||defined(_WIN32) +#include +#endif + +#include +#include + +using namespace aeb::net; +typedef aeb::net::io_dispatcher io_service; +typedef aeb::net::basic_socket tcp_socket; + +/** + * @brief main entry point. A simple example to use + * the fcgi implementation. Will use this test + * to verify the communication + * + * + */ +int main(int argc,char **argv) +{ + + ip::basic_endpoint ep(ip::tcp::v4(),10224); + + aeb::fcgi::acceptor a(ep); + + a.listen(); + +: io_service *io = aeb::singleton::get_instance(); + + io->register_handler(2,&a); + + io->run(false); +}