Esempio n. 1
0
void
Shutdown(void)
{
    AgentInfo	*ap, *root = NULL;
    int		i;

    for (i = 0; i < nAgents; i++) {
	ap = &agent[i];
	if (ap->pmDomainId == PMDAROOT)
	    root = ap;
	if (ap->status.isRootChild)
	    ShutdownAgent(ap);
    }
    for (i = 0; i < nAgents; i++) {
	ap = &agent[i];
	if (ap->pmDomainId == PMDAROOT)
	    continue;
	if (!ap->status.isRootChild)
	    ShutdownAgent(ap);
    }
    if (HarvestAgents(SHUTDOWNWAIT) < 0) {
	/* terminate with prejudice any still remaining non-root PMDAs */
	for (i = 0; i < nAgents; i++) {
	    ap = &agent[i];
	    if (ap == root)
		continue;
	    TerminateAgent(ap);
	}
    }
    if (root) {
	TerminateAgent(root);
	ShutdownAgent(root);
	HarvestAgents(0);
    }
    for (i = 0; i < nClients; i++) {
	if (client[i].status.connected)
	    __pmCloseSocket(client[i].fd);
    }
    __pmServerCloseRequestPorts();
    __pmSecureServerShutdown();
    __pmNotifyErr(LOG_INFO, "pmcd Shutdown\n");
    fflush(stderr);
}
Esempio n. 2
0
void
Shutdown(void)
{
    int	i;

    for (i = 0; i < nAgents; i++) {
	AgentInfo *ap = &agent[i];
	if (!ap->status.connected)
	    continue;
	if (ap->inFd != -1) {
	    if (__pmSocketIPC(ap->inFd))
		__pmCloseSocket(ap->inFd);
	    else
		close(ap->inFd);
	}
	if (ap->outFd != -1) {
	    if (__pmSocketIPC(ap->outFd))
		__pmCloseSocket(ap->outFd);
	    else
		close(ap->outFd);
	}
	if (ap->ipcType == AGENT_SOCKET &&
	    ap->ipc.socket.addrDomain == AF_UNIX) {
	    /* remove the Unix domain socket */
	    unlink(ap->ipc.socket.name);
	}
    }
    if (HarvestAgents(SHUTDOWNWAIT) < 0) {
	/* terminate with prejudice any still remaining */
	for (i = 0; i < nAgents; i++) {
	    AgentInfo *ap = &agent[i];
	    if (ap->status.connected) {
		pid_t pid = ap->ipcType == AGENT_SOCKET ?
			    ap->ipc.socket.agentPid : ap->ipc.pipe.agentPid;
		__pmProcessTerminate(pid, 1);
	    }
	}
    }
    for (i = 0; i < nClients; i++)
	if (client[i].status.connected)
	    __pmCloseSocket(client[i].fd);
    __pmServerCloseRequestPorts();
    __pmSecureServerShutdown();
    __pmNotifyErr(LOG_INFO, "pmcd Shutdown\n");
    fflush(stderr);
}