mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
ported 1.4.4 branch changes (needs build checks and test runs!)
This commit is contained in:
@@ -56,7 +56,7 @@ DatagramSocket::DatagramSocket(IPAddress::Family family): Socket(new DatagramSoc
|
||||
}
|
||||
|
||||
|
||||
DatagramSocket::DatagramSocket(const SocketAddress& address, bool reuseAddress): Socket(new DatagramSocketImpl)
|
||||
DatagramSocket::DatagramSocket(const SocketAddress& address, bool reuseAddress): Socket(new DatagramSocketImpl(address.family()))
|
||||
{
|
||||
bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
@@ -329,10 +329,13 @@ std::string FTPClientSession::extractPath(const std::string& response)
|
||||
|
||||
StreamSocket FTPClientSession::establishDataConnection(const std::string& command, const std::string& arg)
|
||||
{
|
||||
StreamSocket ss;
|
||||
if (_passiveMode)
|
||||
return passiveDataConnection(command, arg);
|
||||
ss = passiveDataConnection(command, arg);
|
||||
else
|
||||
return activeDataConnection(command, arg);
|
||||
ss = activeDataConnection(command, arg);
|
||||
ss.setReceiveTimeout(_timeout);
|
||||
return ss;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,13 +43,15 @@ namespace Net {
|
||||
|
||||
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, const ServerSocket& socket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), socket, pParams)
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), socket, pParams),
|
||||
_pFactory(pFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPServer::HTTPServer(HTTPRequestHandlerFactory::Ptr pFactory, Poco::ThreadPool& threadPool, const ServerSocket& socket, HTTPServerParams::Ptr pParams):
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), threadPool, socket, pParams)
|
||||
TCPServer(new HTTPServerConnectionFactory(pParams, pFactory), threadPool, socket, pParams),
|
||||
_pFactory(pFactory)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,4 +61,11 @@ HTTPServer::~HTTPServer()
|
||||
}
|
||||
|
||||
|
||||
void HTTPServer::stopAll(bool abortCurrent)
|
||||
{
|
||||
_pFactory->serverStopped(this, abortCurrent);
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "Poco/Net/NetException.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/Delegate.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -53,14 +54,18 @@ namespace Net {
|
||||
HTTPServerConnection::HTTPServerConnection(const StreamSocket& socket, HTTPServerParams::Ptr pParams, HTTPRequestHandlerFactory::Ptr pFactory):
|
||||
TCPServerConnection(socket),
|
||||
_pParams(pParams),
|
||||
_pFactory(pFactory)
|
||||
_pFactory(pFactory),
|
||||
_stopped(false)
|
||||
{
|
||||
poco_check_ptr (pFactory);
|
||||
|
||||
_pFactory->serverStopped += Poco::delegate(this, &HTTPServerConnection::onServerStopped);
|
||||
}
|
||||
|
||||
|
||||
HTTPServerConnection::~HTTPServerConnection()
|
||||
{
|
||||
_pFactory->serverStopped -= Poco::delegate(this, &HTTPServerConnection::onServerStopped);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,10 +73,12 @@ void HTTPServerConnection::run()
|
||||
{
|
||||
std::string server = _pParams->getSoftwareVersion();
|
||||
HTTPServerSession session(socket(), _pParams);
|
||||
while (session.hasMoreRequests())
|
||||
while (!_stopped && session.hasMoreRequests())
|
||||
{
|
||||
try
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
HTTPServerResponseImpl response(session);
|
||||
HTTPServerRequestImpl request(response, session, _pParams);
|
||||
|
||||
@@ -124,4 +131,32 @@ void HTTPServerConnection::sendErrorResponse(HTTPServerSession& session, HTTPRes
|
||||
}
|
||||
|
||||
|
||||
void HTTPServerConnection::onServerStopped(const bool& abortCurrent)
|
||||
{
|
||||
_stopped = true;
|
||||
if (abortCurrent)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket().shutdown();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
try
|
||||
{
|
||||
socket().shutdown();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
@@ -59,7 +59,7 @@ RawSocket::RawSocket(IPAddress::Family family, int proto):
|
||||
|
||||
|
||||
RawSocket::RawSocket(const SocketAddress& address, bool reuseAddress):
|
||||
Socket(new RawSocketImpl)
|
||||
Socket(new RawSocketImpl(address.family()))
|
||||
{
|
||||
bind(address, reuseAddress);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ StreamSocket::StreamSocket(): Socket(new StreamSocketImpl)
|
||||
}
|
||||
|
||||
|
||||
StreamSocket::StreamSocket(const SocketAddress& address): Socket(new StreamSocketImpl)
|
||||
StreamSocket::StreamSocket(const SocketAddress& address): Socket(new StreamSocketImpl(address.family()))
|
||||
{
|
||||
connect(address);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user