--- a/src/utils/netcon.h
+++ b/src/utils/netcon.h
@@ -36,7 +36,7 @@
/// endpoints. Netcon also has server-side static code to handle a set
/// of client connections in parallel. This should be moved to a
/// friend class.
-///
+///
/// The client data transfer class can also be used for
/// timeout-protected/asynchronous io using a given fd (ie a pipe
/// descriptor)
@@ -48,25 +48,25 @@
class Netcon {
public:
- enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE=0x2};
- Netcon()
- : m_peer(0), m_fd(-1), m_ownfd(true), m_didtimo(0), m_wantedEvents(0),
- m_loop(0) {
+ enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE = 0x2};
+ Netcon()
+ : m_peer(0), m_fd(-1), m_ownfd(true), m_didtimo(0), m_wantedEvents(0),
+ m_loop(0) {
}
virtual ~Netcon();
- /// Remember whom we're talking to. We let external code do this because
+ /// Remember whom we're talking to. We let external code do this because
/// the application may have a non-dns method to find the peer name.
virtual void setpeer(const char *hostname);
/// Retrieve the peer's hostname. Only works if it was set before !
virtual const char *getpeer() {
- return m_peer ? (const char *)m_peer : "none";
- }
- /// Set or reset the TCP_NODELAY option.
- virtual int settcpnodelay(int on = 1);
+ return m_peer ? (const char *)m_peer : "none";
+ }
+ /// Set or reset the TCP_NODELAY option.
+ virtual int settcpnodelay(int on = 1);
/// Did the last receive() call time out ? Resets the flag.
virtual int timedout() {
- int s = m_didtimo;
- m_didtimo = 0;
+ int s = m_didtimo;
+ m_didtimo = 0;
return s;
}
/// Return string version of last syscall error
@@ -111,7 +111,7 @@
static int select1(int fd, int secs, int writing = 0);
protected:
- char *m_peer; // Name of the connected host
+ char *m_peer; // Name of the connected host
int m_fd;
bool m_ownfd;
int m_didtimo;
@@ -127,7 +127,7 @@
};
-/// The selectloop interface is used to implement parallel servers.
+/// The selectloop interface is used to implement parallel servers.
// The select loop mechanism allows several netcons to be used for io
// in a program without blocking as long as there is data to be read
// or written. In a multithread program which is also using select, it
@@ -136,13 +136,13 @@
class SelectLoop {
public:
SelectLoop()
- : m_selectloopDoReturn(false), m_selectloopReturnValue(0),
- m_placetostart(0),
- m_periodichandler(0), m_periodicparam(0), m_periodicmillis(0) {
+ : m_selectloopDoReturn(false), m_selectloopReturnValue(0),
+ m_placetostart(0),
+ m_periodichandler(0), m_periodicparam(0), m_periodicmillis(0) {
}
/// Loop waiting for events on the connections and call the
- /// cando() method on the object when something happens (this will in
+ /// cando() method on the object when something happens (this will in
/// turn typically call the app callback set on the netcon). Possibly
/// call the periodic handler (if set) at regular intervals.
/// @return -1 for error. 0 if no descriptors left for i/o. 1 for periodic
@@ -151,8 +151,8 @@
/// Call from data handler: make selectloop return the param value
void loopReturn(int value) {
- m_selectloopDoReturn = true;
- m_selectloopReturnValue = value;
+ m_selectloopDoReturn = true;
+ m_selectloopReturnValue = value;
}
/// Add a connection to be monitored (this will usually be called
/// from the server's listen connection's accept callback)
@@ -162,11 +162,11 @@
int remselcon(NetconP con);
/// Set a function to be called periodically, or a time before return.
- /// @param handler the function to be called.
+ /// @param handler the function to be called.
/// - if it is 0, selectloop() will return after ms mS (and can be called
/// again
- /// - if it is not 0, it will be called at ms mS intervals. If its return
- /// value is <= 0, selectloop will return.
+ /// - if it is not 0, it will be called at ms mS intervals. If its return
+ /// value is <= 0, selectloop will return.
/// @param clp client data to be passed to handler at every call.
/// @param ms milliseconds interval between handler calls or
/// before return. Set to 0 for no periodic handler.
@@ -195,12 +195,12 @@
///////////////////////
class NetconData;
-/// Class for the application callback routine (when in selectloop).
+/// Class for the application callback routine (when in selectloop).
///
/// This is set by the app on the NetconData by calling
/// setcallback(). It is then called from the NetconData's cando()
/// routine, itself called by selectloop.
-///
+///
/// It would be nicer to override cando() in a subclass instead of
/// setting a callback, but this can't be done conveniently because
/// accept() always creates a base NetconData (another approach would
@@ -229,7 +229,7 @@
/// Read from the connection
/// @param buf the data buffer
- /// @param cnt the number of bytes we should try to read (but we return
+ /// @param cnt the number of bytes we should try to read (but we return
/// as soon as we get data)
/// @param timeo maximum number of seconds we should be waiting for data.
/// @return the count of bytes actually read. 0 for timeout (call
@@ -251,16 +251,16 @@
}
private:
- char *m_buf; // Buffer. Only used when doing getline()s
+ char *m_buf; // Buffer. Only used when doing getline()s
char *m_bufbase; // Pointer to current 1st byte of useful data
- int m_bufbytes; // Bytes of data.
- int m_bufsize; // Total buffer size
+ int m_bufbytes; // Bytes of data.
+ int m_bufsize; // Total buffer size
STD_SHARED_PTR<NetconWorker> m_user;
virtual int cando(Netcon::Event reason); // Selectloop slot
};
/// Network endpoint, client side.
-class NetconCli : public NetconData {
+class NetconCli : public NetconData {
public:
NetconCli(int silent = 0) {
m_silentconnectfailure = silent;
@@ -276,7 +276,7 @@
/// AF_UNIX service. serv is ignored in this case.
int openconn(const char *host, unsigned int port, int timeo = -1);
- /// Reuse existing fd.
+ /// Reuse existing fd.
/// We DONT take ownership of the fd, and do no closin' EVEN on an
/// explicit closeconn() or setconn() (use getfd(), close,
/// setconn(-1) if you need to really close the fd and have no
@@ -289,7 +289,7 @@
}
private:
- int m_silentconnectfailure; // No logging of connection failures if set
+ int m_silentconnectfailure; // No logging of connection failures if set
};
class NetconServCon;
@@ -316,9 +316,9 @@
public:
NetconServLis() {
#ifdef NETCON_ACCESSCONTROL
- permsinit = 0;
- okaddrs.len = okmasks.len = 0;
- okaddrs.intarray = okmasks.intarray = 0;
+ permsinit = 0;
+ okaddrs.len = okmasks.len = 0;
+ okaddrs.intarray = okmasks.intarray = 0;
#endif /* NETCON_ACCESSCONTROL */
}
~NetconServLis();
@@ -327,7 +327,7 @@
int openservice(const char *serv, int backlog = 10);
/// Open service by port number.
int openservice(int port, int backlog = 10);
- /// Wait for incoming connection. Returned connected Netcon
+ /// Wait for incoming connection. Returned connected Netcon
NetconServCon *accept(int timeo = -1);
protected:
@@ -337,7 +337,7 @@
virtual int cando(Netcon::Event reason);
// Empty if port was numeric, else service name or socket path
- std::string m_serv;
+ std::string m_serv;
private:
#ifdef NETCON_ACCESSCONTROL
@@ -353,16 +353,16 @@
/// Server-side accepted client connection. The only specific code
/// allows closing the listening endpoint in the child process (in the
/// case of a forking server)
-class NetconServCon : public NetconData {
-public:
- NetconServCon(int newfd, Netcon* lis = 0) {
- m_liscon = lis;
- m_fd = newfd;
+class NetconServCon : public NetconData {
+public:
+ NetconServCon(int newfd, Netcon* lis = 0) {
+ m_liscon = lis;
+ m_fd = newfd;
}
/// This is for forked servers that want to get rid of the main socket
void closeLisCon() {
- if (m_liscon) {
- m_liscon->closeconn();
+ if (m_liscon) {
+ m_liscon->closeconn();
}
}
private: