Changeset 26 for trunk/pbs_drmaa/log_reader.c
- Timestamp:
- 10/12/11 14:21:23 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pbs_drmaa/log_reader.c
r25 r26 260 260 pbsdrmaa_read_log( pbsdrmaa_log_reader_t * self ) 261 261 { 262 pbsdrmaa_job_t *pbsjob = (pbsdrmaa_job_t*) self->job; 262 pbsdrmaa_job_t *pbsjob = (pbsdrmaa_job_t*) self->job; 263 263 fsd_job_t *volatile temp_job = NULL; 264 264 … … 279 279 self->select_file(self); 280 280 281 while ((self->read_line(self, line,buffer, sizeof(line), &idx,&end_idx,&line_idx)) > 0) 281 while ((self->read_line(self, line,buffer, sizeof(line), &idx,&end_idx,&line_idx)) > 0) 282 282 { 283 283 const char *volatile ptr = line; … … 349 349 self->run_flag = false; 350 350 job_id_match = true; 351 status.name = fsd_strdup(self->job->job_id); 351 status.name = fsd_strdup(self->job->job_id); 352 352 } 353 353 else if ( !job_found && diff >= 1) … … 379 379 struct_mtime, 380 380 struct_queue, 381 struct_account_name; 381 struct_account_name, 382 struct_exec_vnode; 383 struct attrl *last_attr = NULL; 382 384 383 385 bool state_running = false; … … 393 395 memset(&struct_queue,0,sizeof(struct attrl)); 394 396 memset(&struct_account_name,0,sizeof(struct attrl)); 397 memset(&struct_exec_vnode,0,sizeof(struct attrl)); 395 398 396 399 if (strcmp(event,FLD_MSG_STATE) == 0) … … 401 404 struct_state.next = NULL; 402 405 struct_state.name = "job_state"; 406 last_attr = &struct_state; 407 403 408 if(field[0] == 'J') /* Job Queued, Job Modified, Job Run*/ 404 409 { … … 424 429 { 425 430 time_t temp_time = mktime(&temp_time_tm); 426 status.attribs = &struct_mtime; 431 last_attr->next = &struct_mtime; 432 last_attr = &struct_mtime; 427 433 struct_mtime.name = "mtime"; 428 434 struct_mtime.next = NULL; … … 434 440 /* != Job deleted and Job to be deleted*/ 435 441 #ifdef PBS_PROFESSIONAL 436 else if (field[4] != 't' && field[10] != 'd') { 442 else if (field[4] != 't' && field[10] != 'd') 443 { 437 444 #else 438 else if(field[4] != 'd') { 445 else if (field[4] != 'd') 446 { 439 447 #endif 440 441 if ((struct_state.value = fsd_asprintf("%c",field[n]) ) == NULL ) { /* 4 first letter of state */ 442 fsd_exc_raise_fmt(FSD_ERRNO_INTERNAL_ERROR,"%s - Memory allocation wasn't possible",self->name); 443 } 444 if(struct_state.value[0] == 'R'){ 448 struct_state.value = fsd_asprintf("%c",field[n]); 449 450 if(struct_state.value[0] == 'R') 451 { 445 452 state_running = true; 446 } 447 } 448 else { /* job terminated - pbs drmaa detects failed as completed with exit_status !=0, aborted with status -1*/ 453 #ifdef PBS_PROFESSIONAL 454 { 455 char *p_vnode = NULL; 456 if (p_vnode = strstr(field, "exec_vnode")) 457 { 458 last_attr->next = &struct_exec_vnode; 459 last_attr = &struct_exec_vnode; 460 struct_exec_vnode.name = "exec_vnode"; 461 struct_exec_vnode.next = NULL; 462 struct_exec_vnode.value = fsd_strdup(p + 11); 463 } 464 } 465 #endif 466 } 467 } 468 else 469 { /* job terminated - pbs drmaa detects failed as completed with exit_status !=0, aborted with status -1*/ 449 470 struct_status.name = "exit_status"; 450 471 struct_status.value = fsd_strdup("-1"); … … 452 473 struct_state.next = &struct_status; 453 474 struct_state.value = fsd_strdup("C"); 454 }475 } 455 476 } 456 477 else /*if (strcmp(event,FLD_MSG_STATUS) == 0 )*/ … … 534 555 else 535 556 { 536 fsd_log_debug(("%s - updating job: %s",self->name, temp_job->job_id )); 557 fsd_log_debug(("%s - updating job: %s",self->name, temp_job->job_id )); 537 558 pbsjob->update( temp_job, &status ); 538 559 } … … 540 561 else if( job_found ) /* job_on_missing */ 541 562 { 542 fsd_log_debug(("Job_on_missing - updating job: %s", self->job->job_id )); 563 fsd_log_debug(("Job_on_missing - updating job: %s", self->job->job_id )); 543 564 pbsjob->update( self->job, &status ); 544 565 } … … 575 596 log_event = false; 576 597 } 577 else if( self->job == NULL && log_match && field_n == FLD_MSG && strncmp(field,"Log closed",10) == 0) 598 else if( self->job == NULL && log_match && field_n == FLD_MSG && strncmp(field,"Log closed",10) == 0) 578 599 { 579 600 fsd_log_debug(("%s - Date changed. Closing log file",self->name)); … … 591 612 } 592 613 593 fsd_free(temp_date); 594 } /* end of while getline loop */ 614 fsd_free(temp_date); 615 } /* end of while getline loop */ 595 616 596 617 if(self->job == NULL) … … 599 620 fd_set log_fds; 600 621 601 fsd_mutex_unlock( &self->session->mutex ); 622 fsd_mutex_unlock( &self->session->mutex ); 602 623 603 624 FD_ZERO(&log_fds); … … 874 895 close(self->fd); 875 896 876 fsd_log_debug(("Accounting Log file: %s",log_path)); 897 fsd_log_debug(("Accounting Log file: %s",log_path)); 877 898 878 899 if((self->fd = open(log_path,O_RDONLY) ) == -1 ) … … 926 947 927 948 if(self->fd != -1) 928 while ((self->read_line(self, line,buffer, sizeof(line), &idx,&end_idx,&line_idx)) > 0) 949 while ((self->read_line(self, line,buffer, sizeof(line), &idx,&end_idx,&line_idx)) > 0) 929 950 { 930 951 const char *volatile ptr = line; … … 965 986 job_found = true; 966 987 job_id_match = true; 967 status.name = fsd_strdup(self->job->job_id); 988 status.name = fsd_strdup(self->job->job_id); 968 989 } 969 990 } … … 973 994 { 974 995 struct attrl * struct_attrl = calloc(10,sizeof(struct attrl)); 975 996 int i; 997 976 998 if(field[0] == 'q') 977 999 { … … 987 1009 char msg[ 256 ] = ""; 988 1010 int n2 = 0; 989 int msg_field_n = 0; 1011 int msg_field_n = 0; 990 1012 991 1013 status.attribs = &struct_attrl[0]; … … 996 1018 { 997 1019 case FLD_MSG_ACC_USER: 998 struct_attrl[msg_field_n].name = ATTR_euser; 1020 struct_attrl[msg_field_n].name = ATTR_euser; 999 1021 break; 1000 1022 … … 1061 1083 if( job_found && status.attribs != NULL) 1062 1084 { 1063 fsd_log_debug(("Accounting file - updating job: %s", self->job->job_id )); 1085 fsd_log_debug(("Accounting file - updating job: %s", self->job->job_id )); 1064 1086 pbsjob->update( self->job, &status ); 1065 1087 res = true; … … 1074 1096 temp_job->release( temp_job ); 1075 1097 1076 int i = 0;1077 1098 for(i = 0; i < 10; i++) 1078 1099 {
Note: See TracChangeset
for help on using the changeset viewer.