GNOME Bugzilla – Bug 602156
GDataUploadStream should close GOutputStream on dispose
Last modified: 2009-11-21 20:23:21 UTC
I take the following assert (hit after calling g_cancellable_cancel () during an upload from gdata_picasaweb_service_upload_file ()) to indicate that I should implement a parse_error_response for GDataPicasaWebService. upload_thread (self=0xb412f920) at gdata-upload-stream.c:520 520 g_assert (klass->parse_error_response != NULL); Missing separate debuginfos, use: debuginfo-install expat-2.0.1-6.fc11.1.i586 gnutls-2.6.6-3.fc11.i586 lcms-libs-1.18-2.fc11.i586 libcroco-0.6.2-2.fc11.i586 libexif-0.6.16-3.fc11.i586 libproxy-0.2.3-10.fc11.i586 libvorbis-1.2.0-9.fc11.i586 nss-mdns-0.10-7.fc11.i586 pycairo-1.8.2-2.fc11.i586 pygobject2-2.16.1-4.fc11.i586 pygtk2-2.14.1-2.fc11.i586 (gdb) l 515 if (SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) { 516 GDataServiceClass *klass = GDATA_SERVICE_GET_CLASS (priv->service); 517 518 /* Error! Store it in the structure, and it'll be returned by the next function in the main thread 519 * which can give an error response.*/ 520 g_assert (klass->parse_error_response != NULL); 521 klass->parse_error_response (priv->service, GDATA_SERVICE_ERROR_WITH_UPLOAD, status, priv->message->reason_phrase, 522 priv->message->response_body->data, priv->message->response_body->length, &(priv->response_error)); 523 } 524
Did a little more debugging. (gdb) print priv->message $10 = (SoupMessage *) 0x0 (gdb) print status $11 = 403 (gdb) print priv->service $12 = (GDataService *) 0x0 Perhaps when I cancel early enough, message and service are never set? I think it's prompted by me unref'ing the GFileOutputStream:
+ Trace 219142
Thread 11 (Thread 0xaf3ffb70 (LWP 9240))
I'm going to try closing the GOutputStream before unrefing it, so I can provide it with our GCancellable. Ok, that seemed to work, but perhaps I just have bad luck with a race to dispose/versus cancel. Thoughts?
Created attachment 147949 [details] [review] Patch to close output stream before unreffing it This patch makes us close the output stream before unref'ing it. I'm not totally clear on how GCancellable works, but looking at it, I think this will fix the problem. Testing it, it does seem to.
Created attachment 147968 [details] [review] Bug 602156 — GDataUploadStream should close GOutputStream on dispose Close the GOutputStream before disposing private data for GDataUploadStream which could be referenced by threaded code called when the upload is cancelled. Closes: bgo#602156
Does my patch work? As you say, I think this is being caused by the GOutputStream being closed too late. GDataUploadStream should conform to the behaviour established by GOutputStream in that unreffing the stream should close it *first*.
Ah. That's a better place for it then :) Your patch seems to fix the issue, too.
commit 35a970c145c0390c6cbd663b7d04f515901cd2fc Author: Philip Withnall <philip@tecnocode.co.uk> Date: Tue Nov 17 12:46:39 2009 +0000 Bug 602156 — GDataUploadStream should close GOutputStream on dispose Close the GOutputStream before disposing private data for GDataUploadStream which could be referenced by threaded code called when the upload is cancelled. Closes: bgo#602156 gdata/gdata-upload-stream.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)