]> arthur.barton.de Git - netatalk.git/commitdiff
default to use fault_setup, ie sbt logging and add a macro AFP_PANIC using it
authorFrank Lahm <franklahm@googlemail.com>
Fri, 24 Sep 2010 15:07:56 +0000 (17:07 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 24 Sep 2010 15:07:56 +0000 (17:07 +0200)
etc/afpd/dircache.c
etc/afpd/directory.c
etc/afpd/main.c
include/atalk/util.h
libatalk/util/fault.c

index edec2237bc53159fa75aad6b62fb61e07b033bcc..1923fc32a49ded595179918736d7e4ca068cf159 100644 (file)
@@ -1,5 +1,4 @@
 /*
-  $Id: dircache.c,v 1.1.2.7 2010-02-11 13:06:54 franklahm Exp $
   Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -173,7 +172,6 @@ static int hash_comp_didname(const void *k1, const void *k2)
 
 static q_t *index_queue;    /* the index itself */
 static unsigned int queue_count;
-static const int dircache_free_quantum = 256; /* number of entries to free */
 
 /*!
  * @brief Remove a fixed number of (oldest) entries from the cache and indexes
@@ -187,7 +185,7 @@ static const int dircache_free_quantum = 256; /* number of entries to free */
  */
 static void dircache_evict(void)
 {
-    int i = dircache_free_quantum;
+    int i = DIRCACHE_FREE_QUANTUM;
     struct dir *dir;
 
     LOG(log_debug, logtype_afpd, "dircache: {starting cache eviction}");
@@ -195,7 +193,7 @@ static void dircache_evict(void)
     while (i--) {
         if ((dir = (struct dir *)dequeue(index_queue)) == NULL) { /* 1 */
             dircache_dump();
-            exit(EXITERR_SYS);
+            AFP_PANIC("dircache_evict");
         }
         queue_count--;
 
@@ -204,7 +202,7 @@ static void dircache_evict(void)
             || (dir->d_flags & DIRF_CACHELOCK)) {     /* 2 */
             if ((dir->qidx_node = enqueue(index_queue, dir)) == NULL) {
                 dircache_dump();
-                exit(EXITERR_SYS);
+                AFP_PANIC("dircache_evict");
             }
             queue_count++;
             continue;
@@ -377,7 +375,7 @@ void dircache_remove(const struct vol *vol _U_, struct dir *dir, int flags)
             LOG(log_error, logtype_default, "dircache_remove(%u,%s): not in didname index", 
                 ntohl(dir->d_did), dir->d_u_name);
             dircache_dump();
-            exit(EXITERR_SYS);
+            AFP_PANIC("dircache_remove");
         }
         hash_delete(index_didname, hn);
     }
@@ -387,7 +385,7 @@ void dircache_remove(const struct vol *vol _U_, struct dir *dir, int flags)
             LOG(log_error, logtype_default, "dircache_remove(%u,%s): not in dircache", 
                 ntohl(dir->d_did), dir->d_u_name);
             dircache_dump();
-            exit(EXITERR_SYS);
+            AFP_PANIC("dircache_remove");
         }
         hash_delete(dircache, hn);
     }
index e8cc7f611e798613a11f8f4646b5fe67c73f7dca..76798d9bf60e39e81b4daef4afc9d046009fa3c3 100644 (file)
@@ -786,7 +786,7 @@ struct dir *dir_add(const struct vol *vol, const struct dir *dir, struct path *p
             ntohl(cdir->d_did), cfrombstring(dir->d_fullpath));
         if (dir_remove(vol, cdir) != 0) {
             dircache_dump();
-            exit(EXITERR_SYS);
+            AFP_PANIC("dir_add");
         }
     }
 
@@ -966,7 +966,7 @@ int dir_modify(const struct vol *vol,
     /* Re-add it to the cache */
     if ((dircache_add(dir)) != 0) {
         dircache_dump();
-        exit(EXITERR_SYS);
+        AFP_PANIC("dir_modify");
     }
 
     return ret;
@@ -2294,7 +2294,6 @@ int afp_mapid(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *r
     sfunc = (unsigned char) *ibuf++;
     *rbuflen = 0;
 
-
     if (sfunc >= 3 && sfunc <= 6) {
         if (afp_version < 30) {
             return( AFPERR_PARAM );
index 826ea44008b5bab922db7d20cbefd8613434fbdf..32d44d95614f4fa91d17d9e1ef546f5395180a19 100644 (file)
@@ -147,9 +147,9 @@ int main(int ac, char **av)
     set_auth_parameters( ac, av );
 #endif /* TRU64 */
 
-#ifdef DEBUG1
+    /* Log SIGBUS/SIGSEGV SBT */
     fault_setup(NULL);
-#endif
+
     afp_options_init(&default_options);
     if (!afp_options_parse(ac, av, &default_options))
         exit(EXITERR_CONF);
index 080b13408a216f153d18120bf3f3a075f7d7c9f3..efb31082370ffaea9f19bedd12a427c5f0de64d7 100644 (file)
 #define EXITERR_CONF 2  /* error in config files/cmd line parameters */
 #define EXITERR_SYS  3  /* local system error */
 
+/* Print a SBT and exit */
+#define AFP_PANIC(why) \
+    do {                                            \
+        netatalk_panic(why);                        \
+        exit(1);                                    \
+    } while(0);
+
 /* LOG assert errors */
 #ifndef NDEBUG
 #define AFP_ASSERT(b) \
     do {                                                                \
         if (!(b)) {                                                     \
-            LOG(log_error, logtype_default, "PANIC, assert failed: %s", #b); \
-            abort();                                                    \
+            AFP_PANIC(#b);                                              \
         } \
     } while(0);
 #else
@@ -56,9 +62,9 @@ extern int atalk_aton     (char *, struct at_addr *);
 extern void bprint        (char *, int);
 extern int strdiacasecmp  (const char *, const char *);
 extern int strndiacasecmp (const char *, const char *, size_t);
-extern pid_t server_lock  (char * /*program*/, char * /*file*/, 
-                              int /*debug*/);
+extern pid_t server_lock  (char * /*program*/, char * /*file*/, int /*debug*/);
 extern void fault_setup          (void (*fn)(void *));
+extern void netatalk_panic(const char *why);
 #define server_unlock(x)  (unlink(x))
 
 /* strlcpy and strlcat are used by pam modules */
index 7ef4fb8a5143cac21ddc8c6bc604d60ca82822a2..c9bce38c39272a66091a6d23ca0bb0093ce4cba8 100644 (file)
@@ -22,8 +22,6 @@
 #include "config.h"
 #endif
 
-#ifdef DEBUG1
-
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -84,65 +82,28 @@ static void (*CatchSignal(int signum,void (*handler)(int )))(int)
  Something really nasty happened - panic !
 ********************************************************************/
 
-static void smb_panic(const char *why)
+void netatalk_panic(const char *why)
 {
-#if 0
-       char *cmd;
-       int result;
-#endif
 #ifdef HAVE_BACKTRACE_SYMBOLS
        void *backtrace_stack[BACKTRACE_STACK_SIZE];
        size_t backtrace_size;
        char **backtrace_strings;
-#endif
-
-#ifdef DEVELOPER
-       {
-               extern char *global_clobber_region_function;
-               extern unsigned int global_clobber_region_line;
-
-               if (global_clobber_region_function) {
-                       DEBUG(0,("smb_panic: clobber_region() last called from [%s(%u)]",
-                                        global_clobber_region_function,
-                                        global_clobber_region_line));
-               } 
-       }
-#endif
 
-#if 0
-       cmd = lp_panic_action();
-       if (cmd && *cmd) {
-               DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd));
-               result = system(cmd);
-
-               if (result == -1)
-                       DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
-                                         strerror(errno)));
-               else
-                       DEBUG(0, ("smb_panic(): action returned status %d\n",
-                                         WEXITSTATUS(result)));
-       }
-       DEBUG(0,("PANIC: %s\n", why));
-#endif
-
-#ifdef HAVE_BACKTRACE_SYMBOLS
        /* get the backtrace (stack frames) */
        backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE);
        backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size);
 
-       LOG(log_error, logtype_default, "BACKTRACE: %d stack frames:\n", backtrace_size);
+       LOG(log_severe, logtype_default, "BACKTRACE: %d stack frames:", backtrace_size);
        
        if (backtrace_strings) {
                size_t i;
 
                for (i = 0; i < backtrace_size; i++)
-                       LOG(log_error, logtype_default, " #%u %s", i, backtrace_strings[i]);
+                       LOG(log_severe, logtype_default, " #%u %s", i, backtrace_strings[i]);
 
                SAFE_FREE(backtrace_strings);
        }
-
 #endif
-
 }
 
 
@@ -157,11 +118,11 @@ static void fault_report(int sig)
 
        counter++;
 
-       LOG(log_error, logtype_default, "===============================================================");
-       LOG(log_error, logtype_default, "INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION);
-       LOG(log_error, logtype_default, "===============================================================");
+       LOG(log_severe, logtype_default, "===============================================================");
+       LOG(log_severe, logtype_default, "INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION);
+       LOG(log_severe, logtype_default, "===============================================================");
   
-       smb_panic("internal error");
+       netatalk_panic("internal error");
 
        if (cont_fn) {
                cont_fn(NULL);
@@ -199,4 +160,3 @@ void fault_setup(void (*fn)(void *))
 #endif
 }
 
-#endif