Skip to content

Commit

Permalink
Fixed incorrect call on get_time_ns in pping.c
Browse files Browse the repository at this point in the history
Had forgotten to remove the CLOCK_MONOTONIC argument from the callers after I had removed the clock_id from get_time_ns in previous refactorization, as pointed out by @tohojo.

Signed-off-by: Simon Sundberg <[email protected]>
  • Loading branch information
simosund committed Jan 27, 2021
1 parent 7eb8d10 commit e4ec340
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pping/pping.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int tc_bpf_clear(char *interface)
* Returns time of CLOCK_MONOTONIC as nanoseconds in a single __u64.
* On failure, the value 0 is returned (and errno will be set).
*/
static __u64 get_time_ns()
static __u64 get_time_ns(void)
{
struct timespec t;
if (clock_gettime(CLOCK_MONOTONIC, &t) != 0)
Expand All @@ -174,7 +174,7 @@ static int clean_map(int map_fd, __u64 max_age)
struct ts_key key, prev_key = { 0 };
struct ts_timestamp value;
bool delete_prev = false;
__u64 now_nsec = get_time_ns(CLOCK_MONOTONIC);
__u64 now_nsec = get_time_ns();

int entries = 0; // Just for debug
__u64 duration; // Just for debug
Expand Down Expand Up @@ -203,7 +203,7 @@ static int clean_map(int map_fd, __u64 max_age)
bpf_map_delete_elem(map_fd, &prev_key);
removed++;
}
duration = get_time_ns(CLOCK_MONOTONIC) - now_nsec;
duration = get_time_ns() - now_nsec;
printf("Gone through %d entries and removed %d of them in %llu.%09llu s\n",
entries, removed, duration / NS_PER_SECOND,
duration % NS_PER_SECOND);
Expand Down

0 comments on commit e4ec340

Please sign in to comment.