소스 검색

[interface] Default to calling intf_restart() in response to intf_close()

If an object interface does not provide an intf_close() method, then
default to calling intf_restart().  This allows static objects to
safely ignore intf_close(), without needing to add code solely to
ensure that the interface gets unplugged.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 년 전
부모
커밋
a3346e3587
1개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제
  1. 19
    2
      src/core/interface.c

+ 19
- 2
src/core/interface.c 파일 보기

@@ -34,8 +34,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
34 34
  *
35 35
  */
36 36
 
37
+/**
38
+ * Close null interface
39
+ *
40
+ * @v intf		Null interface
41
+ * @v rc		Reason for close
42
+ */
43
+static void null_intf_close ( struct interface *intf __unused,
44
+			      int rc __unused ) {
45
+
46
+	/* Do nothing.  In particular, do not call intf_restart(),
47
+	 * since that would result in an infinite loop.
48
+	 */
49
+}
50
+
37 51
 /** Null interface operations */
38
-static struct interface_operation null_intf_op[] = {};
52
+static struct interface_operation null_intf_op[] = {
53
+	INTF_OP ( intf_close, struct interface *, null_intf_close ),
54
+};
39 55
 
40 56
 /** Null interface descriptor */
41 57
 struct interface_descriptor null_intf_desc =
@@ -233,7 +249,8 @@ void intf_close ( struct interface *intf, int rc ) {
233 249
 	if ( op ) {
234 250
 		op ( object, rc );
235 251
 	} else {
236
-		/* Default is to ignore intf_close() */
252
+		/* Default is to restart the interface */
253
+		intf_restart ( dest, rc );
237 254
 	}
238 255
 
239 256
 	intf_put ( dest );

Loading…
취소
저장