diff options
author | Conrad Scott <conrad.scott@dsl.pipex.com> | 2002-06-16 22:53:10 +0400 |
---|---|---|
committer | Conrad Scott <conrad.scott@dsl.pipex.com> | 2002-06-16 22:53:10 +0400 |
commit | ca9972ea04af737ec7a8cfa255ae830c55d0d3a5 (patch) | |
tree | 905461f0e997fa4f3e3a1bb8846300cfeda71e3e | |
parent | 28915445a8ba27bb8632c436a30cf7e989e12c0f (diff) |
* include/cygwin/cygserver.h (client_request::serve): Make pure
virtual.
* cygserver.cc (client_request::serve): Remove definition of pure
virtual method.
(class client_request_invalid): New class.
(server_request::process): Use new client_request_invalid
class. And remove goto's.
-rw-r--r-- | winsup/cygwin/ChangeLog | 10 | ||||
-rwxr-xr-x | winsup/cygwin/cygserver.cc | 58 | ||||
-rwxr-xr-x | winsup/cygwin/include/cygwin/cygserver.h | 2 |
3 files changed, 48 insertions, 22 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index feb6e2ec1..e028b5116 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,15 @@ 2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com> + * include/cygwin/cygserver.h (client_request::serve): Make pure + virtual. + * cygserver.cc (client_request::serve): Remove definition of pure + virtual method. + (class client_request_invalid): New class. + (server_request::process): Use new client_request_invalid + class. And remove goto's. + +2002-06-16 Conrad Scott <conrad.scott@dsl.pipex.com> + * cygserver.cc (class server_request): Add virtual destructor. (server_request_queue::addConnection): New method to replace bad virtual add() method. diff --git a/winsup/cygwin/cygserver.cc b/winsup/cygwin/cygserver.cc index 6b2e88f9b..cadde3345 100755 --- a/winsup/cygwin/cygserver.cc +++ b/winsup/cygwin/cygserver.cc @@ -239,15 +239,6 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process, } void -client_request::serve (transport_layer_base *conn, class process_cache *cache) -{ - system_printf ("*****************************************\n" - "A call to the base client_request class has occurred\n" - "This indicates a mismatch in a virtual function definition somewhere"); - exit (1); -} - -void client_request_attach_tty::serve(transport_layer_base *conn, class process_cache *cache) { HANDLE from_process_handle = NULL; @@ -362,6 +353,31 @@ client_request_get_version::serve(transport_layer_base *conn, class process_cach version.patch = CYGWIN_SERVER_VERSION_PATCH; } +/* + * class client_request_invalid + * + * Used by server_request::process() to handle unrecognised client + * requests. Apart from error reporting (to the log and to the + * client), its main purpose is to provide an implementation of the + * (pure virtual) serve() method that server_request::process() can + * call. + */ + +class client_request_invalid : public client_request +{ +public: + client_request_invalid (const request_header * const hdr) + : client_request (CYGSERVER_REQUEST_INVALID, 0) + { + header.error_code = ENOSYS; + system_printf ("invalid request [type = %d]: returning ENOSYS", + hdr->req_id); + }; + + virtual void serve (transport_layer_base *, class process_cache *) + {}; +}; + class server_request : public queue_request { public: @@ -452,7 +468,7 @@ server_request::process () if (bytes_read != sizeof (struct request_header)) { system_printf ("error reading from connection (%lu)", GetLastError ()); - goto out; + return; } // verbose: debug_printf ("got header (%ld)", bytes_read); @@ -465,27 +481,28 @@ server_request::process () case CYGSERVER_REQUEST_SHUTDOWN: req = new client_request_shutdown (); break; case CYGSERVER_REQUEST_SHM_GET: - req = new client_request_shm (); break; + req = new client_request_shm (); break; default: - req = new client_request (CYGSERVER_REQUEST_INVALID, 0); - req->header.error_code = ENOSYS; - system_printf ("Bad client request - returning ENOSYS"); + req = new client_request_invalid (req_ptr); break; } + assert (req); + if (req->header.cb != req_ptr->cb) { system_printf ("Mismatch in request buffer sizes"); - goto out; + delete req; + return; } if (req->header.cb) { - bytes_read = conn->read (req->buffer, req->header.cb); if (bytes_read != req->header.cb) { system_printf ("error reading from connection (%lu)", GetLastError ()); - goto out; + delete req; + return; } // verbose: debug_printf ("got body (%ld)",bytes_read); } @@ -499,15 +516,14 @@ server_request::process () { req->header.error_code = -1; system_printf ("error writing to connection (%lu)", GetLastError ()); - goto out; + delete req; + return; } // verbose: debug_printf("Sent reply, size (%ld)",bytes_written); printf ("."); -out: - if (req) - delete (req); + delete (req); } void diff --git a/winsup/cygwin/include/cygwin/cygserver.h b/winsup/cygwin/include/cygwin/cygserver.h index 553479ddf..8c9c0a93b 100755 --- a/winsup/cygwin/include/cygwin/cygserver.h +++ b/winsup/cygwin/include/cygwin/cygserver.h @@ -89,7 +89,7 @@ public: client_request (cygserver_request_code id, ssize_t data_size); void send (transport_layer_base *conn); #ifndef __INSIDE_CYGWIN__ - virtual void serve (transport_layer_base *conn, class process_cache *cache); + virtual void serve (transport_layer_base *, class process_cache *) = 0; #endif cygserver_request_code req_id () {return header.req_id;}; virtual ~client_request(); |