Browse Source

MT#55283 move helpers out of the way

Change-Id: I207d000c7c2cfca9c139518cc0111355b6414d60
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
09c4c84d03
3 changed files with 13 additions and 13 deletions
  1. +1
    -1
      daemon/graphite.c
  2. +10
    -0
      lib/socket.c
  3. +2
    -12
      lib/socket.h

+ 1
- 1
daemon/graphite.c View File

@ -69,7 +69,7 @@ static int connect_to_graphite_server(const endpoint_t *graphite_ep) {
rc = connect_socket_nb(&graphite_sock, SOCK_STREAM, graphite_ep); rc = connect_socket_nb(&graphite_sock, SOCK_STREAM, graphite_ep);
if (rtpe_config.graphite_timeout > 0 && !(graphite_sock.fd < 0)) { if (rtpe_config.graphite_timeout > 0 && !(graphite_sock.fd < 0)) {
usertimeout(graphite_sock.fd, rtpe_config.graphite_timeout * 1000);
usertimeout(&graphite_sock, rtpe_config.graphite_timeout * 1000);
} }
if (rc == -1) { if (rc == -1) {


+ 10
- 0
lib/socket.c View File

@ -735,6 +735,16 @@ static int __socket(socket_t *r, int type, sockfamily_t *fam) {
return 0; return 0;
} }
INLINE void reuseaddr(int fd) {
int one = 1;
// coverity[check_return : FALSE]
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
}
INLINE void ipv6only(int fd, int yn) {
// coverity[check_return : FALSE]
setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yn, sizeof(yn));
}
bool open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa) { bool open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa) {
sockfamily_t *fam; sockfamily_t *fam;


+ 2
- 12
lib/socket.h View File

@ -243,24 +243,14 @@ INLINE ssize_t socket_sendto_from(socket_t *s, const void *b, size_t l, const en
} while (0) } while (0)
/* XXX obsolete these? */
INLINE void usertimeout(int fd, unsigned int val) {
INLINE void usertimeout(socket_t *s, unsigned int val) {
// coverity[check_return : FALSE] // coverity[check_return : FALSE]
setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &val, sizeof(val));
setsockopt(s->fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &val, sizeof(val));
} }
INLINE void nonblock(int fd) { INLINE void nonblock(int fd) {
// coverity[check_return : FALSE] // coverity[check_return : FALSE]
fcntl(fd, F_SETFL, O_NONBLOCK); fcntl(fd, F_SETFL, O_NONBLOCK);
} }
INLINE void reuseaddr(int fd) {
int one = 1;
// coverity[check_return : FALSE]
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
}
INLINE void ipv6only(int fd, int yn) {
// coverity[check_return : FALSE]
setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yn, sizeof(yn));
}
INLINE int socket_cpu_affinity(socket_t *s, int cpu) { INLINE int socket_cpu_affinity(socket_t *s, int cpu) {
#ifndef SO_INCOMING_CPU #ifndef SO_INCOMING_CPU
errno = ENOTSUP; errno = ENOTSUP;


Loading…
Cancel
Save