mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-27 11:06:50 +01:00 
			
		
		
		
	fix for change for SF# 2807639
This commit is contained in:
		| @@ -14,14 +14,14 @@ | |||||||
| // execute, and transmit the Software, and to prepare derivative works of the | // execute, and transmit the Software, and to prepare derivative works of the | ||||||
| // Software, and to permit third-parties to whom the Software is furnished to | // Software, and to permit third-parties to whom the Software is furnished to | ||||||
| // do so, all subject to the following: | // do so, all subject to the following: | ||||||
| // | //  | ||||||
| // The copyright notices in the Software and this entire statement, including | // The copyright notices in the Software and this entire statement, including | ||||||
| // the above license grant, this restriction and the following disclaimer, | // the above license grant, this restriction and the following disclaimer, | ||||||
| // must be included in all copies of the Software, in whole or in part, and | // must be included in all copies of the Software, in whole or in part, and | ||||||
| // all derivative works of the Software, unless such copies or derivative | // all derivative works of the Software, unless such copies or derivative | ||||||
| // works are solely in the form of machine-executable object code generated by | // works are solely in the form of machine-executable object code generated by | ||||||
| // a source language processor. | // a source language processor. | ||||||
| // | //  | ||||||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||
| // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||||||
| @@ -54,7 +54,7 @@ using Poco::Net::ShutdownNotification; | |||||||
| using Poco::Net::ServerSocket; | using Poco::Net::ServerSocket; | ||||||
| using Poco::Net::StreamSocket; | using Poco::Net::StreamSocket; | ||||||
| using Poco::NObserver; | using Poco::NObserver; | ||||||
| using Poco::Notification; | using Poco::AutoPtr; | ||||||
| using Poco::Thread; | using Poco::Thread; | ||||||
| using Poco::Util::ServerApplication; | using Poco::Util::ServerApplication; | ||||||
| using Poco::Util::Application; | using Poco::Util::Application; | ||||||
| @@ -77,7 +77,7 @@ public: | |||||||
| 		_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable)); | 		_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable)); | ||||||
| 		_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); | 		_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	~EchoServiceHandler() | 	~EchoServiceHandler() | ||||||
| 	{ | 	{ | ||||||
| 		Application& app = Application::instance(); | 		Application& app = Application::instance(); | ||||||
| @@ -92,8 +92,8 @@ public: | |||||||
| 		_reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); | 		_reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown)); | ||||||
| 		delete [] _pBuffer; | 		delete [] _pBuffer; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	void onReadable(const Notification::Ptr& pNf) | 	void onReadable(const AutoPtr<ReadableNotification>& pNf) | ||||||
| 	{ | 	{ | ||||||
| 		int n = _socket.receiveBytes(_pBuffer, BUFFER_SIZE); | 		int n = _socket.receiveBytes(_pBuffer, BUFFER_SIZE); | ||||||
| 		if (n > 0) | 		if (n > 0) | ||||||
| @@ -101,18 +101,18 @@ public: | |||||||
| 		else | 		else | ||||||
| 			delete this; | 			delete this; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	void onShutdown(const Notification::Ptr& pNf) | 	void onShutdown(const AutoPtr<ShutdownNotification>& pNf) | ||||||
| 	{ | 	{ | ||||||
| 		delete this; | 		delete this; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| private: | private: | ||||||
| 	enum | 	enum | ||||||
| 	{ | 	{ | ||||||
| 		BUFFER_SIZE = 1024 | 		BUFFER_SIZE = 1024 | ||||||
| 	}; | 	}; | ||||||
|  | 	 | ||||||
| 	StreamSocket   _socket; | 	StreamSocket   _socket; | ||||||
| 	SocketReactor& _reactor; | 	SocketReactor& _reactor; | ||||||
| 	char*          _pBuffer; | 	char*          _pBuffer; | ||||||
| @@ -142,7 +142,7 @@ public: | |||||||
| 	EchoServer(): _helpRequested(false) | 	EchoServer(): _helpRequested(false) | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	~EchoServer() | 	~EchoServer() | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| @@ -153,7 +153,7 @@ protected: | |||||||
| 		loadConfiguration(); // load default configuration files, if present | 		loadConfiguration(); // load default configuration files, if present | ||||||
| 		ServerApplication::initialize(self); | 		ServerApplication::initialize(self); | ||||||
| 	} | 	} | ||||||
|  | 		 | ||||||
| 	void uninitialize() | 	void uninitialize() | ||||||
| 	{ | 	{ | ||||||
| 		ServerApplication::uninitialize(); | 		ServerApplication::uninitialize(); | ||||||
| @@ -162,7 +162,7 @@ protected: | |||||||
| 	void defineOptions(OptionSet& options) | 	void defineOptions(OptionSet& options) | ||||||
| 	{ | 	{ | ||||||
| 		ServerApplication::defineOptions(options); | 		ServerApplication::defineOptions(options); | ||||||
|  | 		 | ||||||
| 		options.addOption( | 		options.addOption( | ||||||
| 			Option("help", "h", "display help information on command line arguments") | 			Option("help", "h", "display help information on command line arguments") | ||||||
| 				.required(false) | 				.required(false) | ||||||
| @@ -196,14 +196,14 @@ protected: | |||||||
| 		{ | 		{ | ||||||
| 			// get parameters from configuration file | 			// get parameters from configuration file | ||||||
| 			unsigned short port = (unsigned short) config().getInt("EchoServer.port", 9977); | 			unsigned short port = (unsigned short) config().getInt("EchoServer.port", 9977); | ||||||
|  | 			 | ||||||
| 			// set-up a server socket | 			// set-up a server socket | ||||||
| 			ServerSocket svs(port); | 			ServerSocket svs(port); | ||||||
| 			// set-up a SocketReactor... | 			// set-up a SocketReactor... | ||||||
| 			SocketReactor reactor; | 			SocketReactor reactor; | ||||||
| 			// ... and a SocketAcceptor | 			// ... and a SocketAcceptor | ||||||
| 			SocketAcceptor<EchoServiceHandler> acceptor(svs, reactor); | 			SocketAcceptor<EchoServiceHandler> acceptor(svs, reactor); | ||||||
| 			// run the reactor in its own thread so that we can wait for | 			// run the reactor in its own thread so that we can wait for  | ||||||
| 			// a termination request | 			// a termination request | ||||||
| 			Thread thread; | 			Thread thread; | ||||||
| 			thread.start(reactor); | 			thread.start(reactor); | ||||||
| @@ -215,7 +215,7 @@ protected: | |||||||
| 		} | 		} | ||||||
| 		return Application::EXIT_OK; | 		return Application::EXIT_OK; | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| private: | private: | ||||||
| 	bool _helpRequested; | 	bool _helpRequested; | ||||||
| }; | }; | ||||||
| @@ -226,3 +226,4 @@ int main(int argc, char** argv) | |||||||
| 	EchoServer app; | 	EchoServer app; | ||||||
| 	return app.run(argc, argv); | 	return app.run(argc, argv); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Marian Krivos
					Marian Krivos