Changeset 2419 for trunk


Ignore:
Timestamp:
Aug 26, 2011 11:06:14 AM (10 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r2407 r2419  
    107107
    108108typedef struct Image {
    109     struct Image *nextPtr;      /* Next image in chain of images. The list is
    110                                  * ordered by the most recently received image
    111                                  * from the pymol server to the least. */
    112     struct Image *prevPtr;      /* Previous image in chain of images. The list
    113                                  * is ordered by the most recently received
    114                                  * image from the pymol server to the
    115                                  * least. */
    116     ssize_t nWritten;           /* Number of bytes of image data already
    117                                  * delivered.*/
    118     size_t bytesLeft;           /* Number of bytes of image data left to
    119                                  * delivered to the client. */
    120     char data[1];               /* Start of image data. We allocate the size
    121                                  * of the Image structure plus the size of the
    122                                  * image data. */
     109    struct Image *nextPtr;              /* Next image in chain of images. The
     110                                         * list is ordered by the most
     111                                         * recently received image from the
     112                                         * pymol server to the least. */
     113    struct Image *prevPtr;              /* Previous image in chain of
     114                                         * images. The list is ordered by the
     115                                         * most recently received image from
     116                                         * the pymol server to the least. */
     117    ssize_t nWritten;                   /* Number of bytes of image data
     118                                         * already delivered.*/
     119    size_t bytesLeft;                   /* Number of bytes of image data left
     120                                         * to delivered to the client. */
     121    char data[1];                       /* Start of image data. We allocate
     122                                         * the size of the Image structure
     123                                         * plus the size of the image data. */
    123124} Image;
    124125
     
    20752076    close(proxy.sin);
    20762077
    2077     status = waitpid(child, &result, WNOHANG);
    2078     if (status == -1) {
     2078    if (waitpid(child, &result, 0) < 0) {
    20792079        ERROR("error waiting on pymol server to exit: %s", strerror(errno));
    2080     } else if (status == 0) {
    2081         ERROR("attempting to signal (SIGTERM) pymol server.");
    2082         kill(-child, SIGTERM);          // Kill process group
    2083         alarm(5);
    2084         status = waitpid(child, &result, 0);
    2085         alarm(0);
    2086        
    2087         while ((status == -1) && (errno == EINTR)) {
    2088             ERROR("Attempting to signal (SIGKILL) pymol server.");
    2089             kill(-child, SIGKILL);      // Kill process group
    2090             alarm(10);
    2091             status = waitpid(child, &result, 0);
    2092             alarm(0);
    2093         }
    2094     }
     2080    }
     2081    INFO("attempting to signal (SIGTERM) pymol server.");
     2082    kill(-child, SIGTERM);              // Kill process group
     2083    alarm(5);
    20952084   
    2096     ERROR("pymol server process ended (result=%d)", result);
     2085    if (waitpid(child, &result, 0) < 0) {
     2086        ERROR("error waiting on pymol server to exit after SIGTERM: %s",
     2087              strerror(errno));
     2088    }
     2089    status = -1;
     2090    while ((status == -1) && (errno == EINTR)) {
     2091        ERROR("Attempting to signal (SIGKILL) pymol server.");
     2092        kill(-child, SIGKILL);  // Kill process group
     2093        alarm(10);
     2094        status = waitpid(child, &result, 0);
     2095        alarm(0);
     2096    }
     2097    INFO("pymol server process ended (result=%d)", result);
     2098
    20972099    DestroyTmpDir();
    2098 
    20992100    Tcl_DeleteInterp(interp);
    21002101   
     
    21172118    fcntl(proxyPtr->cin, F_SETFL, flags|O_NONBLOCK);
    21182119
    2119     pollResults[0].fd = proxyPtr->cout;
    2120     pollResults[1].fd = proxyPtr->sout;
    2121     pollResults[2].fd = proxyPtr->serr;
     2120    /* Read file descriptors. */
     2121    pollResults[0].fd = proxyPtr->cout; /* Client standard output  */
     2122    pollResults[1].fd = proxyPtr->sout; /* Server standard error.  */
     2123    pollResults[2].fd = proxyPtr->serr; /* Server standard error.  */
    21222124    pollResults[0].events = pollResults[1].events =
    21232125        pollResults[2].events = POLLIN;
    21242126
    2125     pollResults[3].fd = proxyPtr->cin;
     2127    /* Write file descriptors. */
     2128    pollResults[3].fd = proxyPtr->cin;  /* Client standard input. */
    21262129    pollResults[3].events = POLLOUT;
    21272130
     
    21632166            } else {
    21642167                ERROR("Failed reading pymol stdout (nBytes=%d)\n", nBytes);
    2165                 goto error;     /* Get out on EOF or error. */
     2168                goto error;             /* Get out on EOF or error. */
    21662169            }
    21672170        }
     
    21802183                if (errno != EINTR) {
    21812184                    ERROR("lost connection (stderr) to pymol server.");
    2182                     return;
     2185                    goto error;
    21832186                }
    21842187            }
Note: See TracChangeset for help on using the changeset viewer.