1 Index: modules/registrar/save.c |
1 Index: modules/registrar/save.c |
2 diff -Nau modules/registrar/save.c.orig modules/registrar/save.c |
2 diff -Nau modules/registrar/save.c.orig modules/registrar/save.c |
3 --- modules/registrar/save.c.orig 2008-08-03 15:53:57.000000000 +0200 |
3 --- modules/registrar/save.c.orig 2008-08-03 15:53:57.000000000 +0200 |
4 +++ modules/registrar/save.c 2009-03-24 21:44:46.182865192 +0100 |
4 +++ modules/registrar/save.c 2009-03-24 21:44:46.182865192 +0100 |
5 @@ -76,7 +76,7 @@ |
5 @@ -77,7 +77,7 @@ |
6 struct save_ctx { |
6 struct save_ctx { |
7 unsigned int flags; |
7 unsigned int flags; |
8 str aor; |
8 str aor; |
9 - unsigned int max_contacts; |
9 - unsigned int max_contacts; |
10 + int max_contacts; |
10 + int max_contacts; |
11 }; |
11 }; |
12 |
12 |
13 |
13 |
14 @@ -388,7 +388,7 @@ |
14 @@ -394,7 +394,7 @@ |
15 if (e == 0) |
15 if (e == 0) |
16 continue; |
16 continue; |
17 |
17 |
18 - if (_sctx->max_contacts && (num >= _sctx->max_contacts)) { |
18 - if (_sctx->max_contacts && (num >= _sctx->max_contacts)) { |
19 + if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) { |
19 + if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) { |
20 if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
20 if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
21 /* we are overflowing the number of maximum contacts, |
21 /* we are overflowing the number of maximum contacts, |
22 so remove the first (oldest) one to prevent this */ |
22 so remove the first (oldest) one to prevent this */ |
23 @@ -494,6 +494,7 @@ |
23 @@ -501,6 +501,7 @@ |
24 contact_t* _c, struct save_ctx *_sctx) |
24 contact_t* _c, struct save_ctx *_sctx) |
25 { |
25 { |
26 ucontact_info_t *ci; |
26 ucontact_info_t *ci; |
27 + ucontact_t *ucon = 0; |
27 + ucontact_t *ucon = 0; |
28 ucontact_t* c; |
28 ucontact_t* c; |
29 int e; |
29 int e; |
30 unsigned int cflags; |
30 unsigned int cflags; |
31 @@ -554,7 +555,7 @@ |
31 @@ -561,7 +562,7 @@ |
32 continue; |
32 continue; |
33 |
33 |
34 /* we need to add a new contact -> too many ?? */ |
34 /* we need to add a new contact -> too many ?? */ |
35 - if (_sctx->max_contacts && num>=_sctx->max_contacts) { |
35 - if (_sctx->max_contacts && num>=_sctx->max_contacts) { |
36 + if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) { |
36 + if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) { |
37 if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
37 if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { |
38 /* we are overflowing the number of maximum contacts, |
38 /* we are overflowing the number of maximum contacts, |
39 so remove the first (oldest) one to prevent this */ |
39 so remove the first (oldest) one to prevent this */ |
40 @@ -581,6 +582,23 @@ |
40 @@ -588,6 +589,23 @@ |
41 goto error; |
41 goto error; |
42 } |
42 } |
43 |
43 |
44 + /* remove matching contacts or matching Call-ID headers before */ |
44 + /* remove matching contacts or matching Call-ID headers before */ |
45 + /* inserting a new one if indicated by a negative max_contacts */ |
45 + /* inserting a new one if indicated by a negative max_contacts */ |