[dovecot-cvs] dovecot/src/lib data-stack.c, 1.21, 1.22 ioloop-epoll.c, 1.2, 1.3 mempool-alloconly.c, 1.28, 1.29 mempool-system.c, 1.15, 1.16 process-title.c, 1.6, 1.7 restrict-access.c, 1.18, 1.19

cras at dovecot.org cras at dovecot.org
Sun Mar 13 01:10:35 EET 2005


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv28892/lib

Modified Files:
	data-stack.c ioloop-epoll.c mempool-alloconly.c 
	mempool-system.c process-title.c restrict-access.c 
Log Message:
If we run out of memory, exit with FATAL_OUTOFMEM status instead of dumping
core. Also changed a few other i_panic() calls to others.



Index: data-stack.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/data-stack.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- data-stack.c	10 May 2004 01:01:24 -0000	1.21
+++ data-stack.c	12 Mar 2005 23:10:33 -0000	1.22
@@ -93,8 +93,10 @@
 			frame_block = GC_malloc(sizeof(*frame_block));
                         memset(frame_block, 0, sizeof(*frame_block));
 #endif
-			if (frame_block == NULL)
-				i_panic("t_push(): Out of memory");
+			if (frame_block == NULL) {
+				i_fatal_status(FATAL_OUTOFMEM,
+					       "t_push(): Out of memory");
+			}
 		} else {
 			/* use existing unused frame_block */
 			frame_block = unused_frame_blocks;
@@ -190,9 +192,9 @@
 	block = GC_malloc_atomic(SIZEOF_MEMBLOCK + alloc_size);
 #endif
 	if (block == NULL) {
-		i_panic("mem_block_alloc(): "
-			"Out of memory when allocating %"PRIuSIZE_T" bytes",
-			alloc_size + SIZEOF_MEMBLOCK);
+		i_fatal_status(FATAL_OUTOFMEM, "mem_block_alloc(): "
+			       "Out of memory when allocating %"PRIuSIZE_T
+			       " bytes", alloc_size + SIZEOF_MEMBLOCK);
 	}
 	block->size = alloc_size;
 	block->next = NULL;

Index: ioloop-epoll.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop-epoll.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ioloop-epoll.c	7 Oct 2004 19:38:05 -0000	1.2
+++ ioloop-epoll.c	12 Mar 2005 23:10:33 -0000	1.3
@@ -58,7 +58,7 @@
 
 	data->epfd = epoll_create(INITIAL_EPOLL_EVENTS);
 	if (data->epfd < 0)
-		i_panic("epoll_create(): %m");
+		i_fatal("epoll_create(): %m");
 }
 
 void io_loop_handler_deinit(struct ioloop *ioloop)
@@ -161,7 +161,7 @@
 
 	ret = epoll_ctl(data->epfd, op, fd, &event);
 	if (ret < 0)
-		i_panic("epoll_ctl(): %m");
+		i_fatal("epoll_ctl(): %m");
 
 	if (data->events_pos >= data->events_size) {
 		data->events_size = nearest_power(data->events_size + 1);

Index: mempool-alloconly.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-alloconly.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mempool-alloconly.c	8 Jul 2004 20:24:48 -0000	1.28
+++ mempool-alloconly.c	12 Mar 2005 23:10:33 -0000	1.29
@@ -155,7 +155,7 @@
 	memset(block, 0, size);
 #endif
 	if (block == NULL)
-		i_panic("block_alloc(): Out of memory");
+		i_fatal_status(FATAL_OUTOFMEM, "block_alloc(): Out of memory");
 	block->prev = apool->block;
 	apool->block = block;
 

Index: mempool-system.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-system.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mempool-system.c	21 Sep 2003 17:55:36 -0000	1.15
+++ mempool-system.c	12 Mar 2005 23:10:33 -0000	1.16
@@ -67,9 +67,10 @@
 	mem = GC_malloc(size);
 	memset(mem, 0, size);
 #endif
-	if (mem == NULL)
-		i_panic("pool_system_malloc(): Out of memory");
-
+	if (mem == NULL) {
+		i_fatal_status(FATAL_OUTOFMEM,
+			       "pool_system_malloc(): Out of memory");
+	}
 	return mem;
 }
 
@@ -93,8 +94,10 @@
 #else
 	mem = GC_realloc(mem, new_size);
 #endif
-	if (mem == NULL)
-		i_panic("pool_system_realloc(): Out of memory");
+	if (mem == NULL) {
+		i_fatal_status(FATAL_OUTOFMEM,
+			       "pool_system_realloc(): Out of memory");
+	}
 
 	if (old_size < new_size) {
                 /* clear new data */

Index: process-title.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/process-title.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- process-title.c	26 Aug 2003 21:18:16 -0000	1.6
+++ process-title.c	12 Mar 2005 23:10:33 -0000	1.7
@@ -32,12 +32,12 @@
 		;
 
 	if ((p = malloc((i + 1) * sizeof(char *))) == NULL)
-		i_panic("malloc() failed: %m");
+		i_fatal_status(FATAL_OUTOFMEM, "malloc() failed: %m");
 	environ = p;
 
 	for (i = 0; envp[i] != NULL; i++) {
 		if ((environ[i] = strdup(envp[i])) == NULL)
-			i_panic("malloc() failed: %m");
+			i_fatal_status(FATAL_OUTOFMEM, "strdup() failed: %m");
 	}
 	environ[i] = NULL;
 

Index: restrict-access.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/restrict-access.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- restrict-access.c	25 Oct 2004 02:05:50 -0000	1.18
+++ restrict-access.c	12 Mar 2005 23:10:33 -0000	1.19
@@ -112,7 +112,7 @@
 			continue;
 
 		if (!t_try_realloc(gid_list, (gid_count+1) * sizeof(gid_t)))
-			i_panic("won't happen");
+			i_unreached();
 		gid_list[gid_count++] = get_group_id(*tmp);
 	}
 



More information about the dovecot-cvs mailing list