379f344b | 2014-10-04 12:52:55 | Timothy Pearson |
Modify bindAndListen to allow suppression of warnings when bind failures are expected as part of normal operation This relates to Bug 1988 |
||
M tdecore/ksock.cpp M tdecore/ksock.h |
||
diff --git a/tdecore/ksock.cpp b/tdecore/ksock.cpp index 9652646..57bfc26 100644 --- a/tdecore/ksock.cpp +++ b/tdecore/ksock.cpp @@ -20,6 +20,8 @@ * Boston, MA 02110-1301, USA. **/ +#define KSOCK_INTERNAL_C_COMPILATION 1 + #include <config.h> #include <sys/types.h> @@ -312,7 +314,7 @@ d->ks = ks; if (d->bind) - return bindAndListen(); + return bindAndListen(false); return true; } @@ -326,11 +328,11 @@ d->ks = ks; if (d->bind) - return bindAndListen(); + return bindAndListen(false); return true; } -bool TDEServerSocket::bindAndListen() +bool TDEServerSocket::bindAndListen(bool suppressFailureMessages) { if (d == NULL || d->ks == NULL) return false; @@ -339,7 +341,10 @@ int ret = d->ks->listen( SOMAXCONN ); if (ret < 0) { - kdWarning(170) << "Error listening on socket: " << ret << "\n"; + if (!suppressFailureMessages) + { + kdWarning(170) << "Error listening on socket for port " << d->ks->port() << ": " << ret << "\n"; + } delete d->ks; d->ks = NULL; sock = -1; @@ -432,4 +437,10 @@ // ::close( sock ); } +// DEPRECATED +bool TDEServerSocket::bindAndListen() +{ + return bindAndListen(false); +} + #include "ksock.moc" diff --git a/tdecore/ksock.h b/tdecore/ksock.h index cdf4ad1..422e69b 100644 --- a/tdecore/ksock.h +++ b/tdecore/ksock.h @@ -282,9 +282,12 @@ * Binds the socket and start listening. This should only be called * once when the constructor was called with _bind false. * On error the socket will be closed. + * @param suppressFailureMessages suppress warning messages generated if the socket cannot be opened. * @return true on success. false on error. + * @warning If suppressFailureMessages is TRUE future debugging may be made more difficult. Only set it + * if your application expects to bind to unavailable ports, e.g. while scanning for open ports in a range. */ - bool bindAndListen(); + bool bindAndListen(bool suppressFailureMessages = false); /** * Returns the file descriptor associated with the socket. @@ -339,6 +342,11 @@ int sock; private: + // DEPRECATED +#ifdef KSOCK_INTERNAL_C_COMPILATION + KDE_EXPORT bool bindAndListen(); +#endif // KSOCK_INTERNAL_C_COMPILATION + TDEServerSocket(const TDEServerSocket&); TDEServerSocket& operator=(const TDEServerSocket&); |
||
67d3c303 | 2014-10-04 12:53:48 | Timothy Pearson |
Merge branch 'master' of https://scm.trinitydesktop.org/scm/git/tdelibs |
||
M tdestyles/keramik/keramik.cpp |
||
diff --git a/tdestyles/keramik/keramik.cpp b/tdestyles/keramik/keramik.cpp index 08d6c59..ca8dea4 100644 --- a/tdestyles/keramik/keramik.cpp +++ b/tdestyles/keramik/keramik.cpp @@ -1377,6 +1377,7 @@ return true; } + return false; } void KeramikStyle::drawControl( TQ_ControlElement element, |