Commit 7c419681 authored by Stephen Morris's avatar Stephen Morris

[trac499] Mischellaneous minor preparator changes

* Extend logging in IOFetch (and add message definitions)
* Update buffer size setting for UDP socket
* remove spaces at end of lines in other files
parent f0dd8824
...@@ -50,7 +50,8 @@ if USE_CLANGPP ...@@ -50,7 +50,8 @@ if USE_CLANGPP
libasiolink_la_CXXFLAGS += -Wno-error libasiolink_la_CXXFLAGS += -Wno-error
endif endif
libasiolink_la_CPPFLAGS = $(AM_CPPFLAGS) libasiolink_la_CPPFLAGS = $(AM_CPPFLAGS)
libasiolink_la_LIBADD = $(top_builddir)/src/lib/log/liblog.la libasiolink_la_LIBADD =
libasiolink_la_LIBADD += $(top_builddir)/src/lib/resolve/libresolve.la libasiolink_la_LIBADD += $(top_builddir)/src/lib/resolve/libresolve.la
libasiolink_la_LIBADD += $(top_builddir)/src/lib/cache/libcache.la libasiolink_la_LIBADD += $(top_builddir)/src/lib/cache/libcache.la
libasiolink_la_LIBADD += $(top_builddir)/src/lib/nsas/libnsas.la libasiolink_la_LIBADD += $(top_builddir)/src/lib/nsas/libnsas.la
libasiolink_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
// File created from asiodef.msg on Thu Feb 24 11:52:42 2011
#include <cstddef>
#include <log/message_types.h>
#include <log/message_initializer.h>
namespace asiolink {
extern const isc::log::MessageID ASIO_FETCHCOMP = "FETCHCOMP";
extern const isc::log::MessageID ASIO_FETCHSTOP = "FETCHSTOP";
extern const isc::log::MessageID ASIO_OPENSOCK = "OPENSOCK";
extern const isc::log::MessageID ASIO_RECVSOCK = "RECVSOCK";
extern const isc::log::MessageID ASIO_RECVTMO = "RECVTMO";
extern const isc::log::MessageID ASIO_SENDSOCK = "SENDSOCK";
extern const isc::log::MessageID ASIO_UNKORIGIN = "UNKORIGIN";
extern const isc::log::MessageID ASIO_UNKRESULT = "UNKRESULT";
} // namespace asiolink
namespace {
const char* values[] = {
"FETCHCOMP", "upstream fetch to %s has now completed",
"FETCHSTOP", "upstream fetch to %s has been stopped",
"OPENSOCK", "error %d opening %s socket to %s",
"RECVSOCK", "error %d reading data from %s via a %s socket",
"RECVTMO", "receive timeout while waiting for data from %s",
"SENDSOCK", "error %d sending data to %s via a %s socket",
"UNKORIGIN", "unknown origin for ASIO error code %d (protocol: %s, address %s)",
"UNKRESULT", "unknown result (%d) when IOFetch::stop() was executed for I/O to %s",
NULL
};
const isc::log::MessageInitializer initializer(values);
} // Anonymous namespace
// File created from asiodef.msg on Thu Feb 24 11:52:42 2011
#ifndef __ASIODEF_H
#define __ASIODEF_H
#include <log/message_types.h>
namespace asiolink {
extern const isc::log::MessageID ASIO_FETCHCOMP;
extern const isc::log::MessageID ASIO_FETCHSTOP;
extern const isc::log::MessageID ASIO_OPENSOCK;
extern const isc::log::MessageID ASIO_RECVSOCK;
extern const isc::log::MessageID ASIO_RECVTMO;
extern const isc::log::MessageID ASIO_SENDSOCK;
extern const isc::log::MessageID ASIO_UNKORIGIN;
extern const isc::log::MessageID ASIO_UNKRESULT;
} // namespace asiolink
#endif // __ASIODEF_H
# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
$PREFIX ASIO_
$NAMESPACE asiolink
FETCHCOMP upstream fetch to %s has now completed
+ A debug message, this records the the upstream fetch (a query made by the
+ resolver on behalf of its client) to the specified address has completed.
FETCHSTOP upstream fetch to %s has been stopped
+ An external component has requested the halting of an upstream fetch. This
+ is an allowed operation, and the message should only appear if debug is
+ enabled.
OPENSOCK error %d opening %s socket to %s
+ The asynchronous I/O code encountered an error when trying to open a socket
+ of the specified protocol in order to send a message to the target address.
+ The the number of the system error that cause the problem is given in the
+ message.
RECVSOCK error %d reading data from %s via a %s socket
+ The asynchronous I/O code encountered an error when trying read data from
+ the specified address on the given protocol. The the number of the system
+ error that cause the problem is given in the message.
SENDSOCK error %d sending data to %s via a %s socket
+ The asynchronous I/O code encountered an error when trying send data to
+ the specified address on the given protocol. The the number of the system
+ error that cause the problem is given in the message.
RECVTMO receive timeout while waiting for data from %s
+ An upstream fetch from the specified address timed out. This may happen for
+ any number of reasons and is most probably a problem at the remote server
+ or a problem on the network. The message will only appear if debug is
+ enabled.
UNKORIGIN unknown origin for ASIO error code %d (protocol: %s, address %s)
+ This message should not appear and indicates an internal error if it does.
+ Please enter a bug report.
UNKRESULT unknown result (%d) when IOFetch::stop() was executed for I/O to %s
+ The termination method of the resolver's upstream fetch class was called with
+ an unknown result code (which is given in the message). This message should
+ not appear and may indicate an internal error. Please enter a bug report.
...@@ -84,8 +84,4 @@ ...@@ -84,8 +84,4 @@
/// the placeholder of callback handlers: /// the placeholder of callback handlers:
/// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html /// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html
#endif // __ASIOLINK_H #endif // __ASIOLINK_H
\ No newline at end of file
// Local Variables:
// mode: c++
// End:
...@@ -21,7 +21,7 @@ namespace asiolink { ...@@ -21,7 +21,7 @@ namespace asiolink {
/// \brief The \c DNSServer class is a wrapper (and base class) for /// \brief The \c DNSServer class is a wrapper (and base class) for
/// classes which provide DNS server functionality. /// classes which provide DNS server functionality.
/// ///
/// The classes derived from this one, \c TCPServer and \c UDPServer, /// The classes derived from this one, \c TCPServer and \c UDPServer,
/// act as the interface layer between clients sending queries, and /// act as the interface layer between clients sending queries, and
/// functions defined elsewhere that provide answers to those queries. /// functions defined elsewhere that provide answers to those queries.
...@@ -42,10 +42,10 @@ namespace asiolink { ...@@ -42,10 +42,10 @@ namespace asiolink {
/// when "forking", and that instances will be posted as ASIO handler /// when "forking", and that instances will be posted as ASIO handler
/// objects, which are always copied. /// objects, which are always copied.
/// ///
/// Because these objects are frequently copied, it is recommended /// Because these objects are frequently copied, it is recommended
/// that derived classes be kept small to reduce copy overhead. /// that derived classes be kept small to reduce copy overhead.
class DNSServer { class DNSServer {
protected: protected:
/// ///
/// \name Constructors and destructors /// \name Constructors and destructors
/// ///
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
/// the ones in the derived class. This makes it possible to pass /// the ones in the derived class. This makes it possible to pass
/// instances of derived classes as references to this base class /// instances of derived classes as references to this base class
/// without losing access to derived class data. /// without losing access to derived class data.
/// ///
//@{ //@{
/// \brief The funtion operator /// \brief The funtion operator
virtual void operator()(asio::error_code ec = asio::error_code(), virtual void operator()(asio::error_code ec = asio::error_code(),
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
(*self_)(ec, length); (*self_)(ec, length);
} }
/// \brief Resume processing of the server coroutine after an /// \brief Resume processing of the server coroutine after an
/// asynchronous call (e.g., to the DNS Lookup provider) has completed. /// asynchronous call (e.g., to the DNS Lookup provider) has completed.
/// ///
/// \param done If true, this signals the system there is an answer /// \param done If true, this signals the system there is an answer
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
/// \brief Indicate whether the server is able to send an answer /// \brief Indicate whether the server is able to send an answer
/// to a query. /// to a query.
/// ///
/// This is presently used only for testing purposes. /// This is presently used only for testing purposes.
virtual bool hasAnswer() { return (self_->hasAnswer()); } virtual bool hasAnswer() { return (self_->hasAnswer()); }
......
...@@ -26,13 +26,13 @@ class DNSLookup; ...@@ -26,13 +26,13 @@ class DNSLookup;
class DNSAnswer; class DNSAnswer;
class DNSServiceImpl; class DNSServiceImpl;
/// \brief Handle DNS Queries
/// ///
/// DNSService is the service that handles DNS queries and answers with /// DNSService is the service that handles DNS queries and answers with
/// a given IOService. This class is mainly intended to hold all the /// a given IOService. This class is mainly intended to hold all the
/// logic that is shared between the authoritative and the recursive /// logic that is shared between the authoritative and the recursive
/// server implementations. As such, it handles asio, including config /// server implementations. As such, it handles asio, including config
/// updates (through the 'Checkinprovider'), and listening sockets. /// updates (through the 'Checkinprovider'), and listening sockets.
///
class DNSService { class DNSService {
/// ///
/// \name Constructors and Destructor /// \name Constructors and Destructor
......
...@@ -37,7 +37,7 @@ struct IntervalTimerImpl; ...@@ -37,7 +37,7 @@ struct IntervalTimerImpl;
/// The function calls the call back function set by \c setup() and updates /// The function calls the call back function set by \c setup() and updates
/// the timer to expire in (now + interval) milliseconds. /// the timer to expire in (now + interval) milliseconds.
/// The type of call back function is \c void(void). /// The type of call back function is \c void(void).
/// ///
/// The call back function will not be called if the instance of this class is /// The call back function will not be called if the instance of this class is
/// destroyed before the timer is expired. /// destroyed before the timer is expired.
/// ///
......
...@@ -120,8 +120,4 @@ private: ...@@ -120,8 +120,4 @@ private:
}; };
} // asiolink } // asiolink
#endif // __IO_ADDRESS_H #endif // __IO_ADDRESS_H
\ No newline at end of file
// Local Variables:
// mode: c++
// End:
...@@ -41,7 +41,14 @@ public: ...@@ -41,7 +41,14 @@ public:
IOError(file, line, what) {} IOError(file, line, what) {}
}; };
/// \brief Socket not open
///
/// Thrown if attempt to change socket options fails.
class SocketSetError : public IOError {
public:
SocketSetError(const char* file, size_t line, const char* what) :
IOError(file, line, what) {}
};
/// Forward declaration of an IOEndpoint /// Forward declaration of an IOEndpoint
class IOEndpoint; class IOEndpoint;
...@@ -276,7 +283,9 @@ public: ...@@ -276,7 +283,9 @@ public:
/// \param cumulative Unused /// \param cumulative Unused
/// \param endpoint Unused /// \param endpoint Unused
/// \param callback Unused /// \param callback Unused
virtual void asyncReceive(void* data, size_t, size_t, IOEndpoint*, C&) { } virtual void asyncReceive(void* data, size_t, size_t, IOEndpoint*, C&) {
}
/// \brief Checks if the data received is complete. /// \brief Checks if the data received is complete.
/// ///
/// \param data Unused /// \param data Unused
......
...@@ -115,8 +115,4 @@ public: ...@@ -115,8 +115,4 @@ public:
}; };
} // asiolink } // asiolink
#endif // __IO_ENDPOINT_H #endif // __IO_ENDPOINT_H
\ No newline at end of file
// Local Variables:
// mode: c++
// End:
...@@ -46,7 +46,7 @@ isc::log::Logger logger("asio"); ...@@ -46,7 +46,7 @@ isc::log::Logger logger("asio");
/// IOFetch Constructor - just initialize the private data /// IOFetch Constructor - just initialize the private data
IOFetch::IOFetch(int protocol, IOService& service, IOFetch::IOFetch(Protocol protocol, IOService& service,
const isc::dns::Question& question, const IOAddress& address, uint16_t port, const isc::dns::Question& question, const IOAddress& address, uint16_t port,
isc::dns::OutputBufferPtr& buff, Callback* cb, int wait) isc::dns::OutputBufferPtr& buff, Callback* cb, int wait)
: :
...@@ -140,6 +140,7 @@ IOFetch::operator()(error_code ec, size_t length) { ...@@ -140,6 +140,7 @@ IOFetch::operator()(error_code ec, size_t length) {
data_->buffer->writeData(data_->data.get(), length); data_->buffer->writeData(data_->data.get(), length);
// Finished with this socket, so close it. // Finished with this socket, so close it.
data_->origin = CLOSE;
data_->socket->close(); data_->socket->close();
/// We are done /// We are done
...@@ -170,9 +171,14 @@ IOFetch::stop(Result result) { ...@@ -170,9 +171,14 @@ IOFetch::stop(Result result) {
// variable should be done inside a mutex (and the stopped_ variable // variable should be done inside a mutex (and the stopped_ variable
// declared as "volatile"). // declared as "volatile").
// //
// The numeric arguments indicate the debug level, with the lower
// numbers indicating the most important information. The relative
// values are somewhat arbitrary.
//
// Although Logger::debug checks the debug flag internally, doing it // Although Logger::debug checks the debug flag internally, doing it
// in below avoids the overhead of a string conversion in the common // below before calling Logger::debug avoids the overhead of a string
// case when debug is not enabled. // conversion in the common paths and in the common case when debug is
// not enabled.
// //
// TODO: Update testing of stopped_ if threads are used. // TODO: Update testing of stopped_ if threads are used.
data_->stopped = true; data_->stopped = true;
...@@ -185,15 +191,24 @@ IOFetch::stop(Result result) { ...@@ -185,15 +191,24 @@ IOFetch::stop(Result result) {
} }
break; break;
case STOPPED: case SUCCESS:
if (logger.isDebugEnabled(50)) { if (logger.isDebugEnabled(50)) {
logger.debug(50, ASIO_FETCOMP, logger.debug(50, ASIO_FETCHCOMP,
data_->remote->getAddress().toText().c_str()); data_->remote->getAddress().toText().c_str());
} }
break; break;
case STOPPED:
// Fetch has been stopped for some other reason. This is
// allowed but as it is unusual it is logged, but with a lower
// debug level than a timeout (which is totally normal).
logger.debug(10, ASIO_FETCHSTOP,
data_->remote->getAddress().toText().c_str());
break;
default: default:
logger.error(ASIO_UNKRESULT, static_cast<int>(result)); logger.error(ASIO_UNKRESULT, static_cast<int>(result),
data_->remote->getAddress().toText().c_str());
} }
// Stop requested, cancel and I/O's on the socket and shut it down, // Stop requested, cancel and I/O's on the socket and shut it down,
......
...@@ -51,6 +51,12 @@ namespace asiolink { ...@@ -51,6 +51,12 @@ namespace asiolink {
class IOFetch : public coroutine { class IOFetch : public coroutine {
public: public:
/// \brief Protocol to use on the fetch
enum Protocol {
UDP = 0,
TCP = 1
};
/// \brief Origin of Asynchronous I/O Call /// \brief Origin of Asynchronous I/O Call
/// ///
/// Indicates what initiated an asynchronous I/O call and used in deciding /// Indicates what initiated an asynchronous I/O call and used in deciding
...@@ -149,7 +155,7 @@ public: ...@@ -149,7 +155,7 @@ public:
/// ///
/// Just fills in the data members of the IOFetchData structure /// Just fills in the data members of the IOFetchData structure
/// ///
/// \param proto either IPPROTO_UDP or IPPROTO_TCP /// \param proto Protocol: either IOFetch::TCP or IOFetch::UDP
/// \param service I/O Service object to handle the asynchronous /// \param service I/O Service object to handle the asynchronous
/// operations. /// operations.
/// \param query DNS question to send to the upstream server. /// \param query DNS question to send to the upstream server.
...@@ -163,18 +169,18 @@ public: ...@@ -163,18 +169,18 @@ public:
/// \param wait Timeout for the fetch (in ms). /// \param wait Timeout for the fetch (in ms).
/// ///
/// TODO: May need to alter constructor (see comment 4 in Trac ticket #554) /// TODO: May need to alter constructor (see comment 4 in Trac ticket #554)
IOFetchData(int proto, IOService& service, IOFetchData(Protocol proto, IOService& service,
const isc::dns::Question& query, const IOAddress& address, const isc::dns::Question& query, const IOAddress& address,
uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb, uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb,
int wait) int wait)
: :
socket((proto == IPPROTO_UDP) ? socket((proto == UDP) ?
static_cast<IOAsioSocket<IOFetch>*>( static_cast<IOAsioSocket<IOFetch>*>(
new UDPSocket<IOFetch>(service)) : new UDPSocket<IOFetch>(service)) :
static_cast<IOAsioSocket<IOFetch>*>( static_cast<IOAsioSocket<IOFetch>*>(
new TCPSocket<IOFetch>(service)) new TCPSocket<IOFetch>(service))
), ),
remote((proto == IPPROTO_UDP) ? remote((proto == UDP) ?
static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) : static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) :
static_cast<IOEndpoint*>(new TCPEndpoint(address, port)) static_cast<IOEndpoint*>(new TCPEndpoint(address, port))
), ),
...@@ -197,7 +203,7 @@ public: ...@@ -197,7 +203,7 @@ public:
/// ///
/// TODO: Need to randomise the source port /// TODO: Need to randomise the source port
/// ///
/// \param protocol Fetch protocol, either IPPROTO_UDP or IPPROTO_TCP /// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP
/// \param service I/O Service object to handle the asynchronous /// \param service I/O Service object to handle the asynchronous
/// operations. /// operations.
/// \param question DNS question to send to the upstream server. /// \param question DNS question to send to the upstream server.
...@@ -211,11 +217,11 @@ public: ...@@ -211,11 +217,11 @@ public:
/// (default = 53) /// (default = 53)
/// \param wait Timeout for the fetch (in ms). The default value of /// \param wait Timeout for the fetch (in ms). The default value of
/// -1 indicates no timeout. /// -1 indicates no timeout.
IOFetch(int protocol, IOService& service, IOFetch(Protocol protocol, IOService& service,
const isc::dns::Question& question, const IOAddress& address, const isc::dns::Question& question, const IOAddress& address,
uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb, uint16_t port, isc::dns::OutputBufferPtr& buff, Callback* cb,
int wait = -1); int wait = -1);
/// \brief Coroutine entry point /// \brief Coroutine entry point
/// ///
/// The operator() method is the method in which the coroutine code enters /// The operator() method is the method in which the coroutine code enters
......
...@@ -97,8 +97,4 @@ private: ...@@ -97,8 +97,4 @@ private:
} // asiolink } // asiolink
#endif // __IO_MESSAGE_H #endif // __IO_MESSAGE_H
\ No newline at end of file
// Local Variables:
// mode: c++
// End:
...@@ -163,7 +163,7 @@ private: ...@@ -163,7 +163,7 @@ private:
int serverIndex = rand() % uc; int serverIndex = rand() % uc;
dlog("Sending upstream query (" + question_.toText() + dlog("Sending upstream query (" + question_.toText() +
") to " + upstream_->at(serverIndex).first); ") to " + upstream_->at(serverIndex).first);
IOFetch query(IPPROTO_UDP, io_, question_, IOFetch query(IOFetch::UDP, io_, question_,
upstream_->at(serverIndex).first, upstream_->at(serverIndex).first,
upstream_->at(serverIndex).second, buffer_, this, upstream_->at(serverIndex).second, buffer_, this,
query_timeout_); query_timeout_);
...@@ -173,7 +173,7 @@ private: ...@@ -173,7 +173,7 @@ private:
int serverIndex = rand() % zs; int serverIndex = rand() % zs;
dlog("Sending query to zone server (" + question_.toText() + dlog("Sending query to zone server (" + question_.toText() +
") to " + zone_servers_.at(serverIndex).first); ") to " + zone_servers_.at(serverIndex).first);
IOFetch query(IPPROTO_IDP, io_, question_, IOFetch query(IOFetch::UDP, io_, question_,
zone_servers_.at(serverIndex).first, zone_servers_.at(serverIndex).first,
zone_servers_.at(serverIndex).second, buffer_, this, zone_servers_.at(serverIndex).second, buffer_, this,
query_timeout_); query_timeout_);
......
...@@ -32,12 +32,13 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) ...@@ -32,12 +32,13 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDADD = $(GTEST_LDADD) run_unittests_LDADD = $(GTEST_LDADD)
run_unittests_LDADD += $(SQLITE_LIBS) run_unittests_LDADD += $(SQLITE_LIBS)
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la run_unittests_LDADD += $(top_builddir)/src/lib/resolve/libresolve.la
run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(LOG4CXX_LDFLAGS) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(LOG4CXX_LDFLAGS)
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
run_(false), run_(false),
question_(Name("example.net"), RRClass::IN(), RRType::A()), question_(Name("example.net"), RRClass::IN(), RRType::A()),
buff_(new OutputBuffer(512)), buff_(new OutputBuffer(512)),
udp_fetch_(IPPROTO_UDP, service_, question_, IOAddress(TEST_HOST), udp_fetch_(IOFetch::UDP, service_, question_, IOAddress(TEST_HOST),
TEST_PORT, buff_, this, 100) TEST_PORT, buff_, this, 100)
// tcp_fetch_(service_, question_, IOAddress(TEST_HOST), TEST_PORT, // tcp_fetch_(service_, question_, IOAddress(TEST_HOST), TEST_PORT,
// buff_, this, 100, IPPROTO_UDP) // buff_, this, 100, IPPROTO_UDP)
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <config.h> #include <config.h>
#include <asiolink/io_asio_socket.h> #include <asiolink/io_asio_socket.h>
#include <asiolink/io_endpoint.h> #include <asiolink/io_endpoint.h>
#include <asiolink/io_service.h> #include <asiolink/io_service.h>
...@@ -51,7 +50,7 @@ public: ...@@ -51,7 +50,7 @@ public:
enum { enum {
MAX_SIZE = 4096 // Send and receive size MAX_SIZE = 4096 // Send and receive size
}; };
/// \brief Constructor from an ASIO UDP socket. /// \brief Constructor from an ASIO UDP socket.
/// ///
/// \param socket The ASIO representation of the UDP socket. It /// \param socket The ASIO representation of the UDP socket. It
...@@ -201,12 +200,23 @@ UDPSocket<C>::open(const IOEndpoint* endpoint, C&) { ...@@ -201,12 +200,23 @@ UDPSocket<C>::open(const IOEndpoint* endpoint, C&) {
isopen_ = true; isopen_ = true;
// Ensure it can send and receive 4K buffers. // Ensure it can send and receive 4K buffers.
socket_.set_option(asio::socket_base::send_buffer_size(MAX_SIZE));
socket_.set_option(asio::socket_base::receive_buffer_size(MAX_SIZE)); asio::ip::udp::socket::send_buffer_size snd_size;
; socket_.get_option(snd_size);
// Allow reuse of an existing port/address if (snd_size.value() < MAX_SIZE) {
socket_.set_option(asio::socket_base::reuse_address(true)); snd_size = MAX_SIZE;
socket_.set_option(snd_size);
}
asio::ip::udp::socket::receive_buffer_size rcv_size;
socket_.get_option(rcv_size);
if (rcv_size.value() < MAX_SIZE) {
rcv_size = MAX_SIZE;
socket_.set_option(rcv_size);
}
} }
// Nothing was done asynchronously, so tell the caller that.
return (false); return (false);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment