mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-27 14:23:02 +08:00
checkpoint. turned off nagle and send buffering. also
added test to skip clipboard conversion if a previous conversion from that owner failed.
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
# define INCL_WINSOCK_API_TYPEDEFS 0
|
||||
# include <winsock2.h>
|
||||
typedef int ssize_t;
|
||||
# if !defined(SOL_TCP)
|
||||
# define SOL_TCP IPPROTO_TCP
|
||||
# endif
|
||||
#else
|
||||
# define FAR
|
||||
# define PASCAL
|
||||
@@ -21,6 +24,9 @@ typedef int ssize_t;
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <errno.h>
|
||||
# if !defined(TCP_NODELAY) || !defined(SOL_TCP)
|
||||
# include <netinet/tcp.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// FIXME -- must handle htonl and ilk when defined as macros
|
||||
@@ -31,6 +37,7 @@ public:
|
||||
typedef SOCKET Socket;
|
||||
typedef struct sockaddr Address;
|
||||
typedef int AddressLength;
|
||||
typedef BOOL TCPNoDelayType;
|
||||
struct PollEntry {
|
||||
Socket fd;
|
||||
short events;
|
||||
@@ -47,6 +54,7 @@ public:
|
||||
typedef struct sockaddr Address;
|
||||
typedef socklen_t AddressLength;
|
||||
typedef struct pollfd PollEntry;
|
||||
typedef int TCPNoDelayType;
|
||||
enum {
|
||||
kPOLLIN = POLLIN,
|
||||
kPOLLOUT = POLLOUT,
|
||||
|
||||
@@ -128,6 +128,16 @@ void CTCPSocket::init()
|
||||
m_output = new CBufferedOutputStream(m_mutex,
|
||||
new TMethodJob<CTCPSocket>(
|
||||
this, &CTCPSocket::closeOutput));
|
||||
|
||||
// turn off Nagle algorithm. we send lots of very short messages
|
||||
// that should be sent without (much) delay. for example, the
|
||||
// mouse motion messages are much less useful if they're delayed.
|
||||
CNetwork::TCPNoDelayType flag = 1;
|
||||
CNetwork::setsockopt(m_fd, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag));
|
||||
|
||||
// don't buffer sends, we merge messages ourself
|
||||
int data = 0;
|
||||
CNetwork::setsockopt(m_fd, SOL_SOCKET, SO_SNDBUF, &data, sizeof(data));
|
||||
}
|
||||
|
||||
void CTCPSocket::ioThread(void*)
|
||||
|
||||
Reference in New Issue
Block a user