aboutsummaryrefslogtreecommitdiffstats
path: root/main/udptl.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-29 20:50:36 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-29 20:50:36 +0000
commit53f8d43e2945038fe3059fd6c1c00dd4ec117505 (patch)
tree0f3fc04bcb07ac328d54ffb2fed0333dfffb44de /main/udptl.c
parent562decf81af443d24afd3f1fc3d133b8b2b7cee3 (diff)
Merge team/russell/frame_caching
There are some situations in Asterisk where ast_frame and/or iax_frame structures are rapidly allocatted and freed (at least 50 times per second for one call). This code significantly improves the performance of ast_frame_header_new(), ast_frdup(), ast_frfree(), iax_frame_new(), and iax_frame_free() by keeping a thread-local cache of these structures and using frames from the cache whenever possible instead of calling malloc/free every time. This commit also converts the ast_frame and iax_frame structures to use the linked list macros. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41278 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/udptl.c')
-rw-r--r--main/udptl.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/main/udptl.c b/main/udptl.c
index 9e8fdf147..1264c23fc 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -296,8 +296,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
ptr = 0;
ifp_no = 0;
- s->f[0].prev = NULL;
- s->f[0].next = NULL;
+ memset(&s->f[0], 0, sizeof(s->f[0]));
/* Decode seq_number */
if (ptr + 2 > len)
@@ -342,11 +341,9 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
s->f[ifp_no].data = (uint8_t *) bufs[i - 1];
s->f[ifp_no].offset = 0;
s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0) {
- s->f[ifp_no].prev = &s->f[ifp_no - 1];
- s->f[ifp_no - 1].next = &s->f[ifp_no];
- }
- s->f[ifp_no].next = NULL;
+ if (ifp_no > 0)
+ AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+ AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
ifp_no++;
}
}
@@ -364,11 +361,9 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
s->f[ifp_no].data = (uint8_t *) ifp;
s->f[ifp_no].offset = 0;
s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0) {
- s->f[ifp_no].prev = &s->f[ifp_no - 1];
- s->f[ifp_no - 1].next = &s->f[ifp_no];
- }
- s->f[ifp_no].next = NULL;
+ if (ifp_no > 0)
+ AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+ AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
}
}
else
@@ -465,11 +460,9 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
s->f[ifp_no].data = s->rx[l].buf;
s->f[ifp_no].offset = 0;
s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0) {
- s->f[ifp_no].prev = &s->f[ifp_no - 1];
- s->f[ifp_no - 1].next = &s->f[ifp_no];
- }
- s->f[ifp_no].next = NULL;
+ if (ifp_no > 0)
+ AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+ AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
ifp_no++;
}
}
@@ -483,11 +476,9 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len)
s->f[ifp_no].data = (uint8_t *) ifp;
s->f[ifp_no].offset = 0;
s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0) {
- s->f[ifp_no].prev = &s->f[ifp_no - 1];
- s->f[ifp_no - 1].next = &s->f[ifp_no];
- }
- s->f[ifp_no].next = NULL;
+ if (ifp_no > 0)
+ AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+ AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
}
s->rx_seq_no = seq_no + 1;