MCPcopy Create free account
hub / github.com/apache/trafficserver / l_add

Function l_add

tools/http_load/timers.c:53–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static void
54l_add(Timer *t)
55{
56 int h = t->hash;
57 Timer *t2;
58 Timer *t2prev;
59
60 t2 = timers[h];
61 if (t2 == (Timer *)0) {
62 /* The list is empty. */
63 timers[h] = t;
64 t->prev = t->next = (Timer *)0;
65 } else {
66 if (t->time.tv_sec < t2->time.tv_sec || (t->time.tv_sec == t2->time.tv_sec && t->time.tv_usec <= t2->time.tv_usec)) {
67 /* The new timer goes at the head of the list. */
68 timers[h] = t;
69 t->prev = (Timer *)0;
70 t->next = t2;
71 t2->prev = t;
72 } else {
73 /* Walk the list to find the insertion point. */
74 for (t2prev = t2, t2 = t2->next; t2 != (Timer *)0; t2prev = t2, t2 = t2->next) {
75 if (t->time.tv_sec < t2->time.tv_sec || (t->time.tv_sec == t2->time.tv_sec && t->time.tv_usec <= t2->time.tv_usec)) {
76 /* Found it. */
77 t2prev->next = t;
78 t->prev = t2prev;
79 t->next = t2;
80 t2->prev = t;
81 return;
82 }
83 }
84 /* Oops, got to the end of the list. Add to tail. */
85 t2prev->next = t;
86 t->prev = t2prev;
87 t->next = (Timer *)0;
88 }
89 }
90}
91
92static void
93l_remove(Timer *t)

Callers 2

l_resortFunction · 0.85
tmr_createFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected