/*
- $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
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
*/
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}");
while (i--) {
if ((dir = (struct dir *)dequeue(index_queue)) == NULL) { /* 1 */
dircache_dump();
- exit(EXITERR_SYS);
+ AFP_PANIC("dircache_evict");
}
queue_count--;
|| (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;
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);
}
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);
}
ntohl(cdir->d_did), cfrombstring(dir->d_fullpath));
if (dir_remove(vol, cdir) != 0) {
dircache_dump();
- exit(EXITERR_SYS);
+ AFP_PANIC("dir_add");
}
}
/* Re-add it to the cache */
if ((dircache_add(dir)) != 0) {
dircache_dump();
- exit(EXITERR_SYS);
+ AFP_PANIC("dir_modify");
}
return ret;
sfunc = (unsigned char) *ibuf++;
*rbuflen = 0;
-
if (sfunc >= 3 && sfunc <= 6) {
if (afp_version < 30) {
return( AFPERR_PARAM );
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);
#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
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 */
#include "config.h"
#endif
-#ifdef DEBUG1
-
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
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
-
}
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);
#endif
}
-#endif