lib/fault.c

ソースコードを見る。

関数

static void fault_report (int sig)
static void sig_fault (int sig)
void fault_setup (void(*fn)(void *))
void dump_core_setup (const char *progname)
void dump_core (void)

変数

static void(*) cont_fn (void *)
static pstring corepath


関数

static void fault_report ( int  sig  )  [static]

fault.c33 行で定義されています。

参照先 CatchSignal()cont_fncountersmb_panic()sys_getpid().

参照元 sig_fault().

00034 {
00035         static int counter;
00036 
00037         if (counter) _exit(1);
00038 
00039         counter++;
00040 
00041         DEBUGSEP(0);
00042         DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
00043         DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba3-HOWTO\n"));
00044         DEBUG(0,("\nFrom: http://www.samba.org/samba/docs/Samba3-HOWTO.pdf\n"));
00045         DEBUGSEP(0);
00046   
00047         smb_panic("internal error");
00048 
00049         if (cont_fn) {
00050                 cont_fn(NULL);
00051 #ifdef SIGSEGV
00052                 CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
00053 #endif
00054 #ifdef SIGBUS
00055                 CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
00056 #endif
00057 #ifdef SIGABRT
00058                 CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
00059 #endif
00060                 return; /* this should cause a core dump */
00061         }
00062         exit(1);
00063 }

static void sig_fault ( int  sig  )  [static]

fault.c68 行で定義されています。

参照先 fault_report().

参照元 fault_setup().

00069 {
00070         fault_report(sig);
00071 }

void fault_setup ( void(*)(void *)  fn  ) 

fault.c76 行で定義されています。

参照先 CatchSignal()cont_fnsig_fault().

参照元 main()parse_quota_set().

00077 {
00078         cont_fn = fn;
00079 
00080 #ifdef SIGSEGV
00081         CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
00082 #endif
00083 #ifdef SIGBUS
00084         CatchSignal(SIGBUS,SIGNAL_CAST sig_fault);
00085 #endif
00086 #ifdef SIGABRT
00087         CatchSignal(SIGABRT,SIGNAL_CAST sig_fault);
00088 #endif
00089 }

void dump_core_setup ( const char *  progname  ) 

fault.c95 行で定義されています。

参照先 corepathdyn_LOGFILEBASEsnprintf()strrchr_m()sys_chown().

参照元 main().

00096 {
00097         pstring logbase;
00098         char * end;
00099 
00100         if (lp_logfile() && *lp_logfile()) {
00101                 snprintf(logbase, sizeof(logbase), "%s", lp_logfile());
00102                 if ((end = strrchr_m(logbase, '/'))) {
00103                         *end = '\0';
00104                 }
00105         } else {
00106                 /* We will end up here is the log file is given on the command
00107                  * line by the -l option but the "log file" option is not set
00108                  * in smb.conf.
00109                  */
00110                 snprintf(logbase, sizeof(logbase), "%s", dyn_LOGFILEBASE);
00111         }
00112 
00113         SMB_ASSERT(progname != NULL);
00114 
00115         snprintf(corepath, sizeof(corepath), "%s/cores", logbase);
00116         mkdir(corepath,0700);
00117 
00118         snprintf(corepath, sizeof(corepath), "%s/cores/%s",
00119                 logbase, progname);
00120         mkdir(corepath,0700);
00121 
00122         sys_chown(corepath,getuid(),getgid());
00123         chmod(corepath,0700);
00124 
00125 #ifdef HAVE_GETRLIMIT
00126 #ifdef RLIMIT_CORE
00127         {
00128                 struct rlimit rlp;
00129                 getrlimit(RLIMIT_CORE, &rlp);
00130                 rlp.rlim_cur = MAX(16*1024*1024,rlp.rlim_cur);
00131                 setrlimit(RLIMIT_CORE, &rlp);
00132                 getrlimit(RLIMIT_CORE, &rlp);
00133                 DEBUG(3,("Maximum core file size limits now %d(soft) %d(hard)\n",
00134                          (int)rlp.rlim_cur,(int)rlp.rlim_max));
00135         }
00136 #endif
00137 #endif
00138 
00139 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
00140         /* On Linux we lose the ability to dump core when we change our user
00141          * ID. We know how to dump core safely, so let's make sure we have our
00142          * dumpable flag set.
00143          */
00144         prctl(PR_SET_DUMPABLE, 1);
00145 #endif
00146 
00147         /* FIXME: if we have a core-plus-pid facility, configurably set
00148          * this up here.
00149          */
00150 }

void dump_core ( void   ) 

fault.c152 行で定義されています。

参照先 become_root()CatchSignal()corepathdbgflush().

参照元 exit_server_common()fault_continue()fault_quit()smb_panic().

00153 {
00154         /* Note that even if core dumping has been disabled, we still set up
00155          * the core path. This is to handle the case where core dumping is
00156          * turned on in smb.conf and the relevant daemon is not restarted.
00157          */
00158         if (!lp_enable_core_files()) {
00159                 DEBUG(0, ("Exiting on internal error (core file administratively disabled)\n"));
00160                 exit(1);
00161         }
00162 
00163 #if DUMP_CORE
00164         /* If we're running as non root we might not be able to dump the core
00165          * file to the corepath.  There must not be an unbecome_root() before
00166          * we call abort(). */
00167         if (geteuid() != 0) {
00168                 become_root();
00169         }
00170 
00171         if (*corepath != '\0') {
00172                 /* The chdir might fail if we dump core before we finish
00173                  * processing the config file.
00174                  */
00175                 if (chdir(corepath) != 0) {
00176                         DEBUG(0, ("unable to change to %s\n", corepath));
00177                         DEBUGADD(0, ("refusing to dump core\n"));
00178                         exit(1);
00179                 }
00180 
00181                 DEBUG(0,("dumping core in %s\n", corepath));
00182         }
00183 
00184         umask(~(0700));
00185         dbgflush();
00186 
00187         /* Ensure we don't have a signal handler for abort. */
00188 #ifdef SIGABRT
00189         CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
00190 #endif
00191 
00192         abort();
00193 
00194 #else /* DUMP_CORE */
00195         exit(1);
00196 #endif /* DUMP_CORE */
00197 }


変数

void(*) cont_fn(void *) [static]

fault.c27 行で定義されています。

参照元 fault_report()fault_setup().

pstring corepath [static]

fault.c28 行で定義されています。

参照元 dump_core()dump_core_setup().


Sambaに対してSat Aug 29 21:23:36 2009に生成されました。  doxygen 1.4.7