Ver Fonte

* Fix debug log file getting overwritten with NULLs

Bryan Drewery há 16 anos atrás
pai
commit
b3deccb1e4
3 ficheiros alterados com 8 adições e 2 exclusões
  1. 4 1
      src/log.c
  2. 3 0
      src/main.c
  3. 1 1
      src/main.h

+ 4 - 1
src/log.c

@@ -199,6 +199,7 @@ bool logfile_open()
   return 1;
 }
 
+#ifdef unused
 bool logfile_stat(const char *fname)
 {
   struct stat st;
@@ -214,10 +215,12 @@ bool logfile_stat(const char *fname)
   }
   return 1;
 }
+#endif
 
 void logfile(int type, const char *msg)
 {
-  if (!log_f && !logfile_open())
+  // Only log if this is an actual bot and not a startup/cron proc
+  if (!safe_to_log || (!log_f && !logfile_open()))
     return;
 
 //  if (!logfile_stat(".l"))

+ 3 - 0
src/main.c

@@ -95,6 +95,7 @@ const char	*egg_version = VERSION;
 char	git_version[50] = "";
 
 bool	used_B = 0;		/* did we get started with -B? */
+bool	safe_to_log = 0;
 int 	role;
 bool 	loading = 0;
 int	default_flags = 0;	/* Default user flags and */
@@ -801,6 +802,8 @@ int main(int argc, char **argv)
     }
   }
 
+  safe_to_log = 1;
+
   init_flags();			/* needed to establish FLAGS[] */
   core_binds_init();
   init_dcc();			/* needed if we are going to make any dcc */

+ 1 - 1
src/main.h

@@ -16,7 +16,7 @@ enum {
 
 extern int		role, default_flags, default_uflags, do_confedit,
 			updating, do_restart;
-extern bool		use_stderr, backgrd, used_B, term_z, loading, have_linked_to_hub, restart_was_update, restarting;
+extern bool		use_stderr, backgrd, used_B, term_z, loading, have_linked_to_hub, restart_was_update, restarting, safe_to_log;
 extern char		tempdir[], *binname, owner[], version[151], ver[101], quit_msg[], *socksfile;
 extern time_t		online_since, now, restart_time;
 extern egg_timeval_t	egg_timeval_now;