Bug 53783

Summary: Running out of File Descriptors - Piranha 0.4.17-2
Product: [Retired] Red Hat High Availability Server Reporter: sheehan
Component: piranhaAssignee: kbarrett
Status: CLOSED DUPLICATE QA Contact: Phil Copeland <copeland>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-09-18 16:31:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sheehan 2001-09-18 16:31:42 UTC
When setting up lvs.cf you can use ssh, rup etc for uptime but if these
fail to run
properly on the back end webservers then there is a bug in nanny that 
will cause lvs to "basically crash". Runs out of file
descriptors. Version 0.4.17-2 in nanny.c function getExecOutput

p[0] for the parent is never closed if failure of ssh etc. Is only closed
on success.
Lines added are commented by /*Nanny Fix*/.  


char * getExecOutput(int flags, char ** argv, int timeout) {

    pid_t child;
    int status;
    sigset_t sigs, oldSigs;
    int p[2];
    int rc;
    char buf[4096];

    sigemptyset(&sigs);
    sigaddset(&sigs, SIGTERM);
    sigaddset(&sigs, SIGINT);
    sigaddset(&sigs, SIGALRM);

    pipe(p);

    if (!(child = fork())) {
        int stdin, stderr;

            close(p[0]);
            dup2(p[1], 1);
            close(p[1]);

        stdin = open("/dev/null", O_RDONLY);
        if(stdin != STDIN_FILENO) {
            close(STDIN_FILENO);
            dup2(stdin, STDIN_FILENO);
        }
        stderr = open("/dev/null", O_WRONLY);
        if(stdin != STDERR_FILENO) {
            close(STDERR_FILENO);
            dup2(stderr, STDERR_FILENO);
        }
          execvp(argv[0], argv);
            exit(1);
    }

    close(p[1]);

    alarm(timeout);

    needsKilling = child;
    sigprocmask(SIG_UNBLOCK, &sigs, &oldSigs);

    rc = waitpid(child, &status, 0);
    sigprocmask(SIG_SETMASK, &oldSigs, NULL);
    needsKilling = 0;

    if (rc < 0) {
            if (rc == EINTR)
                piranha_log(flags,
                (char *) "unexpected return \"%s\" running the
following:");
            else
                piranha_log(flags, (char *) "timeout running the
following:");

            logArgv(flags, argv);
            kill(child, SIGKILL);
            waitpid(child, &status, 0);
            /*Nanny Fix*/
            close(p[0]);
            return NULL;
    }

    if (!WIFEXITED(status) || WEXITSTATUS(status)) {
            piranha_log(flags, (char *) "The following exited
abnormally:");
            logArgv(flags, argv);
            /*Nanny Fix*/
            close(p[0]);
            return NULL;
    }

    rc = read(p[0], buf, sizeof(buf) - 1);
    buf[rc -1 ] = '\0';             /* chop */

    close(p[0]);

    return strdup(buf);
}

Comment 1 Phil Copeland 2001-09-23 18:13:57 UTC
Has been fixed already. Wait for errata release.

*** This bug has been marked as a duplicate of 20974 ***