]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[xfer] Always nullify interface while sending close() message
authorMichael Brown <mcb30@etherboot.org>
Mon, 6 Jul 2009 15:16:59 +0000 (16:16 +0100)
committerMichael Brown <mcb30@etherboot.org>
Mon, 6 Jul 2009 15:16:59 +0000 (16:16 +0100)
Objects typically call xfer_close() as part of their response to a
close() message.  If the initiating object has already nullified the
xfer interface then this isn't a problem, but it can lead to
unexpected behaviour when the initiating object is aiming to reuse the
connection and so does not nullify the interface.

Fix by always temporarily nullifying the interface during xfer_close()
(as was already being done by xfer_vreopen() in order to work around
this specific problem).

Reported-by: infernix <infernix@infernix.net>
Tested-by: infernix <infernix@infernix.net>
src/core/open.c
src/core/xfer.c

index d5eb30cfaa02b77d0716af63e9f2890ffd4cf097..70b427ba2225b93b52ec31e867a26bb0cde4be5c 100644 (file)
@@ -188,15 +188,10 @@ int xfer_open ( struct xfer_interface *xfer, int type, ... ) {
  * method handler.
  */
 int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) {
-       struct xfer_interface_operations *op = xfer->op;
 
        /* Close existing connection */
-       xfer_nullify ( xfer );
        xfer_close ( xfer, 0 );
 
-       /* Restore to operational status */
-       xfer->op = op;
-
        /* Open new location */
        return xfer_vopen ( xfer, type, args );
 }
index a9bcb4d7bb06e488abee3e5b5b86bba2210cdc67..1ec6f9d3f216ec7e81783417f33e5358b9fe88de 100644 (file)
@@ -45,11 +45,14 @@ static struct xfer_metadata dummy_metadata;
  */
 void xfer_close ( struct xfer_interface *xfer, int rc ) {
        struct xfer_interface *dest = xfer_get_dest ( xfer );
+       struct xfer_interface_operations *op = xfer->op;
 
        DBGC ( xfer, "XFER %p->%p close\n", xfer, dest );
 
        xfer_unplug ( xfer );
+       xfer_nullify ( xfer );
        dest->op->close ( dest, rc );
+       xfer->op = op;
        xfer_put ( dest );
 }