[GRASS-SVN] r62484 - grass/trunk/lib/segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 29 14:38:36 PDT 2014
Author: mmetz
Date: 2014-10-29 14:38:36 -0700 (Wed, 29 Oct 2014)
New Revision: 62484
Modified:
grass/trunk/lib/segment/init.c
grass/trunk/lib/segment/open.c
grass/trunk/lib/segment/pageout.c
Log:
libsegment: improve error handling
Modified: grass/trunk/lib/segment/init.c
===================================================================
--- grass/trunk/lib/segment/init.c 2014-10-29 14:52:35 UTC (rev 62483)
+++ grass/trunk/lib/segment/init.c 2014-10-29 21:38:36 UTC (rev 62484)
@@ -63,7 +63,9 @@
SEG->nseg = nseg;
if (lseek(fd, 0L, SEEK_SET) < 0) {
- G_warning("Segment_init: %s", strerror(errno));
+ int err = errno;
+
+ G_warning("Segment_init: %s", strerror(err));
return -1;
}
Modified: grass/trunk/lib/segment/open.c
===================================================================
--- grass/trunk/lib/segment/open.c 2014-10-29 14:52:35 UTC (rev 62483)
+++ grass/trunk/lib/segment/open.c 2014-10-29 21:38:36 UTC (rev 62484)
@@ -81,6 +81,7 @@
}
/* re-open for read and write */
close(SEG->fd);
+ SEG->fd = -1;
if (-1 == (SEG->fd = open(SEG->fname, 2))) {
unlink(SEG->fname);
G_warning(_("Unable to re-open segment file"));
Modified: grass/trunk/lib/segment/pageout.c
===================================================================
--- grass/trunk/lib/segment/pageout.c 2014-10-29 14:52:35 UTC (rev 62483)
+++ grass/trunk/lib/segment/pageout.c 2014-10-29 21:38:36 UTC (rev 62484)
@@ -37,8 +37,14 @@
int seg_pageout(SEGMENT * SEG, int i)
{
SEG->seek(SEG, SEG->scb[i].n, 0);
+ errno = 0;
if (write(SEG->fd, SEG->scb[i].buf, SEG->size) != SEG->size) {
- G_warning("Segment pageout: %s", strerror(errno));
+ int err = errno;
+
+ if (err)
+ G_warning("Segment pageout: %s", strerror(err));
+ else
+ G_warning("Segment pageout: insufficient disk space?");
return -1;
}
SEG->scb[i].dirty = 0;
More information about the grass-commit
mailing list