[GRASS-SVN] r38757 - grass/branches/develbranch_6/raster/r.li/r.li.daemon

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 17 00:18:46 EDT 2009


Author: hamish
Date: 2009-08-17 00:18:46 -0400 (Mon, 17 Aug 2009)
New Revision: 38757

Modified:
   grass/branches/develbranch_6/raster/r.li/r.li.daemon/worker.c
Log:
detect & bailout on error (trac #718);
use G_malloc();
+new debug msg


Modified: grass/branches/develbranch_6/raster/r.li/r.li.daemon/worker.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.daemon/worker.c	2009-08-17 02:58:14 UTC (rev 38756)
+++ grass/branches/develbranch_6/raster/r.li/r.li.daemon/worker.c	2009-08-17 04:18:46 UTC (rev 38757)
@@ -57,7 +57,8 @@
     fm = G_malloc(sizeof(struct fcell_memory_entry));
     dm = G_malloc(sizeof(struct dcell_memory_entry));
     pid = getpid();
-    ad = malloc(sizeof(struct area_entry));
+    ad = G_malloc(sizeof(struct area_entry));
+
     /* open raster map */
     mapset = G_find_cell(raster, "");
     fd = G_open_cell_old(raster, mapset);
@@ -65,6 +66,7 @@
 	G_message(_("CHILD[pid = %i] cannot open raster map"), pid);
 	exit(EXIT_FAILURE);
     }
+
     /* read data type to allocate cache */
     data_type = G_raster_map_type(raster, mapset);
     /* calculate rows in cache */
@@ -112,6 +114,7 @@
 
     /* receive loop */
     receive(rec_ch, &toReceive);
+
     while (toReceive.type != TERM) {
 	if (toReceive.type == AREA) {
 	    aid = toReceive.f.f_ma.aid;
@@ -122,9 +125,7 @@
 	    ad->raster = raster;
 	    ad->mask = -1;
 	}
-	else {
-	    /* toReceive.type == MASKEDAREA */
-
+	else if (toReceive.type == MASKEDAREA) {
 	    aid = toReceive.f.f_ma.aid;
 	    ad->x = toReceive.f.f_ma.x;
 	    ad->y = toReceive.f.f_ma.y;
@@ -149,9 +150,11 @@
 		    G_message(_("CHILD[pid = %i]: unable to open <%s> mask ... continuing without!"),
 			      pid, toReceive.f.f_ma.mask);
 		}
-
 	    }
 	}
+	else
+	    G_fatal_error("Program error, worker() toReceive.type=%d",
+			  toReceive.type);
 
 	/* memory menagement */
 	if (ad->rl > used) {
@@ -227,8 +230,11 @@
     CELL *old;
     double add_row, add_col;
 
-    buf = malloc(cl * sizeof(int));
+    buf = G_malloc(cl * sizeof(int));
 
+    G_debug(3, "daemon mask preproc: raster=[%s] mask=[%s]  rl=%d cl=%d",
+	    raster, mask, rl, cl);
+
     mapset = G_find_cell(raster, "");
     /* open raster */
     if (G_get_cellhd(raster, mapset, &cell) == -1)



More information about the grass-commit mailing list