Changeset 506
- Timestamp:
- Apr 18, 2011, 3:37:17 PM (12 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/cache.cpp
r505 r506 33 33 #include "specache.h" 34 34 #include "netface.h" 35 36 char lfname[100]=""; // name of compiled lisp code cache file37 35 38 36 #define touch(x) { (x)->last_access=last_access++; \ … … 666 664 } 667 665 668 static void cache_cleanup2()669 { unlink(lfname);670 }671 672 static void cache_cleanup(int ret, void *arg)673 { unlink(lfname);674 }675 676 void CacheList::create_lcache()677 {678 #ifdef WIN32679 char *prefix="c:\\";680 #else681 char const *prefix = "/tmp/"; // for UNIX store lisp cache in tmp dir682 int flags = O_CREAT | O_RDWR;683 #endif684 685 int cfail = 1, num = 0;686 do687 {688 sprintf(lfname,"%slcache%02d.tmp",prefix,num);689 690 #if defined( __APPLE__ )691 unlink(lfname);692 FILE *fp=fopen(lfname,"wb");693 if (fp)694 {695 fclose(fp);696 cfail=0;697 }698 #else699 int fd=open(lfname,flags,S_IRWXU | S_IRWXG | S_IRWXO); // can we get exclusive rights to this file?700 if (fd<0) close(fd); else cfail=0;701 #endif702 703 if (cfail)704 num++;705 706 } while (cfail && num<15);707 708 if (cfail)709 {710 fprintf(stderr,"Error : Unable to open cache file for compiled code.\n"711 " Please delete all files named lcacheXX.tmp\n"712 " and make sure you have write permission to\n"713 " directory (%s)\n",prefix);714 exit(0);715 }716 else717 {718 exit_proc(cache_cleanup,cache_cleanup2); // make sure this file gets deleted on exit..719 }720 lcache_number=-1;721 }722 723 666 CacheList::CacheList() 724 667 { 725 // start out with a decent sized cache buffer because it's going to get allocated anyway. 726 total=0; 727 list=NULL; 728 last_registered=-1; 729 cache_file=fp=NULL; 730 last_access=1; 731 used=ful=0; 732 last_dir=NULL; 733 last_file=-1; 734 prof_data=NULL; 735 cache_read_file=NULL; 736 create_lcache(); 668 // Start out with a decent sized cache buffer because it's going to 669 // get allocated anyway. 670 total = 0; 671 list = NULL; 672 last_registered = -1; 673 fp = NULL; 674 last_access = 1; 675 used = ful = 0; 676 last_dir = NULL; 677 last_file = -1; 678 prof_data = NULL; 737 679 } 738 680 … … 751 693 if (fp) delete fp; 752 694 if (last_dir) delete last_dir; 753 if (cache_file)754 {755 delete cache_file;756 cache_file=NULL;757 }758 unlink(lfname);759 695 760 696 if (prof_data) … … 767 703 list=NULL; 768 704 last_registered=-1; 769 cache_file=fp=NULL; 770 if (cache_read_file) 771 { 772 delete cache_read_file; 773 cache_read_file=NULL; 774 } 705 fp=NULL; 775 706 776 707 last_access=1; -
abuse/trunk/src/cache.h
r503 r506 84 84 int16_t last_file; // for speed leave the last file accessed open 85 85 86 bFILE *fp ,*cache_file,*cache_read_file;86 bFILE *fp; 87 87 spec_directory *last_dir; 88 88 int32_t last_offset; // store the last offset so we don't have to seek if 89 89 // we don't need to 90 91 int16_t lcache_number;92 90 93 91 int AllocId(); … … 105 103 ~CacheList(); 106 104 107 void create_lcache();108 105 void free_oldest(); 109 106 int in_use() { if (used) { used = 0; return 1; } else return 0; }
Note: See TracChangeset
for help on using the changeset viewer.