check (some) return values of setsockopt()
@@ -4936,10 +4936,19 @@ neat_connect(struct neat_he_candidate *candidate, uv_poll_cb callback_fx)
neat_log(ctx, NEAT_LOG_ERROR, "Failed to create he socket");
return -1;
}
- setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
- setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable));
+
+ if (setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < 0) {
+ neat_log(ctx, NEAT_LOG_DEBUG, "Call to setsockopt(SO_REUSEADDR) failed");
+ }
+
+ if (setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable)) < 0) {
+ neat_log(ctx, NEAT_LOG_DEBUG, "Call to setsockopt(SO_REUSEPORT) failed");
+ }
+
#if defined(SO_NOSIGPIPE)
- setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_NOSIGPIPE, &enable, sizeof(enable));
+ if (setsockopt(candidate->pollable_socket->fd, SOL_SOCKET, SO_NOSIGPIPE, &enable, sizeof(enable)) < 0) {
+ neat_log(ctx, NEAT_LOG_DEBUG, "Call to setsockopt(SO_NOSIGPIPE) failed");
+ }
#endif //defined(SO_NOSIGPIPE)
TAILQ_FOREACH(sockopt_ptr, &(candidate->sock_opts), next) {
@@ -5054,18 +5063,19 @@ neat_connect(struct neat_he_candidate *candidate, uv_poll_cb callback_fx)
switch (candidate->pollable_socket->stack) {
case NEAT_STACK_TCP:
- setsockopt(candidate->pollable_socket->fd,
- IPPROTO_TCP, TCP_NODELAY, &enable, sizeof(int));
+ if (setsockopt(candidate->pollable_socket->fd, IPPROTO_TCP, TCP_NODELAY, &enable, sizeof(enable) < 0)) {
+ neat_log(ctx, NEAT_LOG_DEBUG, "Call to setsockopt(TCP_NODELAY) failed");
+ }
#if defined(__FreeBSD__) && defined(FLOW_GROUPS)
group = candidate->pollable_socket->flow->group;
- if (setsockopt(candidate->pollable_socket->fd, IPPROTO_TCP, 8192 /* Group ID */, &group, sizeof(int)) != 0) {
+ if (setsockopt(candidate->pollable_socket->fd, IPPROTO_TCP, 8192 /* Group ID */, &group, sizeof(group)) != 0) {
neat_log(ctx, NEAT_LOG_DEBUG, "Unable to set flow group: %s", strerror(errno));
}
// Map the priority range to some integer range
prio = candidate->pollable_socket->flow->priority * 255;
- if (setsockopt(candidate->pollable_socket->fd, IPPROTO_TCP, 4096 /* Priority */, &prio, sizeof(int)) != 0) {
+ if (setsockopt(candidate->pollable_socket->fd, IPPROTO_TCP, 4096 /* Priority */, &prio, sizeof(prio)) != 0) {
neat_log(ctx, NEAT_LOG_DEBUG, "Unable to set flow priority: %s", strerror(errno));
}
#endif
