/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/io/ShutdownSocketSet.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <chrono>
#include <folly/FileUtil.h>
#include <folly/Malloc.h>
+#include <folly/portability/Sockets.h>
namespace folly {
void ShutdownSocketSet::add(int fd) {
// Silently ignore any fds >= maxFd_, very unlikely
DCHECK_GE(fd, 0);
- if (fd >= maxFd_) {
+ if (size_t(fd) >= maxFd_) {
return;
}
void ShutdownSocketSet::remove(int fd) {
DCHECK_GE(fd, 0);
- if (fd >= maxFd_) {
+ if (size_t(fd) >= maxFd_) {
return;
}
int ShutdownSocketSet::close(int fd) {
DCHECK_GE(fd, 0);
- if (fd >= maxFd_) {
+ if (size_t(fd) >= maxFd_) {
return folly::closeNoInt(fd);
}
void ShutdownSocketSet::shutdown(int fd, bool abortive) {
DCHECK_GE(fd, 0);
- if (fd >= maxFd_) {
+ if (fd >= 0 && size_t(fd) >= maxFd_) {
doShutdown(fd, abortive);
return;
}