Changeset 696


Ignore:
Timestamp:
May 3, 2007 8:12:36 PM (17 years ago)
Author:
nkissebe
Message:

pretty up pymolproxy error handling

File:
1 edited

Legend:

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

    r694 r696  
    143143                if ((result < 0) && (errno != EAGAIN) && (errno != EINTR))
    144144                {
    145                         fprintf(stderr,"Error reading sock(%d), %d/%s\n", sock, errno,strerror(errno));
     145                        fprintf(stderr,"pymolproxy: Error reading sock(%d), %d/%s\n", sock, errno,strerror(errno));
    146146                        break;
    147147                }
     
    336336
    337337    if (waitForString(pymol, "PyMOL>", buffer, 800)) {
    338         fprintf(stderr,"Timeout reading data [%s]\n",buffer);
     338        fprintf(stderr,"pymolproxy: Timeout reading data [%s]\n",buffer);
    339339                pymol->error = 1;
    340340                pymol->status = TCL_ERROR;
     
    681681        pymol->immediate_update |= push;
    682682        pymol->invalidate_cache = 1;
    683 fprintf(stderr,"LabelCmd: state = %d, pymolstate = %d\n",state,pymol->labels);
     683
    684684    if (state) {
    685685                sendf(pymol, "set label_color,white,all\n");
     
    866866       
    867867        if (tmpf <= 0)
    868             fprintf(stderr,"error opening file %d\n",errno);
     868            fprintf(stderr,"pymolproxy: error opening file %d\n",errno);
    869869
    870870    write(tmpf,pdbdata,strlen(pdbdata));
     
    11111111
    11121112                execvp(command,argv);
    1113                 fprintf(stderr,"Failed to start pyMol\n");
     1113                fprintf(stderr,"pymolproxy: Failed to start pyMol\n");
    11141114                exit(-1);
    11151115        }
     
    11771177        //  send images back
    11781178
    1179         if (1)
    1180                 fprintf(stderr,"Pymol Ready.\n");
    1181 
    11821179        gettimeofday(&end, NULL);
    11831180
     
    12101207                if ( status < 0 )
    12111208                {
    1212                         fprintf(stderr, "POLL ERROR: status = %d, errno = %d, %s \n", status,errno,strerror(errno));
     1209                        fprintf(stderr, "pymolproxy: POLL ERROR: status = %d, errno = %d, %s \n", status,errno,strerror(errno));
    12131210                }
    12141211                else if (status > 0)
     
    12161213                        gettimeofday(&now,NULL);
    12171214
    1218             if (ufd[0].revents) {
    1219 
     1215            if (ufd[0].revents) { /* Client Stdout Connection: command input */
    12201216                            if (read(ufd[0].fd,&ch,1) <= 0)
    12211217                            {
    1222                                     fprintf(stderr,"EOF or Lost Connection. status = %d, errno = %d, %s \n", status,errno,strerror(errno));
    1223                                     break;
     1218                                    if (errno != EINTR)
     1219                                        {
     1220                                        fprintf(stderr,"pymolproxy: Lost Client Connection.\n");
     1221                                        break;
     1222                                        }
    12241223                            }
    12251224                            else
     
    12371236                        }
    12381237
    1239                         if (ufd[1].revents ) {
     1238                        if (ufd[1].revents ) { /* pyMol Stdout Connection: pymol (unexpected) output */
    12401239                            if (read(ufd[1].fd, &ch, 1) <= 0)
    12411240                                {
    1242                                     if (errno == EAGAIN)
    1243                                             fprintf(stderr,"EAGAIN error reading pymol stdout... retrying.\n");
    1244                     else {
    1245                                         fprintf(stderr,"Lost PyMol Session. (errno=%d)\n",errno);
     1241                                    if (errno != EINTR) {
     1242                                        fprintf(stderr,"pymolproxy: lost connection (stdout) to pymol server\n");
    12461243                                                break;
    12471244                                        }
     
    12551252                                            dyBufferAppend(&dybuffer, &ch, 1);
    12561253                                                fprintf(stderr,"STDOUT>%s",dybuffer.data);
    1257 
    1258                                                 if (dybuffer.data[0]=='I' && dybuffer.data[1] == 0)
    1259                                                     pymol.need_update = 1;
    1260 
    12611254                                                dyBufferSetLength(&dybuffer,0);
    12621255                                        }
     
    12641257                        }
    12651258
    1266                         if (ufd[2].revents) {
     1259                        if (ufd[2].revents) { /* pyMol Stderr Connection: pymol standard error output */
    12671260                                if (read(ufd[2].fd, &ch, 1) <= 0)
    12681261                                {
    1269                                     if (errno == EAGAIN)
    1270                                             fprintf(stderr,"EAGAIN error reading pymol stderr... retrying.\n");
    1271                         else {
    1272                                             fprintf(stderr,"Lost PyMol Stderr Session. (errno=%d)\n", errno);
     1262                                    if (errno != EINTR) {
     1263                                            fprintf(stderr,"pymolproxy: lost connection (stderr) to pymol server\n");
    12731264                                                break;
    12741265                                        }
     
    12811272                                                dyBufferAppend(&dybuffer2, &ch, 1);
    12821273                                                fprintf(stderr,"stderr>%s", dybuffer2.data);
    1283 
    12841274                                                dyBufferSetLength(&dybuffer2,0);
    12851275                                        }
     
    13081298    }
    13091299
    1310         fprintf(stderr,"Waiting for process to end\n");
    1311 
    13121300        status = waitpid(pid, NULL, WNOHANG);
    13131301
    13141302        if (status == -1)
    1315                 fprintf(stderr, "Error waiting on process (%d)\n", errno);
     1303                fprintf(stderr, "pymolproxy: error waiting on pymol server to exit (%d)\n", errno);
    13161304        else if (status == 0) {
    1317                 fprintf(stderr, "Attempting to SIGTERM process.\n");
     1305                fprintf(stderr, "pymolproxy: attempting to SIGTERM pymol server\n");
    13181306                kill(-pid, SIGTERM); // kill process group
    13191307                alarm(5);
     
    13231311                while ((status == -1) && (errno == EINTR))
    13241312                {
    1325                         fprintf(stderr, "Attempting to SIGKILL process.\n");
     1313                        fprintf(stderr, "pymolproxy: Attempting to SIGKILL process.\n");
    13261314                        kill(-pid, SIGKILL); // kill process group
    13271315                        alarm(10);
     
    13311319        }
    13321320
    1333         fprintf(stderr, "Process ended\n");
     1321        fprintf(stderr, "pymolproxy: pymol server process ended\n");
    13341322
    13351323        dyBufferFree(&pymol.image);
Note: See TracChangeset for help on using the changeset viewer.