Changeset: 0a7afdbff569 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0a7afdbff569
Modified Files:
        gdk/gdk_posix.mx
        gdk/gdk_utils.mx
Branch: Apr2011
Log Message:

gdk: write warning messages to console, iso client

Avoid breaking the protocol by sending panic messages which the client
can't actually do anything with.  Just write to the console instead.
TODO: convert all debug messages to write to the same channel (it's a
mix of GDKout and stderr now)


diffs (153 lines):

diff --git a/gdk/gdk_posix.mx b/gdk/gdk_posix.mx
--- a/gdk/gdk_posix.mx
+++ b/gdk/gdk_posix.mx
@@ -609,7 +609,7 @@
                if (MT_mmap_cur == -1)
                        MT_mmap_cur = i;
 #ifdef MMAP_DEBUG
-               mnstr_printf(GDKerr, "#MT_mmap_new: %s fd=%d\n", path, fd);
+               mnstr_printf(GDKstdout, "#MT_mmap_new: %s fd=%d\n", path, fd);
 #endif
                strncpy(MT_mmap_tab[i].path, path, 128);
                MT_mmap_tab[i].base = base;
@@ -660,7 +660,7 @@
                                /* tell the OS quite clearly that you want to 
drop this */
                                ret = posix_fadvise(MT_mmap_tab[victim].fd, 
0LL, MT_mmap_tab[victim].len & ~(MT_pagesize() - 1), POSIX_FADV_DONTNEED);
 #ifdef MMAP_DEBUG
-                               mnstr_printf(GDKerr,
+                               mnstr_printf(GDKstdout,
                                              "#MT_mmap_del: 
posix_fadvise(%s,fd=%d,%uMB,POSIX_FADV_DONTNEED) = %d\n",
                                              MT_mmap_tab[victim].path,
                                              MT_mmap_tab[victim].fd,
@@ -671,7 +671,7 @@
 #endif
                        ret = close(MT_mmap_tab[victim].fd);
 #ifdef MMAP_DEBUG
-                       mnstr_printf(GDKerr,
+                       mnstr_printf(GDKstdout,
                                      "#MT_mmap_del: close(%s fd=%d) = %d\n",
                                      MT_mmap_tab[victim].path,
                                      MT_mmap_tab[victim].fd,
@@ -704,7 +704,7 @@
                        if (MT_mmap_tab[i].fd >= 0) {
                                ret = posix_fadvise(MT_mmap_tab[i].fd, 0, len & 
~(MT_pagesize() - 1), advice);
 #ifdef MMAP_DEBUG
-                               mnstr_printf(GDKerr,
+                               mnstr_printf(GDKstdout,
                                              "#MT_fadvise: 
posix_fadvise(%s,fd=%d,%uMB,%d) = %d\n",
                                              MT_mmap_tab[i].path,
                                              MT_mmap_tab[i].fd,
@@ -943,7 +943,7 @@
        }
        (void) pthread_mutex_unlock(&MT_mmap_lock);
        if (ret) {
-               mnstr_printf(GDKerr,
+               mnstr_printf(GDKstdout,
                              "#MT_mmap_inform: posix_madvise(file=%s, fd=%d, 
base=" PTRFMT ", len=" SZFMT "MB, advice=MMAP_SEQUENTIAL) = %d (%s)\n",
                              (i >= 0 ? MT_mmap_tab[i].path : ""),
                              (i >= 0 ? MT_mmap_tab[i].fd : -1),
@@ -1138,7 +1138,7 @@
        int ret = munmap(p, len);
 
 #ifdef MMAP_DEBUG
-       mnstr_printf(GDKerr, "#munmap(" LLFMT "," LLFMT ",%d) = %d\n", (long 
long) p, (long long) len, ret);
+       mnstr_printf(GDKstdout, "#munmap(" LLFMT "," LLFMT ",%d) = %d\n", (long 
long) p, (long long) len, ret);
 #endif
        MT_mmap_del(p, len);
        return ret;
@@ -1150,7 +1150,7 @@
        int ret = msync(((char *) p) + off, len, (mode & MMAP_SYNC) ? MS_SYNC : 
((mode & MMAP_ASYNC) ? MS_ASYNC : MS_INVALIDATE));
 
 #ifdef MMAP_DEBUG
-       mnstr_printf(GDKerr,
+       mnstr_printf(GDKstdout,
                      "#msync(" LLFMT "," LLFMT ",%s) = %d\n",
                      (long long) p, (long long) len,
                      (mode & MMAP_SYNC) ? "MS_SYNC" : ((mode & MMAP_ASYNC) ? 
"MS_ASYNC" : "MS_INVALIDATE"),
@@ -1167,7 +1167,7 @@
        int ret = posix_madvise(p, len & ~(MT_pagesize() - 1), advice);
 
 #ifdef MMAP_DEBUG
-       mnstr_printf(GDKerr, "#posix_madvise(" PTRFMT "," SZFMT ",%d) = %d\n",
+       mnstr_printf(GDKstdout, "#posix_madvise(" PTRFMT "," SZFMT ",%d) = 
%d\n",
                      PTRFMTCAST p, len, advice, ret);
 #endif
        if (MT_fadvise(p, len, advice))
@@ -1547,7 +1547,7 @@
        }
        if (heapstatus == _HEAPBADPTR || heapstatus == _HEAPBADBEGIN || 
heapstatus == _HEAPBADNODE) {
 
-               mnstr_printf(GDKerr, "#mallinfo(): heap is corrupt.");
+               mnstr_printf(GDKstdout, "#mallinfo(): heap is corrupt.");
        }
        _heapmin();
        return _ret;
@@ -1744,7 +1744,7 @@
                /* it could be the <expletive deleted> indexing
                 * service which prevents us from doing what we have a
                 * right to do, so try again (once) */
-               IODEBUG THRprintf(GDKout, "#retry rename %s %s\n", old, new);
+               IODEBUG THRprintf(GDKstdout, "#retry rename %s %s\n", old, new);
                MT_sleep_ms(100);       /* wait a little */
                ret = rename(old, new);
        }
@@ -2029,7 +2029,7 @@
        p = (void *) VirtualAlloc(a, size, MEM_COMMIT | mode, PAGE_READWRITE);
        (void) pthread_mutex_unlock(&MT_mmap_lock);
        if (p == NULL) {
-               mnstr_printf(GDKerr, "#VirtualAlloc(" PTRFMT "," SZFMT 
",MEM_COMMIT,PAGE_READWRITE): failed\n", PTRFMTCAST a, size);
+               mnstr_printf(GDKstdout, "#VirtualAlloc(" PTRFMT "," SZFMT 
",MEM_COMMIT,PAGE_READWRITE): failed\n", PTRFMTCAST a, size);
        }
        return p;
 }
@@ -2039,9 +2039,9 @@
 MT_vmfree(void *p, size_t size)
 {
        if (VirtualFree(p, size, MEM_DECOMMIT) == 0)
-               mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT "," SZFMT 
",MEM_DECOMMIT): failed\n", PTRFMTCAST p, size);
+               mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT "," SZFMT 
",MEM_DECOMMIT): failed\n", PTRFMTCAST p, size);
        if (VirtualFree(p, 0, MEM_RELEASE) == 0)
-               mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT ",0,MEM_RELEASE): 
failed\n", PTRFMTCAST p);
+               mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT 
",0,MEM_RELEASE): failed\n", PTRFMTCAST p);
 }
 
 void *
@@ -2062,7 +2062,7 @@
                size_t ret = VirtualFree(p + newsize, oldsize - newsize, 
MEM_DECOMMIT);
 
                if (ret == 0)
-                       mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT "," SSZFMT 
",MEM_DECOMMIT): failed\n", PTRFMTCAST(p + newsize), (ssize_t) (oldsize - 
newsize));
+                       mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT "," 
SSZFMT ",MEM_DECOMMIT): failed\n", PTRFMTCAST(p + newsize), (ssize_t) (oldsize 
- newsize));
        } else if (oldsize < newsize) {
                (void) pthread_mutex_lock(&MT_mmap_lock);
                a = (char *) VirtualAlloc(p, newsize, MEM_COMMIT, 
PAGE_READWRITE);
diff --git a/gdk/gdk_utils.mx b/gdk/gdk_utils.mx
--- a/gdk/gdk_utils.mx
+++ b/gdk/gdk_utils.mx
@@ -1433,7 +1433,7 @@
                GDKmemfail("GDKmmap", len, 0, BBPTRIM_ALL);
                ret = MT_mmap(path, mode, off, len);
                if (ret != (void *) -1L) {
-                       THRprintf(GDKout, "#GDKmmap: recovery ok. 
Continuing..\n");
+                       THRprintf(GDKstdout, "#GDKmmap: recovery ok. 
Continuing..\n");
                }
        }
        ALLOCDEBUG fprintf(stderr, "#GDKmmap " LLFMT " " SZFMT " " PTRFMT "\n", 
(lng) off, len, PTRFMTCAST ret);
@@ -1483,7 +1483,7 @@
                        MT_alloc_print();
                        GDKfatal("GDKvmalloc: failed for " SZFMT " bytes", 
size);
                } else {
-                       THRprintf(GDKout, "#GDKvmalloc(" SZFMT "): recovery ok. 
Continuing..\n", size);
+                       THRprintf(GDKstdout, "#GDKvmalloc(" SZFMT "): recovery 
ok. Continuing..\n", size);
                }
        }
        ALLOCDEBUG fprintf(stderr, "#GDKvmalloc " SZFMT " " SZFMT " " PTRFMT 
"\n", size, *maxsize, PTRFMTCAST ret);
@@ -1510,7 +1510,7 @@
                        MT_alloc_print();
                        GDKfatal("GDKvmrealloc: failed for " SZFMT " bytes 
(from " SZFMT ")", newsize, oldsize);
                } else {
-                       THRprintf(GDKout, "#GDKvmrealloc(" SZFMT "): recovery 
ok. Continuing..\n", newsize);
+                       THRprintf(GDKstdout, "#GDKvmrealloc(" SZFMT "): 
recovery ok. Continuing..\n", newsize);
                }
        }
        ALLOCDEBUG fprintf(stderr, "#GDKvmrealloc " SZFMT " " SZFMT " " PTRFMT 
" " PTRFMT "\n", newsize, *newmax, PTRFMTCAST pold, PTRFMTCAST ret);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to