Skip to content

Commit

Permalink
Make chord_print_circle print to a FILE *
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstorm committed Jun 3, 2013
1 parent 371b773 commit f79d112
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/chord/chord_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
extern "C" {
#endif

#include <stdio.h>

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
Expand All @@ -27,7 +29,7 @@ typedef struct Server Server;

void chord_get_range(Server *srv, chordID *l, chordID *r);
int chord_is_local(Server *srv, chordID *x);
void chord_print_circle(Server *srv);
void chord_print_circle(Server *srv, FILE *fp);

#ifdef __cplusplus
}
Expand Down
9 changes: 6 additions & 3 deletions src/chord.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ long double id_to_radians(const chordID *id)
return rad*2*PI;
}

void chord_print_circle(Server *srv)
void chord_print_circle(Server *srv, FILE *fp)
{
return;
#define ROW_RATIO ((long double)0.5)
Expand Down Expand Up @@ -365,7 +365,7 @@ void chord_print_circle(Server *srv)

StartLog(INFO);
PartialLog("\n");
print_grid(clog_file_logger()->fp, g);
print_grid(fp, g);
EndLog();

free_circle(c);
Expand All @@ -384,7 +384,10 @@ void chord_update_range(Server *srv, chordID *l, chordID *r)
srv->pred_bound = *l;
srv->node.id = *r;

chord_print_circle(srv);
StartLog(INFO);
PartialLog("\n");
chord_print_circle(srv, clog_file_logger()->fp);
EndLog();
}

/* get_range: returns the range (l,r] that this node is responsible for */
Expand Down
6 changes: 5 additions & 1 deletion src/finger.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ void activate_finger(Server *srv, Finger *f)
if (f->status == F_PASSIVE) {
srv->num_passive_fingers--;
f->status = F_ACTIVE;
chord_print_circle(srv);

StartLog(INFO);
PartialLog("\n");
chord_print_circle(srv, clog_file_logger()->fp);
EndLog();
}
}

Expand Down

0 comments on commit f79d112

Please sign in to comment.