1/* Copyright (c) 2000, 2002, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
2 Use is subject to license terms.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17#include "heapdef.h"
18
19 /* if flag == HA_PANIC_CLOSE then all files are removed for more
20 memory */
21
22int hp_panic(enum ha_panic_function flag)
23{
24 LIST *element,*next_open;
25 DBUG_ENTER("hp_panic");
26
27 mysql_mutex_lock(&THR_LOCK_heap);
28 for (element=heap_open_list ; element ; element=next_open)
29 {
30 HP_INFO *info=(HP_INFO*) element->data;
31 next_open=element->next; /* Save if close */
32 switch (flag) {
33 case HA_PANIC_CLOSE:
34 hp_close(info);
35 break;
36 default:
37 break;
38 }
39 }
40 for (element=heap_share_list ; element ; element=next_open)
41 {
42 HP_SHARE *share=(HP_SHARE*) element->data;
43 next_open=element->next; /* Save if close */
44 switch (flag) {
45 case HA_PANIC_CLOSE:
46 {
47 if (!share->open_count)
48 hp_free(share);
49 break;
50 }
51 default:
52 break;
53 }
54 }
55 mysql_mutex_unlock(&THR_LOCK_heap);
56 DBUG_RETURN(0);
57} /* hp_panic */
58