You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/01/15 21:10:57 UTC
[2/6] git commit: cleanup: get rid of ink_killall implementation
cleanup: get rid of ink_killall implementation
After ripping it out from the code, remove it the Linux-specific,
/proc parsing ink_killall implementation.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ce7df45b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ce7df45b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ce7df45b
Branch: refs/heads/3.2.x
Commit: ce7df45b2a20cfa13d57f5eb30e23d15201839f6
Parents: b20c740
Author: Igor Galić <i....@brainsware.org>
Authored: Tue Oct 30 22:26:40 2012 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Tue Jan 15 17:05:49 2013 +0100
----------------------------------------------------------------------
cop/TrafficCop.cc | 1 -
lib/ts/Makefile.am | 2 -
lib/ts/ink_killall.cc | 149 --------------------------------------------
lib/ts/ink_killall.h | 63 -------------------
lib/ts/libts.h | 1 -
lib/ts/lockfile.cc | 9 +---
6 files changed, 1 insertions(+), 224 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/cop/TrafficCop.cc
----------------------------------------------------------------------
diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
index b901145..84a3e1c 100644
--- a/cop/TrafficCop.cc
+++ b/cop/TrafficCop.cc
@@ -29,7 +29,6 @@
#if defined(linux)
#include "sys/utsname.h"
-#include "ink_killall.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/lib/ts/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
index 4195d3d..107fc4c 100644
--- a/lib/ts/Makefile.am
+++ b/lib/ts/Makefile.am
@@ -71,8 +71,6 @@ libtsutil_la_SOURCES = \
ink_inet.cc \
ink_inet.h \
ink_inout.h \
- ink_killall.cc \
- ink_killall.h \
ink_llqueue.h \
ink_lockfile.h \
INK_MD5.h \
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/lib/ts/ink_killall.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_killall.cc b/lib/ts/ink_killall.cc
deleted file mode 100644
index 81fab9c..0000000
--- a/lib/ts/ink_killall.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-/*-------------------------------------------------------------------------
- -------------------------------------------------------------------------*/
-
-#include "libts.h"
-
-#if defined(linux)
-
-#include "ink_killall.h"
-#include "ink_resource.h"
-
-#define PROC_BASE "/proc"
-
-#define INITIAL_PIDVSIZE 32
-
-int
-ink_killall(const char *pname, int sig)
-{
-
- int err;
- pid_t *pidv;
- int pidvcnt;
-
- if (ink_killall_get_pidv_xmalloc(pname, &pidv, &pidvcnt) < 0) {
- return -1;
- }
-
- if (pidvcnt == 0) {
- ats_free(pidv);
- return 0;
- }
-
- err = ink_killall_kill_pidv(pidv, pidvcnt, sig);
- ats_free(pidv);
-
- return err;
-
-}
-
-int
-ink_killall_get_pidv_xmalloc(const char *pname, pid_t ** pidv, int *pidvcnt)
-{
-
- DIR *dir;
- FILE *fp;
- struct dirent *de;
- pid_t pid, self;
- char buf[LINE_MAX], *p, *comm;
- int pidvsize = INITIAL_PIDVSIZE;
-
- if (!pname || !pidv || !pidvcnt)
- goto l_error;
-
- self = getpid();
- if (!(dir = opendir(PROC_BASE)))
- goto l_error;
-
- *pidvcnt = 0;
- *pidv = (pid_t *)ats_malloc(pidvsize * sizeof(pid_t));
-
- while ((de = readdir(dir))) {
- if (!(pid = (pid_t) atoi(de->d_name)) || pid == self)
- continue;
- snprintf(buf, sizeof(buf), PROC_BASE "/%d/stat", pid);
- if ((fp = fopen(buf, "r"))) {
- if (fgets(buf, sizeof buf, fp) == 0)
- goto l_close;
- if ((p = strchr(buf, '('))) {
- comm = p + 1;
- if ((p = strchr(comm, ')')))
- *p = '\0';
- else
- goto l_close;
- if (strcmp(comm, pname) == 0) {
- if (*pidvcnt >= pidvsize) {
- pid_t *pidv_realloc;
- pidvsize *= 2;
- if (!(pidv_realloc = (pid_t *)ats_realloc(*pidv, pidvsize * sizeof(pid_t)))) {
- ats_free(*pidv);
- goto l_error;
- } else {
- *pidv = pidv_realloc;
- }
- }
- (*pidv)[*pidvcnt] = pid;
- (*pidvcnt)++;
- }
- }
- l_close:
- fclose(fp);
- }
- }
- closedir(dir);
-
- if (*pidvcnt == 0) {
- ats_free(*pidv);
- *pidv = 0;
- }
-
- return 0;
-
-l_error:
- *pidv = NULL;
- *pidvcnt = 0;
- return -1;
-}
-
-int
-ink_killall_kill_pidv(pid_t * pidv, int pidvcnt, int sig)
-{
-
- int err = 0;
-
- if (!pidv || (pidvcnt <= 0))
- return -1;
-
- while (pidvcnt > 0) {
- pidvcnt--;
- if (kill(pidv[pidvcnt], sig) < 0)
- err = -1;
- }
-
- return err;
-
-}
-
-#endif // linux check
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/lib/ts/ink_killall.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_killall.h b/lib/ts/ink_killall.h
deleted file mode 100644
index 9b9f581..0000000
--- a/lib/ts/ink_killall.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-/*-------------------------------------------------------------------------
- -------------------------------------------------------------------------*/
-
-
-#ifndef _INK_KILLALL_H_
-#define _INK_KILLALL_H_
-
-#include "ink_config.h"
-
-#if defined(linux)
-
-/*-------------------------------------------------------------------------
- ink_killall
- - Sends signal 'sig' to all processes with the name 'pname'
- - Returns: -1 error
- 0 okay
- -------------------------------------------------------------------------*/
-int ink_killall(const char *pname, int sig);
-
-/*-------------------------------------------------------------------------
- ink_killall_get_pidv_xmalloc
- - Get all pid's named 'pname' and stores into ats_malloc'd
- pid_t array, 'pidv'
- - Returns: -1 error (pidv: set to NULL; pidvcnt: set to 0)
- 0 okay (pidv: ats_malloc'd pid vector; pidvcnt: number of pid's;
- if pidvcnt is set to 0, then pidv will be set to NULL)
- -------------------------------------------------------------------------*/
-int ink_killall_get_pidv_xmalloc(const char *pname, pid_t ** pidv, int *pidvcnt);
-
-/*-------------------------------------------------------------------------
- ink_killall_kill_pidv
- - Kills all pid's in 'pidv' with signal 'sig'
- - Returns: -1 error
- 0 okay
- -------------------------------------------------------------------------*/
-int ink_killall_kill_pidv(pid_t * pidv, int pidvcnt, int sig);
-
-#endif
-
-#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/lib/ts/libts.h
----------------------------------------------------------------------
diff --git a/lib/ts/libts.h b/lib/ts/libts.h
index 833cdf9..1006bc9 100644
--- a/lib/ts/libts.h
+++ b/lib/ts/libts.h
@@ -60,7 +60,6 @@
#include "ink_hash_table.h"
#include "ink_hrtime.h"
#include "ink_inout.h"
-#include "ink_killall.h"
#include "ink_llqueue.h"
#include "ink_lockfile.h"
#include "ink_memory.h"
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce7df45b/lib/ts/lockfile.cc
----------------------------------------------------------------------
diff --git a/lib/ts/lockfile.cc b/lib/ts/lockfile.cc
index c2d34c4..e3da24d 100644
--- a/lib/ts/lockfile.cc
+++ b/lib/ts/lockfile.cc
@@ -24,10 +24,6 @@
#include "ink_platform.h"
#include "ink_lockfile.h"
-#if defined(linux)
-#include "ink_killall.h"
-#endif
-
#define LOCKFILE_BUF_LEN 16 // 16 bytes should be enought for a pid
int
@@ -195,10 +191,7 @@ Lockfile::Close(void)
// killed): Unfortunately, it's possible on Linux that the main PID of
// the process has been successfully killed (and is waiting to be
// reaped while in a defunct state), while some of the other threads
-// of the process just don't want to go away. Integrate ink_killall
-// into Kill() and KillAll() just to make sure we really kill
-// everything and so that we don't spin hard while trying to kill a
-// defunct process.
+// of the process just don't want to go away.
//-------------------------------------------------------------------------
static void