You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/04/04 16:56:31 UTC
[trafficserver] branch master updated: removes unused RecPipe class
This is an automated email from the ASF dual-hosted git repository.
bcall 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 bf6e14b removes unused RecPipe class
bf6e14b is described below
commit bf6e14b06340bae58dc7149a549069354c9c0de6
Author: Randall Meyer <ra...@yahoo.com>
AuthorDate: Tue Apr 3 15:40:20 2018 -0700
removes unused RecPipe class
---
lib/records/P_RecFile.h | 12 +---
lib/records/RecFile.cc | 177 ------------------------------------------------
2 files changed, 1 insertion(+), 188 deletions(-)
diff --git a/lib/records/P_RecFile.h b/lib/records/P_RecFile.h
index 25b0a49..032eab9 100644
--- a/lib/records/P_RecFile.h
+++ b/lib/records/P_RecFile.h
@@ -1,6 +1,6 @@
/** @file
- Private RecFile and RecPipe declarations
+ Private RecFile declarations
@section license License
@@ -44,14 +44,4 @@ int RecFileGetSize(RecHandle h_file);
int RecFileExists(const char *file);
int RecFileSync(RecHandle h_file);
-//-------------------------------------------------------------------------
-// RecPipe
-//-------------------------------------------------------------------------
-
-RecHandle RecPipeCreate(const char *base_path, const char *name);
-RecHandle RecPipeConnect(const char *base_path, const char *name);
-int RecPipeClose(RecHandle h_pipe);
-int RecPipeRead(RecHandle h_pipe, char *buf, int size);
-int RecPipeWrite(RecHandle h_pipe, char *buf, int size);
-
#endif
diff --git a/lib/records/RecFile.cc b/lib/records/RecFile.cc
index 8a0b5ef..466864b 100644
--- a/lib/records/RecFile.cc
+++ b/lib/records/RecFile.cc
@@ -128,180 +128,3 @@ RecFileExists(const char *file)
RecFileClose(h_file);
return REC_ERR_OKAY;
}
-
-//-------------------------------------------------------------------------
-// RecPipeCreate
-//-------------------------------------------------------------------------
-
-RecHandle
-RecPipeCreate(const char *base_path, const char *name)
-{
- RecHandle listenfd;
- RecHandle acceptfd;
- struct sockaddr_un servaddr;
- struct sockaddr_un cliaddr;
- int servaddr_len;
- socklen_t cliaddr_len;
-
- // first, let's disable SIGPIPE (move out later!)
- struct sigaction act, oact;
- act.sa_handler = SIG_IGN;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- act.sa_flags |= SA_RESTART;
- sigaction(SIGPIPE, &act, &oact);
-
- // construct a path/filename for the pipe
- char path[PATH_NAME_MAX];
- snprintf(path, sizeof(path), "%s/%s", base_path, name);
- if (strlen(path) > (sizeof(servaddr.sun_path) - 1)) {
- RecLog(DL_Warning, "[RecPipeCreate] Path name too long; exiting\n");
- return REC_HANDLE_INVALID;
- }
-
- unlink(path);
-
- if ((listenfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- RecLog(DL_Warning, "[RecPipeCreate] socket error\n");
- return REC_HANDLE_INVALID;
- }
- // set so that child process doesn't inherit our fd
- if (fcntl(listenfd, F_SETFD, FD_CLOEXEC) < 0) {
- RecLog(DL_Warning, "[RecPipeCreate] fcntl error\n");
- close(listenfd);
- return REC_HANDLE_INVALID;
- }
-
- memset(&servaddr, 0, sizeof(servaddr));
- servaddr.sun_family = AF_UNIX;
- ink_strlcpy(servaddr.sun_path, path, sizeof(servaddr.sun_path));
-
- int optval = 1;
- if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(int)) < 0) {
- RecLog(DL_Warning, "[RecPipeCreate] setsockopt error\n");
- close(listenfd);
- return REC_HANDLE_INVALID;
- }
-
- servaddr_len = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path);
- if ((bind(listenfd, (struct sockaddr *)&servaddr, servaddr_len)) < 0) {
- RecLog(DL_Warning, "[RecPipeCreate] bind error\n");
- close(listenfd);
- return REC_HANDLE_INVALID;
- }
- // listen, backlog of 1 (expecting only one client)
- if ((listen(listenfd, 1)) < 0) {
- RecLog(DL_Warning, "[RecPipeCreate] listen error\n");
- close(listenfd);
- return REC_HANDLE_INVALID;
- }
- // block until we get a connection from the other side
- cliaddr_len = sizeof(cliaddr);
- if ((acceptfd = accept(listenfd, (struct sockaddr *)&cliaddr, &cliaddr_len)) < 0) {
- close(listenfd);
- return REC_HANDLE_INVALID;
- }
-
- close(listenfd);
-
- return acceptfd;
-}
-
-//-------------------------------------------------------------------------
-// RecPipeConnect
-//-------------------------------------------------------------------------
-
-RecHandle
-RecPipeConnect(const char *base_path, const char *name)
-{
- RecHandle sockfd;
- struct sockaddr_un servaddr;
- int servaddr_len;
-
- // construct a path/filename for the pipe
- char path[PATH_NAME_MAX];
- snprintf(path, sizeof(path), "%s/%s", base_path, name);
- if (strlen(path) > (sizeof(servaddr.sun_path) - 1)) {
- RecLog(DL_Warning, "[RecPipeConnect] Path name too long\n");
- return REC_HANDLE_INVALID;
- }
- // Setup Connection to LocalManager */
- memset((char *)&servaddr, 0, sizeof(servaddr));
- servaddr.sun_family = AF_UNIX;
- ink_strlcpy(servaddr.sun_path, path, sizeof(servaddr.sun_path));
- servaddr_len = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path);
-
- if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- RecLog(DL_Warning, "[RecPipeConnect] socket error\n");
- return REC_HANDLE_INVALID;
- }
- // set so that child process doesn't inherit our fd
- if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) {
- RecLog(DL_Warning, "[RecPipeConnect] fcntl error\n");
- close(sockfd);
- return REC_HANDLE_INVALID;
- }
- // blocking connect
- if ((connect(sockfd, (struct sockaddr *)&servaddr, servaddr_len)) < 0) {
- RecLog(DL_Warning, "[RecPipeConnect] connect error\n");
- close(sockfd);
- return REC_HANDLE_INVALID;
- }
-
- return sockfd;
-}
-
-//-------------------------------------------------------------------------
-// RecPipeRead
-//-------------------------------------------------------------------------
-
-int
-RecPipeRead(RecHandle h_pipe, char *buf, int size)
-{
- int bytes_read = 0;
- int bytes_wanted = size;
- char *p = buf;
- while (bytes_wanted > 0) {
- bytes_read = read(h_pipe, p, bytes_wanted);
- if (bytes_read < 0) {
- // FIXME: something more intelligent please!
- return REC_ERR_FAIL;
- }
- bytes_wanted -= bytes_read;
- p += bytes_read;
- }
- return REC_ERR_OKAY;
-}
-
-//-------------------------------------------------------------------------
-// RecPipeWrite
-//-------------------------------------------------------------------------
-
-int
-RecPipeWrite(RecHandle h_pipe, char *buf, int size)
-{
- int bytes_written = 0;
- int bytes_to_write = size;
- char *p = buf;
- while (bytes_to_write > 0) {
- bytes_written = write(h_pipe, p, bytes_to_write);
- if (bytes_written < 0) {
- // FIXME: something more intelligent please!
- return REC_ERR_FAIL;
- }
- bytes_to_write -= bytes_written;
- p += bytes_written;
- }
-
- return REC_ERR_OKAY;
-}
-
-//-------------------------------------------------------------------------
-// RecPipeClose
-//-------------------------------------------------------------------------
-
-int
-RecPipeClose(RecHandle h_pipe)
-{
- return (close(h_pipe) == 0) ? REC_ERR_OKAY : REC_ERR_FAIL;
-}
--
To stop receiving notification emails like this one, please contact
bcall@apache.org.