瀏覽代碼

[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 16 年之前
父節點
當前提交
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
  * method handler.
188
  * method handler.
189
  */
189
  */
190
 int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) {
190
 int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) {
191
-	struct xfer_interface_operations *op = xfer->op;
192
 
191
 
193
 	/* Close existing connection */
192
 	/* Close existing connection */
194
-	xfer_nullify ( xfer );
195
 	xfer_close ( xfer, 0 );
193
 	xfer_close ( xfer, 0 );
196
 
194
 
197
-	/* Restore to operational status */
198
-	xfer->op = op;
199
-
200
 	/* Open new location */
195
 	/* Open new location */
201
 	return xfer_vopen ( xfer, type, args );
196
 	return xfer_vopen ( xfer, type, args );
202
 }
197
 }

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

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

Loading…
取消
儲存