Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests and bug fixes for XmlRpcpp #1214

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,67 +36,4 @@

#include <stdexcept>

namespace XmlRpc {


//! An interface allowing custom handling of error message reporting.
class XmlRpcErrorHandler {
public:
virtual ~XmlRpcErrorHandler() { }

//! Returns a pointer to the currently installed error handling object.
static XmlRpcErrorHandler* getErrorHandler()
{ return _errorHandler; }

//! Specifies the error handler.
static void setErrorHandler(XmlRpcErrorHandler* eh)
{ _errorHandler = eh; }

//! Report an error. Custom error handlers should define this method.
virtual void error(const char* msg) = 0;

protected:
static XmlRpcErrorHandler* _errorHandler;
};

//! An interface allowing custom handling of informational message reporting.
class XmlRpcLogHandler {
public:
virtual ~XmlRpcLogHandler() { }

//! Returns a pointer to the currently installed message reporting object.
static XmlRpcLogHandler* getLogHandler()
{ return _logHandler; }

//! Specifies the message handler.
static void setLogHandler(XmlRpcLogHandler* lh)
{ _logHandler = lh; }

//! Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static int getVerbosity()
{ return _verbosity; }

//! Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static void setVerbosity(int v)
{ _verbosity = v; }

//! Output a message. Custom error handlers should define this method.
virtual void log(int level, const char* msg) = 0;

protected:
static XmlRpcLogHandler* _logHandler;
static int _verbosity;
};

//! Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity()
int getVerbosity();
//! Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level)
void setVerbosity(int level);


//! Version identifier
extern const char XMLRPC_VERSION[];

} // namespace XmlRpc

#endif // _XMLRPC_H_
12 changes: 8 additions & 4 deletions utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace XmlRpc {
virtual bool setupConnection();

virtual bool generateRequest(const char* method, XmlRpcValue const& params);
virtual std::string generateHeader(std::string const& body);
virtual std::string generateHeader(size_t length) const;
virtual bool writeRequest();
virtual bool readHeader();
virtual bool readResponse();
Expand All @@ -90,6 +90,8 @@ namespace XmlRpc {
enum ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE };
ClientConnectionState _connectionState;

static const char * connectionStateStr(ClientConnectionState state);

// Server location
std::string _host;
std::string _uri;
Expand All @@ -107,6 +109,8 @@ namespace XmlRpc {
// Number of times the client has attempted to send the request
int _sendAttempts;

// NOTE(austin): Having multiple variables that imply that the fd is valid
// smells funny.
// Number of bytes of the request that have been written to the socket so far
int _bytesWritten;

Expand All @@ -116,9 +120,9 @@ namespace XmlRpc {

// True if the server closed the connection
bool _eof;
// True if a fault response was returned by the server
bool _isFault;

// True if a fault response was returned by the server
bool _isFault;

// Number of bytes expected in the response body (parsed from response header)
int _contentLength;
Expand Down
2 changes: 1 addition & 1 deletion utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace XmlRpc {
enum EventType {
ReadableEvent = 1, //!< data available to read
WritableEvent = 2, //!< connected/data can be written without blocking
Exception = 4 //!< uh oh
Exception = 4 //!< out-of-band data has arrived
};

//! Monitor this source for the event types specified by the event mask
Expand Down
19 changes: 18 additions & 1 deletion utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef MAKEDEPEND
# include <map>
# include <string>
# include <vector>
# include <poll.h>
#endif

#include "xmlrpcpp/XmlRpcDispatch.h"
Expand Down Expand Up @@ -87,11 +89,14 @@ namespace XmlRpc {
protected:

//! Accept a client connection request
virtual void acceptConnection();
virtual unsigned acceptConnection();

//! Create a new connection object for processing requests from a specific client.
virtual XmlRpcServerConnection* createConnection(int socket);

//! Count number of free file descriptors
int countFreeFDs();

// Whether the introspection API is supported by this server
bool _introspectionEnabled;

Expand All @@ -108,6 +113,18 @@ namespace XmlRpc {

int _port;

// Flag indicating that accept had an error and needs to be retried.
bool _accept_error;
// If we cannot accept(), retry after this many seconds. Hopefully there
// will be more free file descriptors later.
const double ACCEPT_RETRY_INTERVAL_SEC = 1.0;
// Retry time for accept.
double _accept_retry_time_sec;

// Minimum number of free file descriptors before rejecting clients.
const int FREE_FD_BUFFER = 32;
// List of all file descriptors, used for counting open files.
std::vector<struct pollfd> pollfds;
};
} // namespace XmlRpc

Expand Down
4 changes: 2 additions & 2 deletions utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace XmlRpc {
static bool nbRead(int socket, std::string& s, bool *eof);

//! Write text to the specified socket. Returns false on error.
static bool nbWrite(int socket, std::string& s, int *bytesSoFar);
static bool nbWrite(int socket, const std::string& s, int *bytesSoFar);


// The next four methods are appropriate for servers.
Expand All @@ -62,7 +62,7 @@ namespace XmlRpc {


//! Connect a socket to a server (from a client)
static bool connect(int socket, std::string& host, int port);
static bool connect(int socket, const std::string& host, int port);


//! Returns last errno
Expand Down
57 changes: 57 additions & 0 deletions utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,63 @@

namespace XmlRpc {

//! An interface allowing custom handling of error message reporting.
class XmlRpcErrorHandler {
public:
virtual ~XmlRpcErrorHandler() { }

//! Returns a pointer to the currently installed error handling object.
static XmlRpcErrorHandler* getErrorHandler()
{ return _errorHandler; }

//! Specifies the error handler.
static void setErrorHandler(XmlRpcErrorHandler* eh)
{ _errorHandler = eh; }

//! Report an error. Custom error handlers should define this method.
virtual void error(const char* msg) = 0;

protected:
static XmlRpcErrorHandler* _errorHandler;
};

//! An interface allowing custom handling of informational message reporting.
class XmlRpcLogHandler {
public:
virtual ~XmlRpcLogHandler() { }

//! Returns a pointer to the currently installed message reporting object.
static XmlRpcLogHandler* getLogHandler()
{ return _logHandler; }

//! Specifies the message handler.
static void setLogHandler(XmlRpcLogHandler* lh)
{ _logHandler = lh; }

//! Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static int getVerbosity()
{ return _verbosity; }

//! Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
static void setVerbosity(int v)
{ _verbosity = v; }

//! Output a message. Custom error handlers should define this method.
virtual void log(int level, const char* msg) = 0;

protected:
static XmlRpcLogHandler* _logHandler;
static int _verbosity;
};

//! Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity()
int getVerbosity();
//! Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level)
void setVerbosity(int level);

//! Version identifier
extern const char XMLRPC_VERSION[];

//! Utilities for XML parsing, encoding, and decoding and message handlers.
class XMLRPCPP_DECL XmlRpcUtil {
public:
Expand Down
Loading