mirror of https://github.com/ipxe/ipxe.git
[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>pull/59/head
parent
b991c67c1d
commit
daa8ed9274
|
@ -295,7 +295,6 @@ void intf_shutdown ( struct interface *intf, int rc ) {
|
||||||
* blocked during shutdown.
|
* blocked during shutdown.
|
||||||
*/
|
*/
|
||||||
void intf_restart ( struct interface *intf, int rc ) {
|
void intf_restart ( struct interface *intf, int rc ) {
|
||||||
struct interface_descriptor *desc = intf->desc;
|
|
||||||
|
|
||||||
/* Shut down the interface */
|
/* Shut down the interface */
|
||||||
intf_shutdown ( intf, rc );
|
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
|
* infinite loop as the intf_close() operations on each side
|
||||||
* of the link call each other recursively.
|
* of the link call each other recursively.
|
||||||
*/
|
*/
|
||||||
intf->desc = desc;
|
intf_reinit ( intf );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,6 +123,11 @@ struct interface {
|
||||||
struct refcnt *refcnt;
|
struct refcnt *refcnt;
|
||||||
/** Interface descriptor */
|
/** Interface descriptor */
|
||||||
struct interface_descriptor *desc;
|
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 );
|
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->dest = &null_intf;
|
||||||
intf->refcnt = refcnt;
|
intf->refcnt = refcnt;
|
||||||
intf->desc = desc;
|
intf->desc = desc;
|
||||||
|
intf->original = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,6 +183,7 @@ static inline void intf_init ( struct interface *intf,
|
||||||
.dest = &null_intf, \
|
.dest = &null_intf, \
|
||||||
.refcnt = NULL, \
|
.refcnt = NULL, \
|
||||||
.desc = &(descriptor), \
|
.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 )
|
#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 */
|
#endif /* _IPXE_INTERFACE_H */
|
||||||
|
|
|
@ -787,12 +787,9 @@ static int http_transfer_complete ( struct http_transaction *http ) {
|
||||||
/* Restart content decoding interfaces (which may be attached
|
/* Restart content decoding interfaces (which may be attached
|
||||||
* to the same object).
|
* to the same object).
|
||||||
*/
|
*/
|
||||||
intf_nullify ( &http->content );
|
intf_nullify ( &http->transfer ); /* avoid potential loops */
|
||||||
intf_nullify ( &http->transfer );
|
|
||||||
intf_restart ( &http->content, http->response.rc );
|
intf_restart ( &http->content, http->response.rc );
|
||||||
intf_restart ( &http->transfer, 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 );
|
intf_plug_plug ( &http->transfer, &http->content );
|
||||||
http->len = 0;
|
http->len = 0;
|
||||||
assert ( http->remaining == 0 );
|
assert ( http->remaining == 0 );
|
||||||
|
|
Loading…
Reference in New Issue