Re: How to cancel a tny_transport_account_send?



On Mon, 2008-01-21 at 14:35 +0100, Philip Van Hoof wrote:
> On Mon, 2008-01-21 at 14:19 +0100, Sergio Villar Senin wrote:
> 
> > I'm trying to cancel the tny_transport_account_send that is performed in
> > the TnyCamelSendQueue with tny_account_cancel, but it does nothing. The
> > reason is because the "cancel" field of the private structure that
> > belongs to TnyCamelAccount is empty. What is means is that maybe we need
> > to enclose that call between the tny_camel_account_start/stop_operation.
> 
> Indeed.
> 
> Cancels can only work for operations enclosed with camel_operation_start
> and camel_operation_stop. The tny_camel_account_start/stop things do it.

Note that the original intent of cancels in a TnySendQueue where not to
cancel the current item that is being sent, as you can't know where
exactly you cancelled it (so either you send it twice, because you
didn't atomically move it to the sent folder, or you never send it
because you removed it from the outbox folder).

Now with your suspend proposal, I guess you'll either send it just once
because you cancelled right after the sent, while you are moving to the
sent folder, or you will never send it because you'll first mark it as
suspended in the outbox folder (and you don't handle suspended items
during the next run).

The cancels of the current TnySendQueue where intended to only cancel
the loop. Not the current item that is being send.

Anyway, keep in mind atomicy when cancelling: don't promise the user you
cancelled something if you have just sent the last byte to the SMTP
server. You wont have cancelled the sending of the message.

It's also quite hard to make any promise to the user about his
cancellation. You never know how far it got. You also don't control what
the SMTP server will do with the partial message.


-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]