Changeset 9197 for trunk/src/apps/ucache/ucached.c
- Timestamp:
- 02/17/12 17:05:04 (16 months ago)
- Files:
-
- 1 modified
-
trunk/src/apps/ucache/ucached.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/ucache/ucached.c
r9190 r9197 48 48 else 49 49 { 50 strcpy(buffer, "FAILURE: check log: " UCACHED_LOG_FILE);50 strcpy(buffer, "FAILURE: check log: " UCACHED_LOG_FILE); 51 51 } 52 52 } … … 80 80 * handled. 81 81 * Returns -1 when 1 or more hung locks are detected and couldn't 82 * be handled properly. (error)82 * be handled properly. (error) 83 83 */ 84 84 static int ucached_lockchk(void) … … 179 179 break; 180 180 case 'i': 181 rc = ucache_info(stdout, "sav"); 181 { 182 char info_options[6]; 183 memset(info_options, 0, 6); 184 185 /* Open FILE * to output ucache_info */ 186 FILE * info_out = fopen(UCACHED_INFO_FILE, "w"); 187 //FILE * info_out = fdopen(writefd, "w"); 188 189 int howmany = sscanf(&buffer[1], "%s", info_options); 190 if(howmany > 0) 191 { 192 rc = ucache_info(info_out, info_options); 193 } 194 else 195 { 196 fprintf(info_out, "No display options specified. " 197 "Showing all ucache contents.\n"); 198 rc = ucache_info(info_out, "a"); 199 } 200 rc = 1; 201 fclose(info_out); 202 //shmdt(ucache); 203 //shmdt(ucache_aux); 182 204 break; 205 } 183 206 /* Close Daemon */ 184 207 case 'x': … … 190 213 } 191 214 close(writefd); 215 close(readfd); 192 216 exit(EXIT_SUCCESS); 193 217 break; 194 218 default: 195 219 strcpy(buffer, "FAILURE\tInvalid command character"); 196 break;197 }220 return -1; 221 } 198 222 return rc; 199 223 } … … 475 499 if(dest_ucache) 476 500 { 501 // printf("dest_ucache\n"); 477 502 gossip_debug(GOSSIP_UCACHED_DEBUG, 478 503 "INFO: destroying ucache shmem\n"); … … 499 524 if(dest_locks) 500 525 { 526 // printf("dest_locks\n"); 501 527 gossip_debug(GOSSIP_UCACHED_DEBUG, 502 528 "INFO: destroying locks' shmem\n"); … … 523 549 gossip_debug(GOSSIP_UCACHED_DEBUG, 524 550 "INFO: both shmem segments marked for destruction.\n"); 525 526 551 return rc; 527 552 } … … 576 601 577 602 /* Daemonize! */ 578 rc = daemon(0, 0); 603 //rc = daemon( 0, 0); 604 rc = daemon( 1, 1); 579 605 580 606 if(rc != 0) … … 645 671 char c = buffer[0]; 646 672 /* Valid Command? */ 647 if(c == 'c' || c == 'd' || c == 'x' || 'i')673 if(c == 'c' || c == 'd' || c == 'x' || c == 'i') 648 674 { 649 675 gossip_debug(GOSSIP_UCACHED_DEBUG, 650 676 "INFO: Command Received: %c\n", c); 651 /* Run creation in child process */ 652 if(c == 'c') 677 if(c == 'c' || c == 'i') 653 678 { 679 /* Run creation in child process */ 654 680 run_as_child(c); 655 681 } 656 682 else 657 683 { 658 rc =execute_cmd(c);684 execute_cmd(c); 659 685 } 660 check_rc(rc); 686 check_rc(rc); 661 687 } 662 688 /* Invalid Command */ … … 670 696 671 697 /* Data can be written, not guaranteed anything to write */ 672 int responseLength = 0;673 if( (responseLength = strlen(buffer))!= 0)698 int responseLength = strlen(buffer); 699 if(responseLength != 0) 674 700 { 675 701 writefd = open(FIFO2, O_WRONLY); 676 702 if(writefd == -1) 677 { 703 { perror("Error Opening File"); 678 704 gossip_debug(GOSSIP_UCACHED_DEBUG, 679 705 "ERROR: opening write FIFO: errno = %d\n", errno); … … 681 707 rc = write(writefd, buffer, BUFF_SIZE); 682 708 while(rc <= 0) 683 { 709 { printf("rc = %d\n", rc); 684 710 rc = write(writefd, buffer, BUFF_SIZE); 685 711 } 686 712 memset(buffer, 0, BUFF_SIZE); 687 close(writefd);688 713 } 714 else 715 { 716 printf("no response\n"); 717 } 689 718 } 690 719 } … … 693 722 if(ucache_avail) 694 723 { 695 /* Gather stats */ 696 /* TODO: which stats? */ 724 /* TODO: write some stats to file periodically */ 697 725 698 726 /* Write some dirty blocks out */ 699 /* TODO: create function to do this or do i already have one that will suffice?*/727 /* TODO: create function to do this. */ 700 728 701 729 /* Check for hung locks */
