degesch: show an error message on log write failure
Running out of space and I/O errors seem like the most likely causes.
This commit is contained in:
		
							
								
								
									
										19
									
								
								degesch.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								degesch.c
									
									
									
									
									
								
							@@ -12738,7 +12738,8 @@ on_display_full_log (int count, int key, void *user_data)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (ctx->current_buffer->log_file)
 | 
			
		||||
		fflush (ctx->current_buffer->log_file);
 | 
			
		||||
		// The regular flush will log any error eventually
 | 
			
		||||
		(void) fflush (ctx->current_buffer->log_file);
 | 
			
		||||
 | 
			
		||||
	set_cloexec (fileno (full_log));
 | 
			
		||||
	launch_backlog_helper (ctx, fileno (full_log));
 | 
			
		||||
@@ -13631,9 +13632,23 @@ rearm_flush_timer (struct app_context *ctx)
 | 
			
		||||
static void
 | 
			
		||||
on_flush_timer (struct app_context *ctx)
 | 
			
		||||
{
 | 
			
		||||
	// TODO: maybe also garbage collect all plugins?
 | 
			
		||||
	// I guess we don't need to do anything more complicated
 | 
			
		||||
	fflush (NULL);
 | 
			
		||||
 | 
			
		||||
	// It would be a bit problematic to handle it properly, so do this at least
 | 
			
		||||
	LIST_FOR_EACH (struct buffer, buffer, ctx->buffers)
 | 
			
		||||
	{
 | 
			
		||||
		if (!buffer->log_file || !ferror (buffer->log_file))
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		// Might be a transient error such as running out of disk space,
 | 
			
		||||
		// keep notifying of the problem until it disappears
 | 
			
		||||
		clearerr (buffer->log_file);
 | 
			
		||||
		log_global (ctx, BUFFER_LINE_ERROR | BUFFER_LINE_SKIP_FILE,
 | 
			
		||||
			"Log write failure detected for #s", buffer->name);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// TODO: maybe also garbage collect all plugins?
 | 
			
		||||
	rearm_flush_timer (ctx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user