caf80ae6 |
/*
* $Id$
*
* here, we delete message lumps which are generated in
* core functions using pkg_malloc and applied to shmem
* requests; not doing so would result ugly memory problems
*
* I admit it is not a nice hack; -jiri |
7dd0b342 |
* |
84d8e165 |
* Copyright (C) 2001-2003 FhG Fokus |
7dd0b342 |
*
* This file is part of ser, a free SIP server.
*
* ser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* ser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
caf80ae6 |
*/ |
b7b66ef2 |
/* |
84d8e165 |
* History: |
b7b66ef2 |
* -------
* 2003-11-24 changed free_via_lump to free_via_clen_lump and make it
* handle CONTENTLENGTH lumps also (andrei) |
3c41d76d |
* 2005-07-04 lumps in SHM or dup'ed lumps are not freed and an warning
* message is logged (temporary fix) (andrei) |
b7b66ef2 |
*/
|
caf80ae6 |
|
7dd0b342 |
|
caf80ae6 |
#ifndef _FIX_LUMPS_H
#define _FIX_LUMPS_H
|
ff979952 |
|
1ff47a5c |
/** @brief used to delete attached via lumps from msg;
msg can be either an original pkg msg, whose Via lump I want |
caf80ae6 |
to delete before generating next branch, or a shmem-stored
message processed during on_reply -- then I want to
delete the Via lump for the same reason
the other case when I want to delete them is when a message
is stored in shmem for branch picking, forwarded lated and
Via removal is applied to the shmem-ed message |
b7b66ef2 |
the same thing for Content-Length lumps (FIXME: this
should be done in a nicer way) |
caf80ae6 |
*/ |
b7b66ef2 |
inline static void free_via_clen_lump( struct lump **list ) |
caf80ae6 |
{ |
35b730a3 |
struct lump *prev_lump, *lump, *a, *foo, *next; |
caf80ae6 |
|
35b730a3 |
next=0; |
caf80ae6 |
prev_lump=0; |
35b730a3 |
for(lump=*list;lump;lump=next) {
next=lump->next; |
5c28a534 |
if (lump->type==HDR_VIA_T||lump->type==HDR_CONTENTLENGTH_T) { |
3c41d76d |
if (lump->flags & (LUMPFLAG_DUPED|LUMPFLAG_SHMEM)){
LOG(L_CRIT, "BUG: free_via_clen_lmp: lump %p, flags %x\n",
lump, lump->flags);
/* ty to continue */
} |
caf80ae6 |
a=lump->before;
while(a) {
foo=a; a=a->before; |
3c41d76d |
if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
free_lump(foo);
if (!(foo->flags&LUMPFLAG_SHMEM))
pkg_free(foo); |
caf80ae6 |
}
a=lump->after;
while(a) {
foo=a; a=a->after; |
3c41d76d |
if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
free_lump(foo);
if (!(foo->flags&LUMPFLAG_SHMEM))
pkg_free(foo); |
caf80ae6 |
}
if (prev_lump) prev_lump->next = lump->next;
else *list = lump->next; |
3c41d76d |
if (!(lump->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
free_lump(lump);
if (!(lump->flags&LUMPFLAG_SHMEM))
pkg_free(lump); |
caf80ae6 |
} else {
/* store previous position */
prev_lump=lump;
}
}
}
#endif |