Changeset 85
- Timestamp:
- 07/01/05 00:35:06 (4 years ago)
- Files:
-
- debian/changelog (modified) (1 diff)
- src/Makefile (modified) (2 diffs)
- src/main.c (modified) (2 diffs)
- src/state.c (modified) (3 diffs)
- src/swaps.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
debian/changelog
r82 r85 2 2 3 3 * Redesigned internal state machine, should improve corner-case behaviour 4 * Custom signal handlers are now reusable 5 * Signal-triggered stats dump now goes to log if appropriate 4 6 5 7 -- Jeroen T. Vermeulen <jtv@sipa.or.th> Wed, 29 June 2005 14:10:00 +0700 src/Makefile
r82 r85 2 2 3 3 # Assumes we're using gcc 4 CFLAGS=--std=c99 -Wall --pedantic -Wshadow -O2 -g 4 # swapspace is written in C99, but with at least one extension that isn't 5 # supported in gcc's C99 mode: sigaction() (though it is part of POSIX). 6 CFLAGS=--std=gnu99 -Wall --pedantic -Wshadow -O2 -g 5 7 CPPFLAGS=-DSUPPORT_LARGE_FILES -DVERSION="\"$(VERSION)\"" -DDATE="\"$(DATE)\"" 6 8 RM=rm -f … … 24 26 opts.o : opts.c opts.h main.h ../VERSION ../DATE 25 27 26 state.o : state.c state.h main.h memory.h support.h swaps.h28 state.o : state.c state.h log.h main.h memory.h support.h swaps.h 27 29 28 30 support.o : support.c config.h env.h support.h src/main.c
r82 r85 180 180 181 181 182 static void install_sighandler(int signum, void (*handler)(int)) 183 { 184 struct sigaction sa; 185 memset(&sa, 0, sizeof(sa)); 186 sa.sa_handler = handler; 187 sigaction(signum, &sa, NULL); 188 } 189 190 182 191 /// Install signal handlers 183 192 static void install_sigs(void) … … 188 197 signal(SIGXFSZ, SIG_IGN); 189 198 #endif 190 // TODO: Looks like these only work once... Should remain in effect! 191 signal(SIGUSR1, sighand_status);192 signal(SIGUSR2, sighand_adjust);199 200 install_sighandler(SIGUSR1, sighand_status); 201 install_sighandler(SIGUSR2, sighand_adjust); 193 202 } 194 203 src/state.c
r83 r85 21 21 #include <stdio.h> 22 22 23 #include "log.h" 23 24 #include "main.h" 24 25 #include "memory.h" … … 30 31 */ 31 32 32 // TODO: Adaptive cooldown_time? 33 /* TODO: Adaptive cooldown_time? 34 * Extend cooldown time if a swapfile is allocated shortly after deallocation in 35 * "overfed" state (say, within another timeout period), or if one is 36 * deallocated shortly (say, at most two timeout periods) after having been 37 * allocated. 38 * Reduce cooldown time if "hungry" and/or "overfed" states consistently timeout 39 * too soon (say, X times in the first half of the timeout period but never in 40 * the second) 41 */ 42 33 43 /// Minimum cooldown time before returning to "steady state" allocation policy 34 44 static time_t cooldown_time = 600; … … 140 150 void dump_state(void) 141 151 { 142 printf("state:\t%s\n", Statenames[the_state]); 143 if (timer > 0) printf("timer:\t%ld\n", (long)timer); 152 sprintf(localbuf, "state: %s", Statenames[the_state]); 153 log_msg(LOG_INFO, localbuf); 154 if (timer > 0) 155 { 156 sprintf(localbuf, "timer: %ld", (long)timer); 157 log_msg(LOG_INFO, localbuf); 158 } 144 159 } 145 160 src/swaps.c
r82 r85 89 89 if (chdir(swappath) == -1) 90 90 { 91 log_perr_str(LOG_ERR, "Coul tnot cd to", swappath);91 log_perr_str(LOG_ERR, "Could not cd to", swappath); 92 92 return false; 93 93 } … … 145 145 void dump_stats(void) 146 146 { 147 // TODO: Allow this to go to logfile 148 printf("clock: %lld\t", (long long)clock); 147 sprintf(localbuf, "clock: %lld", (long long)clock); 148 log_msg(LOG_INFO, localbuf); 149 149 150 dump_state(); 150 151 151 152 // TODO: Print memory overview, and include percentages 152 153 153 puts("swapfiles in use:\nfile\tsize\tused"); 154 for (int i=0; i<MAX_SWAPFILES; ++i) 155 if (swapfiles[i].size) 156 printf("%d\t%lld\t%lld\n", 157 i, 158 swapfiles[i].size, 159 swapfiles[i].used); 160 puts("---"); 154 log_msg(LOG_INFO, "swapfiles in use:"); 155 log_msg(LOG_INFO, "file size used"); 156 for (int i=0; i<MAX_SWAPFILES; ++i) if (swapfiles[i].size) 157 { 158 sprintf(localbuf,"%4d%16lld%16lld",i,swapfiles[i].size,swapfiles[i].used); 159 log_msg(LOG_INFO, localbuf); 160 } 161 161 } 162 162
