This is an automated email from the ASF dual-hosted git repository.
wkaras pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new c4d07a402 Remove unused functions in SocketManager namespace. (#9126)
c4d07a402 is described below
commit c4d07a402f6b48fe032444d9756ea47655f5559c
Author: Walt Karas <[email protected]>
AuthorDate: Tue Oct 11 15:58:33 2022 -0500
Remove unused functions in SocketManager namespace. (#9126)
Co-authored-by: Walt Karas <[email protected]>
---
iocore/eventsystem/I_SocketManager.h | 38 +----
iocore/eventsystem/P_UnixSocketManager.h | 280 -------------------------------
2 files changed, 3 insertions(+), 315 deletions(-)
diff --git a/iocore/eventsystem/I_SocketManager.h
b/iocore/eventsystem/I_SocketManager.h
index 9506c877a..718293f83 100644
--- a/iocore/eventsystem/I_SocketManager.h
+++ b/iocore/eventsystem/I_SocketManager.h
@@ -50,13 +50,11 @@
#endif
#endif
-#define DEFAULT_OPEN_MODE 0644
-
extern int net_config_poll_timeout;
#define SOCKET int
-/** Utility class for socket operations.
+/** Utility namespace for socket operations.
*/
namespace SocketManager
{
@@ -65,60 +63,30 @@ bool fastopen_supported();
// result is the socket or -errno
SOCKET socket(int domain = AF_INET, int type = SOCK_STREAM, int protocol = 0);
-SOCKET mc_socket(int domain = AF_INET, int type = SOCK_DGRAM, int protocol =
0, bool bNonBlocking = true);
+
+const mode_t DEFAULT_OPEN_MODE{0644};
// result is the fd or -errno
int open(const char *path, int oflag = O_RDWR | O_NDELAY | O_CREAT, mode_t
mode = DEFAULT_OPEN_MODE);
// result is the number of bytes or -errno
int64_t read(int fd, void *buf, int len, void *pOLP = nullptr);
-int64_t vector_io(int fd, struct iovec *vector, size_t count, int
read_request, void *pOLP = nullptr);
-int64_t readv(int fd, struct iovec *vector, size_t count);
-int64_t read_vector(int fd, struct iovec *vector, size_t count, void *pOLP =
nullptr);
-int64_t pread(int fd, void *buf, int len, off_t offset, char *tag = nullptr);
int recv(int s, void *buf, int len, int flags);
int recvfrom(int fd, void *buf, int size, int flags, struct sockaddr *addr,
socklen_t *addrlen);
int recvmsg(int fd, struct msghdr *m, int flags, void *pOLP = nullptr);
int64_t write(int fd, void *buf, int len, void *pOLP = nullptr);
-int64_t writev(int fd, struct iovec *vector, size_t count);
-int64_t write_vector(int fd, struct iovec *vector, size_t count, void *pOLP =
nullptr);
int64_t pwrite(int fd, void *buf, int len, off_t offset, char *tag = nullptr);
int send(int fd, void *buf, int len, int flags);
int sendto(int fd, void *buf, int len, int flags, struct sockaddr const *to,
int tolen);
int sendmsg(int fd, struct msghdr *m, int flags, void *pOLP = nullptr);
int64_t lseek(int fd, off_t offset, int whence);
-int fstat(int fd, struct stat *);
-int unlink(char *buf);
int fsync(int fildes);
-int ftruncate(int fildes, off_t length);
-int lockf(int fildes, int function, off_t size);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
-#if TS_USE_EPOLL
-int epoll_create(int size);
-int epoll_close(int eps);
-int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
-int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int
timeout = net_config_poll_timeout);
-#endif
-
-#if TS_USE_KQUEUE
-int kqueue();
-int kevent(int kq, const struct kevent *changelist, int nchanges, struct
kevent *eventlist, int nevents,
- const struct timespec *timeout);
-#endif
-
-#if TS_USE_PORT
-int port_create();
-int port_associate(int port, int fd, uintptr_t obj, int events, void *user);
-int port_dissociate(int port, int fd, uintptr_t obj);
-int port_getn(int port, port_event_t *list, uint_t max, uint_t *nget,
timespec_t *timeout);
-#endif
-
int shutdown(int s, int how);
-int dup(int s);
// result is the fd or -errno
int accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags);
diff --git a/iocore/eventsystem/P_UnixSocketManager.h
b/iocore/eventsystem/P_UnixSocketManager.h
index dc5c0c911..177a3704f 100644
--- a/iocore/eventsystem/P_UnixSocketManager.h
+++ b/iocore/eventsystem/P_UnixSocketManager.h
@@ -82,82 +82,6 @@ SocketManager::read(int fd, void *buf, int size, void * /*
pOLP ATS_UNUSED */)
return r;
}
-TS_INLINE int64_t
-SocketManager::pread(int fd, void *buf, int size, off_t offset, char * /* tag
ATS_UNUSED */)
-{
- int64_t r;
- do {
- r = ::pread(fd, buf, size, offset);
- if (r < 0) {
- r = -errno;
- }
- } while (r == -EINTR);
- return r;
-}
-
-TS_INLINE int64_t
-SocketManager::readv(int fd, struct iovec *vector, size_t count)
-{
- int64_t r;
- do {
- // coverity[tainted_data_argument]
- if (likely((r = ::readv(fd, vector, count)) >= 0)) {
- break;
- }
- r = -errno;
- } while (transient_error());
- return r;
-}
-
-TS_INLINE int64_t
-SocketManager::vector_io(int fd, struct iovec *vector, size_t count, int
read_request, void * /* pOLP ATS_UNUSED */)
-{
- const int max_iovecs_per_request = 16;
- int n;
- int64_t r;
- int n_vec;
- int64_t bytes_xfered = 0;
-
- for (n_vec = 0; n_vec < (int)count; n_vec += max_iovecs_per_request) {
- int current_count = std::min(max_iovecs_per_request, ((int)(count -
n_vec)));
- do {
- // coverity[tainted_data_argument]
- r = read_request ? ::readv(fd, &vector[n_vec], current_count) :
::writev(fd, &vector[n_vec], current_count);
- if (likely(r >= 0)) {
- break;
- }
- r = -errno;
- } while (transient_error());
-
- if (r <= 0) {
- return (bytes_xfered && (r == -EAGAIN)) ? bytes_xfered : r;
- }
- bytes_xfered += r;
-
- if ((n_vec + max_iovecs_per_request) >= (int)count) {
- break;
- }
-
- // Compute bytes in current vector
- int64_t current_request_bytes = 0;
- for (n = n_vec; n < (n_vec + current_count); ++n) {
- current_request_bytes += vector[n].iov_len;
- }
-
- // Exit if we were unable to read all data in the current vector
- if (r != current_request_bytes) {
- break;
- }
- }
- return bytes_xfered;
-}
-
-TS_INLINE int64_t
-SocketManager::read_vector(int fd, struct iovec *vector, size_t count, void
*pOLP)
-{
- return vector_io(fd, vector, count, 1, pOLP);
-}
-
TS_INLINE int
SocketManager::recv(int fd, void *buf, int size, int flags)
{
@@ -220,25 +144,6 @@ SocketManager::pwrite(int fd, void *buf, int size, off_t
offset, char * /* tag A
return r;
}
-TS_INLINE int64_t
-SocketManager::writev(int fd, struct iovec *vector, size_t count)
-{
- int64_t r;
- do {
- if (likely((r = ::writev(fd, vector, count)) >= 0)) {
- break;
- }
- r = -errno;
- } while (transient_error());
- return r;
-}
-
-TS_INLINE int64_t
-SocketManager::write_vector(int fd, struct iovec *vector, size_t count, void
*pOLP)
-{
- return vector_io(fd, vector, count, 0, pOLP);
-}
-
TS_INLINE int
SocketManager::send(int fd, void *buf, int size, int flags)
{
@@ -287,31 +192,6 @@ SocketManager::lseek(int fd, off_t offset, int whence)
return r;
}
-TS_INLINE int
-SocketManager::fstat(int fd, struct stat *buf)
-{
- int r;
- do {
- if ((r = ::fstat(fd, buf)) >= 0) {
- break;
- }
- r = -errno;
- } while (transient_error());
- return r;
-}
-
-TS_INLINE int
-SocketManager::unlink(char *buf)
-{
- int r;
- do {
- if ((r = ::unlink(buf)) < 0) {
- r = -errno;
- }
- } while (r == -EINTR);
- return r;
-}
-
TS_INLINE int
SocketManager::fsync(int fildes)
{
@@ -324,18 +204,6 @@ SocketManager::fsync(int fildes)
return r;
}
-TS_INLINE int
-SocketManager::ftruncate(int fildes, off_t length)
-{
- int r;
- do {
- if ((r = ::ftruncate(fildes, length)) < 0) {
- r = -errno;
- }
- } while (r == -EINTR);
- return r;
-}
-
TS_INLINE int
SocketManager::poll(struct pollfd *fds, unsigned long nfds, int timeout)
{
@@ -349,129 +217,6 @@ SocketManager::poll(struct pollfd *fds, unsigned long
nfds, int timeout)
return r;
}
-#if TS_USE_EPOLL
-TS_INLINE int
-SocketManager::epoll_create(int size)
-{
- int r;
- if (size <= 0) {
- size = EPOLL_MAX_DESCRIPTOR_SIZE;
- }
- do {
- if (likely((r = ::epoll_create(size)) >= 0)) {
- break;
- }
- r = -errno;
- } while (errno == -EINTR);
- return r;
-}
-
-TS_INLINE int
-SocketManager::epoll_close(int epfd)
-{
- int r = 0;
- if (likely(epfd >= 0)) {
- do {
- if (likely((r = ::close(epfd)) == 0)) {
- break;
- }
- r = -errno;
- } while (errno == -EINTR);
- }
- return r;
-}
-
-TS_INLINE int
-SocketManager::epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
-{
- int r;
- do {
- if (likely((r = ::epoll_ctl(epfd, op, fd, event)) == 0)) {
- break;
- }
- r = -errno;
- } while (errno == -EINTR);
- return r;
-}
-
-TS_INLINE int
-SocketManager::epoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout)
-{
- int r;
- do {
- if ((r = ::epoll_wait(epfd, events, maxevents, timeout)) >= 0) {
- break;
- }
- r = -errno;
- } while (errno == -EINTR);
- return r;
-}
-
-#endif /* TS_USE_EPOLL */
-
-#if TS_USE_KQUEUE
-TS_INLINE int
-SocketManager::kqueue()
-{
- return ::kqueue();
-}
-
-TS_INLINE int
-SocketManager::kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
- const struct timespec *timeout)
-{
- int r;
- do {
- r = ::kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
- if (likely(r >= 0)) {
- break;
- }
- r = -errno;
- } while (errno == -EINTR);
- return r;
-}
-#endif /* TS_USE_KQUEUE */
-
-#if TS_USE_PORT
-TS_INLINE int
-SocketManager::port_create()
-{
- return ::port_create();
-}
-
-TS_INLINE int
-SocketManager::port_associate(int port, int source, uintptr_t obj, int events,
void *user)
-{
- int r;
- r = ::port_associate(port, source, obj, events, user);
- if (r < 0)
- r = -errno;
- return r;
-}
-
-TS_INLINE int
-SocketManager::port_dissociate(int port, int source, uintptr_t obj)
-{
- int r;
- r = ::port_dissociate(port, source, obj);
- if (r < 0)
- r = -errno;
- return r;
-}
-
-TS_INLINE int
-SocketManager::port_getn(int port, port_event_t *list, uint_t max, uint_t
*nget, timespec_t *timeout)
-{
- int r;
- do {
- if ((r = ::port_getn(port, list, max, nget, timeout)) >= 0)
- break;
- r = -errno;
- } while (errno == -EINTR); // TODO: possible EAGAIN(undocumented)
- return r;
-}
-#endif /* TS_USE_PORT */
-
TS_INLINE int
SocketManager::get_sndbuf_size(int s)
{
@@ -529,28 +274,3 @@ SocketManager::shutdown(int s, int how)
} while (res == -EINTR);
return res;
}
-
-TS_INLINE int
-SocketManager::lockf(int s, int f, off_t size)
-{
- int res;
- do {
- if ((res = ::lockf(s, f, size)) < 0) {
- res = -errno;
- }
- } while (res == -EINTR);
- return res;
-}
-
-TS_INLINE int
-SocketManager::dup(int s)
-{
- int res;
- do {
- if ((res = ::dup(s)) >= 0) {
- break;
- }
- res = -errno;
- } while (res == -EINTR);
- return res;
-}