Skip to content

Commit

Permalink
fixing bug in sync timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngerakines committed Feb 25, 2010
1 parent afdc254 commit 7a587c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/barbershop.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void on_accept(int fd, short ev, void *arg) {

int main(int argc, char **argv) {
int port = SERVER_PORT;
timeout = 60 * CLOCKS_PER_SEC;
timeout = 60;
static int daemon_mode = 0;

int c;
Expand Down Expand Up @@ -236,7 +236,7 @@ int main(int argc, char **argv) {
port = atoi(optarg);
break;
case 's':
timeout = atoi(optarg) * CLOCKS_PER_SEC;
timeout = atoi(optarg);
break;
case '?':
/* getopt_long already printed an error message. */
Expand Down Expand Up @@ -310,6 +310,7 @@ void reply(int fd, char *buffer) {

void gc_thread() {
while (1) {
printf("[gc_thread] sleeping %d\n", timeout);
sleep(timeout);
pthread_mutex_lock(&scores_mutex);
sync_to_disk(scores, sync_file);
Expand Down Expand Up @@ -341,6 +342,7 @@ void load_snapshot(char *filename) {

// TODO: Make these writes atomic (write to tmp, move tmp to file).
void sync_to_disk(PoolNode *head, char *filename) {
printf("Syncing scores to file '%s'\n", filename);
FILE *out_file;

remove(filename);
Expand Down

0 comments on commit 7a587c4

Please sign in to comment.