summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2016-11-16 23:22:13 +0100
committerMichael Brown2016-11-16 23:22:13 +0100
commitdaa8ed9274d91a157dc049f00792f62c98b0a11a (patch)
tree7ce6edec2f46a6fcab3c0a1edc9c989e2b6c3885 /src
parent[build] Disable TIVOLI_VMM_WORKAROUND in the qemu configuration (diff)
downloadipxe-daa8ed9274d91a157dc049f00792f62c98b0a11a.tar.gz
ipxe-daa8ed9274d91a157dc049f00792f62c98b0a11a.tar.xz
ipxe-daa8ed9274d91a157dc049f00792f62c98b0a11a.zip
[interface] Provide intf_reinit() to reinitialise nullified interfaces
Provide an abstraction intf_reinit() to restore the descriptor of a previously nullified interface. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/interface.c3
-rw-r--r--src/include/ipxe/interface.h18
-rw-r--r--src/net/tcp/httpcore.c5
3 files changed, 20 insertions, 6 deletions
diff --git a/src/core/interface.c b/src/core/interface.c
index ba148c13..948fa5c5 100644
--- a/src/core/interface.c
+++ b/src/core/interface.c
@@ -295,7 +295,6 @@ void intf_shutdown ( struct interface *intf, int rc ) {
* blocked during shutdown.
*/
void intf_restart ( struct interface *intf, int rc ) {
- struct interface_descriptor *desc = intf->desc;
/* Shut down the interface */
intf_shutdown ( intf, rc );
@@ -309,7 +308,7 @@ void intf_restart ( struct interface *intf, int rc ) {
* infinite loop as the intf_close() operations on each side
* of the link call each other recursively.
*/
- intf->desc = desc;
+ intf_reinit ( intf );
}
/**
diff --git a/src/include/ipxe/interface.h b/src/include/ipxe/interface.h
index a8d82377..ebb1b691 100644
--- a/src/include/ipxe/interface.h
+++ b/src/include/ipxe/interface.h
@@ -123,6 +123,11 @@ struct interface {
struct refcnt *refcnt;
/** Interface descriptor */
struct interface_descriptor *desc;
+ /** Original interface descriptor
+ *
+ * Used by intf_reinit().
+ */
+ struct interface_descriptor *original;
};
extern void intf_plug ( struct interface *intf, struct interface *dest );
@@ -166,6 +171,7 @@ static inline void intf_init ( struct interface *intf,
intf->dest = &null_intf;
intf->refcnt = refcnt;
intf->desc = desc;
+ intf->original = desc;
}
/**
@@ -177,6 +183,7 @@ static inline void intf_init ( struct interface *intf,
.dest = &null_intf, \
.refcnt = NULL, \
.desc = &(descriptor), \
+ .original = &(descriptor), \
}
/**
@@ -236,4 +243,15 @@ static inline void intf_init ( struct interface *intf,
*/
#define INTF_INTF_DBG( intf, dest ) INTF_DBG ( intf ), INTF_DBG ( dest )
+/**
+ * Reinitialise an object interface
+ *
+ * @v intf Object interface
+ */
+static inline void intf_reinit ( struct interface *intf ) {
+
+ /* Restore original interface descriptor */
+ intf->desc = intf->original;
+}
+
#endif /* _IPXE_INTERFACE_H */
diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c
index b1f74bc4..27cc5065 100644
--- a/src/net/tcp/httpcore.c
+++ b/src/net/tcp/httpcore.c
@@ -787,12 +787,9 @@ static int http_transfer_complete ( struct http_transaction *http ) {
/* Restart content decoding interfaces (which may be attached
* to the same object).
*/
- intf_nullify ( &http->content );
- intf_nullify ( &http->transfer );
+ intf_nullify ( &http->transfer ); /* avoid potential loops */
intf_restart ( &http->content, http->response.rc );
intf_restart ( &http->transfer, http->response.rc );
- http->content.desc = &http_content_desc;
- http->transfer.desc = &http_transfer_desc;
intf_plug_plug ( &http->transfer, &http->content );
http->len = 0;
assert ( http->remaining == 0 );