Re: [libvirt] [PATCHv3 1/6] DO NOT APPLY UPSTREAM: Close callback race corruption crash reproducer.

2013-04-01 Thread Eric Blake
On 03/31/2013 10:20 AM, Peter Krempa wrote:
 ---
  src/remote/remote_driver.c | 5 +
  src/rpc/virnetclient.c | 9 -
  2 files changed, 13 insertions(+), 1 deletion(-)

While I agree that this must not be applied upstream, I applied it
locally and was indeed able to more reliably reproduce the problems.
Thanks; having this patch in place locally will make the rest of my
review easier.

 
 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
 index 885120e..711143a 100644
 --- a/src/remote/remote_driver.c
 +++ b/src/remote/remote_driver.c
 @@ -1027,6 +1027,11 @@ doRemoteClose(virConnectPtr conn, struct private_data 
 *priv)
   (xdrproc_t) xdr_void, (char *) NULL) == -1)
  ret = -1;
 
 +/* this is needed so that the remote side has the time to close the 
 socket */
 +printf(\n\n DEBUG: Connection close called, sleeping\n\n);
 +sleep(1);
 +printf(\n\n DEBUG: Finishing close\n\n);
 +
  #ifdef WITH_GNUTLS
  virObjectUnref(priv-tls);
  priv-tls = NULL;
 diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
 index 010c5c3..51b80a2 100644
 --- a/src/rpc/virnetclient.c
 +++ b/src/rpc/virnetclient.c
 @@ -674,8 +674,15 @@ virNetClientCloseLocked(virNetClientPtr client)
  virKeepAliveStop(ka);
  virObjectUnref(ka);
  }
 -if (closeCb)
 +if (closeCb) {
 +/* the callback has to delay for a while until the connection 
 object
 + * is being freed in the original thread that closed the 
 connection
 + * */
 +printf(\n\n DEBUG: calling the close callback\n\n);
 +sleep(2);
  closeCb(client, closeReason, closeOpaque);
 +printf(\n\n DEBUG: callback returned\n\n);
 +}
 
  virObjectLock(client);
  virObjectUnref(client);
 

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCHv3 1/6] DO NOT APPLY UPSTREAM: Close callback race corruption crash reproducer.

2013-03-31 Thread Peter Krempa
---
 src/remote/remote_driver.c | 5 +
 src/rpc/virnetclient.c | 9 -
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 885120e..711143a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1027,6 +1027,11 @@ doRemoteClose(virConnectPtr conn, struct private_data 
*priv)
  (xdrproc_t) xdr_void, (char *) NULL) == -1)
 ret = -1;

+/* this is needed so that the remote side has the time to close the socket 
*/
+printf(\n\n DEBUG: Connection close called, sleeping\n\n);
+sleep(1);
+printf(\n\n DEBUG: Finishing close\n\n);
+
 #ifdef WITH_GNUTLS
 virObjectUnref(priv-tls);
 priv-tls = NULL;
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 010c5c3..51b80a2 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -674,8 +674,15 @@ virNetClientCloseLocked(virNetClientPtr client)
 virKeepAliveStop(ka);
 virObjectUnref(ka);
 }
-if (closeCb)
+if (closeCb) {
+/* the callback has to delay for a while until the connection 
object
+ * is being freed in the original thread that closed the connection
+ * */
+printf(\n\n DEBUG: calling the close callback\n\n);
+sleep(2);
 closeCb(client, closeReason, closeOpaque);
+printf(\n\n DEBUG: callback returned\n\n);
+}

 virObjectLock(client);
 virObjectUnref(client);
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list