瀏覽代碼

[xfer] Always nullify interface while sending close() message

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>
tags/v0.9.8
Michael Brown 15 年之前
父節點
當前提交
b7e93a6a55
共有 2 個文件被更改,包括 3 次插入5 次删除
  1. 0
    5
      src/core/open.c
  2. 3
    0
      src/core/xfer.c

+ 0
- 5
src/core/open.c 查看文件

@@ -188,15 +188,10 @@ int xfer_open ( struct xfer_interface *xfer, int type, ... ) {
188 188
  * method handler.
189 189
  */
190 190
 int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) {
191
-	struct xfer_interface_operations *op = xfer->op;
192 191
 
193 192
 	/* Close existing connection */
194
-	xfer_nullify ( xfer );
195 193
 	xfer_close ( xfer, 0 );
196 194
 
197
-	/* Restore to operational status */
198
-	xfer->op = op;
199
-
200 195
 	/* Open new location */
201 196
 	return xfer_vopen ( xfer, type, args );
202 197
 }

+ 3
- 0
src/core/xfer.c 查看文件

@@ -45,11 +45,14 @@ static struct xfer_metadata dummy_metadata;
45 45
  */
46 46
 void xfer_close ( struct xfer_interface *xfer, int rc ) {
47 47
 	struct xfer_interface *dest = xfer_get_dest ( xfer );
48
+	struct xfer_interface_operations *op = xfer->op;
48 49
 
49 50
 	DBGC ( xfer, "XFER %p->%p close\n", xfer, dest );
50 51
 
51 52
 	xfer_unplug ( xfer );
53
+	xfer_nullify ( xfer );
52 54
 	dest->op->close ( dest, rc );
55
+	xfer->op = op;
53 56
 	xfer_put ( dest );
54 57
 }
55 58
 

Loading…
取消
儲存