mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-27 19:10:22 +01:00
Problem: Bad style in tcp.hpp/cpp
Solution: Add spaces between function name and parentheses.
This commit is contained in:
38
src/tcp.cpp
38
src/tcp.cpp
@@ -53,7 +53,7 @@ int zmq::tune_tcp_socket (fd_t s_)
|
|||||||
int nodelay = 1;
|
int nodelay = 1;
|
||||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY, (char*) &nodelay,
|
int rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELAY, (char*) &nodelay,
|
||||||
sizeof (int));
|
sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ int zmq::tune_tcp_socket (fd_t s_)
|
|||||||
int nodelack = 1;
|
int nodelack = 1;
|
||||||
rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELACK, (char*) &nodelack,
|
rc = setsockopt (s_, IPPROTO_TCP, TCP_NODELACK, (char*) &nodelack,
|
||||||
sizeof (int));
|
sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ int zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_)
|
|||||||
{
|
{
|
||||||
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_SNDBUF,
|
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_SNDBUF,
|
||||||
(char*) &bufsize_, sizeof bufsize_);
|
(char*) &bufsize_, sizeof bufsize_);
|
||||||
tcp_assert_tuning_error(sockfd_, rc);
|
tcp_assert_tuning_error (sockfd_, rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ int zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_)
|
|||||||
{
|
{
|
||||||
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
|
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
|
||||||
(char *) &bufsize_, sizeof bufsize_);
|
(char *) &bufsize_, sizeof bufsize_);
|
||||||
tcp_assert_tuning_error(sockfd_, rc);
|
tcp_assert_tuning_error (sockfd_, rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,9 +106,9 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
keepalive_opts.keepaliveinterval = keepalive_intvl_ != -1 ?
|
keepalive_opts.keepaliveinterval = keepalive_intvl_ != -1 ?
|
||||||
keepalive_intvl_ * 1000 : 1000;
|
keepalive_intvl_ * 1000 : 1000;
|
||||||
DWORD num_bytes_returned;
|
DWORD num_bytes_returned;
|
||||||
int rc = WSAIoctl(s_, SIO_KEEPALIVE_VALS, &keepalive_opts,
|
int rc = WSAIoctl (s_, SIO_KEEPALIVE_VALS, &keepalive_opts,
|
||||||
sizeof(keepalive_opts), NULL, 0, &num_bytes_returned, NULL, NULL);
|
sizeof (keepalive_opts), NULL, 0, &num_bytes_returned, NULL, NULL);
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc == SOCKET_ERROR)
|
if (rc == SOCKET_ERROR)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
if (keepalive_ != -1) {
|
if (keepalive_ != -1) {
|
||||||
int rc = setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE,
|
int rc = setsockopt (s_, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
(char*) &keepalive_, sizeof (int));
|
(char*) &keepalive_, sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
if (keepalive_cnt_ != -1) {
|
if (keepalive_cnt_ != -1) {
|
||||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPCNT,
|
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPCNT,
|
||||||
&keepalive_cnt_, sizeof (int));
|
&keepalive_cnt_, sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
if (keepalive_idle_ != -1) {
|
if (keepalive_idle_ != -1) {
|
||||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPIDLE,
|
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPIDLE,
|
||||||
&keepalive_idle_, sizeof (int));
|
&keepalive_idle_, sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
if (keepalive_idle_ != -1) {
|
if (keepalive_idle_ != -1) {
|
||||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPALIVE,
|
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPALIVE,
|
||||||
&keepalive_idle_, sizeof (int));
|
&keepalive_idle_, sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ int zmq::tune_tcp_keepalives (fd_t s_, int keepalive_, int keepalive_cnt_,
|
|||||||
if (keepalive_intvl_ != -1) {
|
if (keepalive_intvl_ != -1) {
|
||||||
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPINTVL,
|
int rc = setsockopt (s_, IPPROTO_TCP, TCP_KEEPINTVL,
|
||||||
&keepalive_intvl_, sizeof (int));
|
&keepalive_intvl_, sizeof (int));
|
||||||
tcp_assert_tuning_error(s_, rc);
|
tcp_assert_tuning_error (s_, rc);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -178,14 +178,14 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
|
|||||||
// msdn says it's supported in >= Vista, >= Windows Server 2003
|
// msdn says it's supported in >= Vista, >= Windows Server 2003
|
||||||
timeout_ /= 1000; // in seconds
|
timeout_ /= 1000; // in seconds
|
||||||
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT, (char*) &timeout_,
|
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_MAXRT, (char*) &timeout_,
|
||||||
sizeof(timeout_));
|
sizeof (timeout_));
|
||||||
tcp_assert_tuning_error(sockfd_, rc);
|
tcp_assert_tuning_error (sockfd_, rc);
|
||||||
return rc;
|
return rc;
|
||||||
// FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
|
// FIXME: should be ZMQ_HAVE_TCP_USER_TIMEOUT
|
||||||
#elif defined (TCP_USER_TIMEOUT)
|
#elif defined (TCP_USER_TIMEOUT)
|
||||||
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout_,
|
int rc = setsockopt (sockfd_, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout_,
|
||||||
sizeof(timeout_));
|
sizeof (timeout_));
|
||||||
tcp_assert_tuning_error(sockfd_, rc);
|
tcp_assert_tuning_error (sockfd_, rc);
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@@ -199,7 +199,7 @@ int zmq::tune_tcp_maxrt (fd_t sockfd_, int timeout_)
|
|||||||
|
|
||||||
// If not a single byte can be written to the socket in non-blocking mode
|
// If not a single byte can be written to the socket in non-blocking mode
|
||||||
// we'll get an error (this may happen during the speculative write).
|
// we'll get an error (this may happen during the speculative write).
|
||||||
const int last_error = WSAGetLastError();
|
const int last_error = WSAGetLastError ();
|
||||||
if (nbytes == SOCKET_ERROR && last_error == WSAEWOULDBLOCK)
|
if (nbytes == SOCKET_ERROR && last_error == WSAEWOULDBLOCK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
|
|||||||
// If not a single byte can be read from the socket in non-blocking mode
|
// If not a single byte can be read from the socket in non-blocking mode
|
||||||
// we'll get an error (this may happen during the speculative read).
|
// we'll get an error (this may happen during the speculative read).
|
||||||
if (rc == SOCKET_ERROR) {
|
if (rc == SOCKET_ERROR) {
|
||||||
const int last_error = WSAGetLastError();
|
const int last_error = WSAGetLastError ();
|
||||||
if (last_error == WSAEWOULDBLOCK) {
|
if (last_error == WSAEWOULDBLOCK) {
|
||||||
errno = EAGAIN;
|
errno = EAGAIN;
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ int zmq::tcp_read (fd_t s_, void *data_, size_t size_)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::tcp_assert_tuning_error(zmq::fd_t s_, int rc_)
|
void zmq::tcp_assert_tuning_error (zmq::fd_t s_, int rc_)
|
||||||
{
|
{
|
||||||
if (rc_ == 0)
|
if (rc_ == 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace zmq
|
|||||||
|
|
||||||
// Asserts that an internal error did not occur. Does not assert
|
// Asserts that an internal error did not occur. Does not assert
|
||||||
// on network errors such as reset or aborted connections.
|
// on network errors such as reset or aborted connections.
|
||||||
void tcp_assert_tuning_error(fd_t s_, int rc_);
|
void tcp_assert_tuning_error (fd_t s_, int rc_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user