• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

fix_lumps.h

00001 /*
00002  * $Id$
00003  *
00004  * here, we delete message lumps which are generated in
00005  * core functions using pkg_malloc and applied to shmem
00006  * requests; not doing so would result ugly memory problems
00007  *
00008  * I admit it is not a nice hack; -jiri 
00009  *
00010  * Copyright (C) 2001-2003 FhG Fokus
00011  *
00012  * This file is part of ser, a free SIP server.
00013  *
00014  * ser is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU General Public License as published by
00016  * the Free Software Foundation; either version 2 of the License, or
00017  * (at your option) any later version
00018  *
00019  * ser is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License 
00025  * along with this program; if not, write to the Free Software 
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  */
00028 /*
00029  * History:
00030  * -------
00031  *  2003-11-24  changed free_via_lump to free_via_clen_lump and make it
00032  *              handle CONTENTLENGTH lumps also (andrei)
00033  *  2005-07-04  lumps in SHM or dup'ed lumps are not freed and an warning
00034  *               message is logged (temporary fix) (andrei)
00035  */
00036 
00037 
00038 
00039 #ifndef _FIX_LUMPS_H
00040 #define _FIX_LUMPS_H
00041 
00042 
00043 
00058 inline static void free_via_clen_lump( struct lump **list )
00059 {
00060         struct lump *prev_lump, *lump, *a, *foo, *next;
00061 
00062         next=0;
00063         prev_lump=0;
00064         for(lump=*list;lump;lump=next) {
00065                 next=lump->next;
00066                 if (lump->type==HDR_VIA_T||lump->type==HDR_CONTENTLENGTH_T) {
00067                         if (lump->flags & (LUMPFLAG_DUPED|LUMPFLAG_SHMEM)){
00068                                 LOG(L_CRIT, "BUG: free_via_clen_lmp: lump %p, flags %x\n",
00069                                                 lump, lump->flags);
00070                                 /* ty to continue */
00071                         }
00072                         a=lump->before;
00073                         while(a) {
00074                                 foo=a; a=a->before;
00075                                 if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
00076                                         free_lump(foo);
00077                                 if (!(foo->flags&LUMPFLAG_SHMEM))
00078                                         pkg_free(foo);
00079                         }
00080                         a=lump->after;
00081                         while(a) {
00082                                 foo=a; a=a->after;
00083                                 if (!(foo->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
00084                                         free_lump(foo);
00085                                 if (!(foo->flags&LUMPFLAG_SHMEM))
00086                                         pkg_free(foo);
00087                         }
00088                         if (prev_lump) prev_lump->next = lump->next;
00089                         else *list = lump->next;
00090                         if (!(lump->flags&(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)))
00091                                 free_lump(lump);
00092                         if (!(lump->flags&LUMPFLAG_SHMEM))
00093                                 pkg_free(lump);
00094                 } else {
00095                         /* store previous position */
00096                         prev_lump=lump;
00097                 }
00098         }
00099 }
00100 
00101 #endif

Generated on Tue May 22 2012 13:10:07 for SIP Router by  doxygen 1.7.1