summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2019-02-12 12:16:40 +0100
committerJan Holesovsky <kendy@collabora.com>2019-02-12 12:20:11 +0100
commitf76b36193df424e9718bb25c589c6efd476774cc (patch)
tree48bb6f13ab7d9f5158da81f91ffe5c5712314e93 /net
parentd15fc93f312882037f9991335b945f8c3676a43d (diff)
android: #if(n)def MOBILEAPP -> #if (!)MOBILEAPP for better reliability.
Change-Id: I5f9c9420b6c83601db1c8fdba4ae5a10b17b2107
Diffstat (limited to 'net')
-rw-r--r--net/FakeSocket.hpp2
-rw-r--r--net/ServerSocket.hpp6
-rw-r--r--net/Socket.cpp16
-rw-r--r--net/Socket.hpp30
-rw-r--r--net/WebSocketHandler.hpp22
5 files changed, 38 insertions, 38 deletions
diff --git a/net/FakeSocket.hpp b/net/FakeSocket.hpp
index 11470f6da..8ad1d48f1 100644
--- a/net/FakeSocket.hpp
+++ b/net/FakeSocket.hpp
@@ -10,7 +10,7 @@
#ifndef INCLUDED_FAKESOCKET_H
#define INCLUDED_FAKESOCKET_H
-#ifdef MOBILEAPP
+#if MOBILEAPP
#include <string>
diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp
index 7606e86ce..eb0bb46ca 100644
--- a/net/ServerSocket.hpp
+++ b/net/ServerSocket.hpp
@@ -47,7 +47,7 @@ public:
/// Returns true on success only.
bool listen(const int backlog = 64)
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const int rc = ::listen(getFD(), backlog);
#else
const int rc = fakeSocketListen(getFD());
@@ -64,7 +64,7 @@ public:
{
// Accept a connection (if any) and set it to non-blocking.
// There still need the client's address to filter request from POST(call from REST) here.
-#ifndef MOBILEAPP
+#if !MOBILEAPP
struct sockaddr_in6 clientInfo;
socklen_t addrlen = sizeof(clientInfo);
const int rc = ::accept4(getFD(), (struct sockaddr *)&clientInfo, &addrlen, SOCK_NONBLOCK);
@@ -77,7 +77,7 @@ public:
// Create a socket object using the factory.
if (rc != -1)
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
char addrstr[INET6_ADDRSTRLEN];
const void *inAddr;
diff --git a/net/Socket.cpp b/net/Socket.cpp
index 2d35f6b02..8d2cd3533 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -28,7 +28,7 @@
#include <SigUtil.hpp>
#include "ServerSocket.hpp"
-#ifndef MOBILEAPP
+#if !MOBILEAPP
#include "SslSocket.hpp"
#endif
#include "WebSocketHandler.hpp"
@@ -39,7 +39,7 @@ std::atomic<bool> Socket::InhibitThreadChecks(false);
int Socket::createSocket(Socket::Type type)
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
int domain = type == Type::IPv4 ? AF_INET : AF_INET6;
return socket(domain, SOCK_STREAM | SOCK_NONBLOCK, 0);
#else
@@ -71,7 +71,7 @@ SocketPoll::SocketPoll(const std::string& threadName)
{
// Create the wakeup fd.
if (
-#ifndef MOBILEAPP
+#if !MOBILEAPP
::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1
#else
fakeSocketPipe2(_wakeup) == -1
@@ -99,7 +99,7 @@ SocketPoll::~SocketPoll()
getWakeupsArray().erase(it);
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
::close(_wakeup[0]);
::close(_wakeup[1]);
#else
@@ -190,14 +190,14 @@ void SocketPoll::wakeupWorld()
}
void SocketPoll::insertNewWebSocketSync(
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const Poco::URI &uri,
#else
int peerSocket,
#endif
const std::shared_ptr<SocketHandlerInterface>& websocketHandler)
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
LOG_INF("Connecting to " << uri.getHost() << " : " << uri.getPort() << " : " << uri.getPath());
// FIXME: put this in a ClientSocket class ?
@@ -380,7 +380,7 @@ void SocketPoll::dumpState(std::ostream& os)
/// Returns true on success only.
bool ServerSocket::bind(Type type, int port)
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
// Enable address reuse to avoid stalling after
// recycling, when previous socket is TIME_WAIT.
//TODO: Might be worth refactoring out.
@@ -430,7 +430,7 @@ bool ServerSocket::bind(Type type, int port)
#endif
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
bool StreamSocket::parseHeader(const char *clientName,
Poco::MemoryInputStream &message,
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 531f5358a..e27dc6df0 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -116,7 +116,7 @@ public:
LOG_TRC("#" << getFD() << " Socket dtor.");
// Doesn't block on sockets; no error handling needed.
-#ifndef MOBILEAPP
+#if !MOBILEAPP
::close(_fd);
#else
fakeSocketClose(_fd);
@@ -144,7 +144,7 @@ public:
virtual void shutdown()
{
LOG_TRC("#" << _fd << ": socket shutdown RDWR.");
-#ifndef MOBILEAPP
+#if !MOBILEAPP
::shutdown(_fd, SHUT_RDWR);
#else
fakeSocketShutdown(_fd);
@@ -165,14 +165,14 @@ public:
/// manage latency issues around packet aggregation
void setNoDelay()
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const int val = 1;
::setsockopt(_fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &val, sizeof(val));
#endif
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
/// Sets the kernel socket send buffer in size bytes.
/// Note: TCP will allocate twice this size for admin purposes,
/// so a subsequent call to getSendBufferSize will return
@@ -218,14 +218,14 @@ public:
/// Gets our fast cache of the socket buffer size
int getSendBufferSize() const
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
return _sendBufferSize;
#else
return INT_MAX; // We want to always send a single record in one go
#endif
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
/// Sets the receive buffer size in bytes.
/// Note: TCP will allocate twice this size for admin purposes,
/// so a subsequent call to getReceieveBufferSize will return
@@ -318,7 +318,7 @@ protected:
_owner = std::this_thread::get_id();
LOG_DBG("#" << _fd << " Thread affinity set to " << Log::to_string(_owner) << ".");
-#ifndef MOBILEAPP
+#if !MOBILEAPP
#if ENABLE_DEBUG
if (std::getenv("LOOL_ZERO_BUFFER_SIZE"))
{
@@ -401,7 +401,7 @@ public:
{
LOG_DBG("Stopping " << _name << ".");
_stop = true;
-#ifdef MOBILEAPP
+#if MOBILEAPP
{
// We don't want to risk some callbacks in _newCallbacks being invoked when we start
// running a thread for this SocketPoll again.
@@ -485,7 +485,7 @@ public:
int rc;
do
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
rc = ::poll(&_pollFds[0], size + 1, std::max(timeoutMaxMs,0));
#else
LOG_TRC("SocketPoll Poll");
@@ -504,7 +504,7 @@ public:
std::lock_guard<std::mutex> lock(_mutex);
// Clear the data.
-#ifndef MOBILEAPP
+#if !MOBILEAPP
int dump = ::read(_wakeup[0], &dump, sizeof(dump));
#else
LOG_TRC("Wakeup pipe read");
@@ -588,7 +588,7 @@ public:
// wakeup the main-loop.
int rc;
do {
-#ifndef MOBILEAPP
+#if !MOBILEAPP
rc = ::write(fd, "w", 1);
#else
#if 0
@@ -645,7 +645,7 @@ public:
/// Inserts a new websocket to be polled.
/// NOTE: The DNS lookup is synchronous.
void insertNewWebSocketSync(
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const Poco::URI &uri,
#else
int peerSocket,
@@ -864,7 +864,7 @@ public:
{
assertCorrectThread();
-#ifndef MOBILEAPP
+#if !MOBILEAPP
// SSL decodes blocks of 16Kb, so for efficiency we use the same.
char buf[16 * 1024];
ssize_t len;
@@ -1081,7 +1081,7 @@ protected:
virtual int readData(char* buf, int len)
{
assertCorrectThread();
-#ifndef MOBILEAPP
+#if !MOBILEAPP
return ::read(getFD(), buf, len);
#else
return fakeSocketRead(getFD(), buf, len);
@@ -1092,7 +1092,7 @@ protected:
virtual int writeData(const char* buf, const int len)
{
assertCorrectThread();
-#ifndef MOBILEAPP
+#if !MOBILEAPP
return ::write(getFD(), buf, len);
#else
struct pollfd p;
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index a037cb6b5..88350df1e 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -113,7 +113,7 @@ public:
static_cast<unsigned>(statusCode) << ", message: " << statusMessage);
_shuttingDown = true;
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const size_t len = statusMessage.size();
std::vector<char> buf(2 + len);
buf[0] = ((((int)statusCode) >> 8) & 0xff);
@@ -136,7 +136,7 @@ public:
if (len == 0)
return false; // avoid logging.
-#ifndef MOBILEAPP
+#if !MOBILEAPP
if (len < 2) // partial read
{
LOG_TRC("#" << socket->getFD() << ": Still incomplete WebSocket message, have " << len << " bytes");
@@ -215,7 +215,7 @@ public:
socket->getInBuffer().erase(socket->getInBuffer().begin(), socket->getInBuffer().begin() + headerLen + payloadLen);
-#ifndef MOBILEAPP
+#if !MOBILEAPP
// FIXME: fin, aggregating payloads into _wsPayload etc.
LOG_TRC("#" << socket->getFD() << ": Incoming WebSocket message code " << static_cast<unsigned>(code) <<
@@ -270,7 +270,7 @@ public:
#endif
-#ifndef MOBILEAPP
+#if !MOBILEAPP
if (doClose)
{
if (!_shuttingDown)
@@ -312,7 +312,7 @@ public:
std::shared_ptr<StreamSocket> socket = _socket.lock();
-#ifdef MOBILEAPP
+#if MOBILEAPP
// No separate "upgrade" is going on
if (socket != nullptr && !socket->isWebSocket())
socket->setWebSocket();
@@ -322,7 +322,7 @@ public:
{
LOG_ERR("No socket associated with WebSocketHandler " << this);
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
else if (_isClient && !socket->isWebSocket())
handleClientUpgrade();
#endif
@@ -345,7 +345,7 @@ public:
return POLLIN;
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
/// Send a ping message
void sendPingOrPong(std::chrono::steady_clock::time_point now,
const char* data, const size_t len,
@@ -388,7 +388,7 @@ public:
/// Do we need to handle a timeout ?
void checkTimeout(std::chrono::steady_clock::time_point now) override
{
-#ifndef MOBILEAPP
+#if !MOBILEAPP
if (_isClient)
return;
@@ -445,7 +445,7 @@ private:
socket->assertCorrectThread();
std::vector<char>& out = socket->getOutBuffer();
-#ifndef MOBILEAPP
+#if !MOBILEAPP
const size_t oldSize = out.size();
out.push_back(flags);
@@ -551,7 +551,7 @@ protected:
LOG_TRC("#" << socket->getFD() << ": Upgrading to WebSocket.");
assert(!socket->isWebSocket());
-#ifndef MOBILEAPP
+#if !MOBILEAPP
// create our websocket goodness ...
const int wsVersion = std::stoi(req.get("Sec-WebSocket-Version", "13"));
const std::string wsKey = req.get("Sec-WebSocket-Key", "");
@@ -579,7 +579,7 @@ protected:
setWebSocket();
}
-#ifndef MOBILEAPP
+#if !MOBILEAPP
// Handle incoming upgrade to full socket as client WS.
void handleClientUpgrade()
{