瀏覽代碼

[syslog] Disable console when no syslog server is defined

Explicitly disable the syslog console when no syslog server is
defined, rather than (ab)using the socket family address as an
equivalent console-enabled flag.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 年之前
父節點
當前提交
c72b8969e2
共有 1 個文件被更改,包括 5 次插入7 次删除
  1. 5
    7
      src/net/udp/syslog.c

+ 5
- 7
src/net/udp/syslog.c 查看文件

@@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
37 37
 
38 38
 /** The syslog server */
39 39
 static struct sockaddr_tcpip logserver = {
40
+	.st_family = AF_INET,
40 41
 	.st_port = htons ( SYSLOG_PORT ),
41 42
 };
42 43
 
@@ -84,10 +85,6 @@ static struct ansiesc_context syslog_ansiesc_ctx = {
84 85
 static void syslog_putchar ( int character ) {
85 86
 	int rc;
86 87
 
87
-	/* Do nothing if we have no log server */
88
-	if ( ! logserver.st_family )
89
-		return;
90
-
91 88
 	/* Ignore if we are already mid-logging */
92 89
 	if ( syslog_entered )
93 90
 		return;
@@ -136,6 +133,7 @@ static void syslog_putchar ( int character ) {
136 133
 /** Syslog console driver */
137 134
 struct console_driver syslog_console __console_driver = {
138 135
 	.putchar = syslog_putchar,
136
+	.disabled = 1,
139 137
 };
140 138
 
141 139
 /******************************************************************************
@@ -166,11 +164,11 @@ static int apply_syslog_settings ( void ) {
166 164
 	int rc;
167 165
 
168 166
 	/* Fetch log server */
167
+	syslog_console.disabled = 1;
169 168
 	old_addr.s_addr = sin_logserver->sin_addr.s_addr;
170
-	logserver.st_family = 0;
171 169
 	if ( ( len = fetch_ipv4_setting ( NULL, &syslog_setting,
172 170
 					  &sin_logserver->sin_addr ) ) >= 0 ) {
173
-		sin_logserver->sin_family = AF_INET;
171
+		syslog_console.disabled = 0;
174 172
 	}
175 173
 
176 174
 	/* Do nothing unless log server has changed */
@@ -181,7 +179,7 @@ static int apply_syslog_settings ( void ) {
181 179
 	intf_restart ( &syslogger, 0 );
182 180
 
183 181
 	/* Do nothing unless we have a log server */
184
-	if ( ! logserver.st_family ) {
182
+	if ( syslog_console.disabled ) {
185 183
 		DBG ( "SYSLOG has no log server\n" );
186 184
 		return 0;
187 185
 	}

Loading…
取消
儲存