Re: Patch: Camel stream filter waits properly for slow streams

View: New views
5 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Patch: Camel stream filter waits properly for slow streams

by Philip Van Hoof :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Adding some people and mailing lists in CC

Reattaching patch for Evolution-hackers mailing list.

Please bring this upstream too, José

Response from Jeffrey:

jeff_ yea, you should compare against -1
jeff_ as long as it returns >0, it wrote all the data
jeff_ -1 is error
jeff_ 0 is EOF maybe
jeff_ if write even returns 0 ever


On Tue, 2008-05-20 at 16:10 +0200, José Dapena Paz wrote:

> Hi,
>
> This patch for tinymail modifies a bit the implementation of do_write
> method in camel_stream_filter, to make it not fail simply because the
> stream is slow. In my case I'm getting problems writting to a bluetooth
> stream, as it sometimes writes less than the full buffer, and then the
> stream filter returns -1.
>
> Anyway, it seems that my code adds an active wait. How could I fix
> this? Any safe idea?
>
> Changelog entry would be:
> * libtinymail-camel/camel-lite/camel/camel-stream-filter.c:
> * (do_write): if the camel_stream_write call does not write the
>  full buffer but it's not due to an error, then loop to go on
>  writing the stream.



--
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





Index: libtinymail-camel/camel-lite/camel/camel-stream-filter.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-stream-filter.c (revision 3671)
+++ libtinymail-camel/camel-lite/camel/camel-stream-filter.c (working copy)
@@ -290,6 +290,7 @@
  struct _filter *f;
  size_t presize, len, left = n;
  char *buffer, realbuffer[READ_SIZE+READ_PAD];
+ size_t written = 0;
 
  p->last_was_read = FALSE;
 
@@ -321,8 +322,13 @@
  f = f->next;
  }
 
- if (camel_stream_write(filter->source, buffer, len) != len)
- return -1;
+ for (written = 0; written < len;) {
+ size_t just_written;
+ just_written = camel_stream_write (filter->source, buffer + written, len - written);
+ if (just_written == -1)
+ return -1;
+ written += just_written;
+ }
  }
 
  g_check(p->realbuffer);


_______________________________________________
Evolution-patches mailing list
Evolution-patches@...
http://mail.gnome.org/mailman/listinfo/evolution-patches

Re: Patch: Camel stream filter waits properly for slow streams

by José Dapena Paz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

El mar, 20-05-2008 a las 17:03 +0200, Philip Van Hoof escribió:
> Please bring this upstream too, José
>
> Response from Jeffrey:
>
> jeff_ yea, you should compare against -1
> jeff_ as long as it returns >0, it wrote all the data
> jeff_ -1 is error
> jeff_ 0 is EOF maybe
> jeff_ if write even returns 0 ever

        Ok, prepared patch for camel (it applied without problems). The
changelog would be mostly the same:

* evolution-data-server/camel/camel-stream-filter.c:
  (do_write): if the camel_stream_write call does not write the
  full buffer but it's not due to an error, then loop to go on
  writing the stream.


--
José Dapena Paz <jdapena@...>
Igalia


Index: camel/camel-stream-filter.c
===================================================================
--- camel/camel-stream-filter.c (revisión: 8817)
+++ camel/camel-stream-filter.c (copia de trabajo)
@@ -290,6 +290,7 @@
  struct _filter *f;
  size_t presize, len, left = n;
  char *buffer, realbuffer[READ_SIZE+READ_PAD];
+ size_t written = 0;
 
  p->last_was_read = FALSE;
 
@@ -321,8 +322,13 @@
  f = f->next;
  }
 
- if (camel_stream_write(filter->source, buffer, len) != len)
- return -1;
+ for (written = 0; written < len;) {
+ size_t just_written;
+ just_written = camel_stream_write (filter->source, buffer + written, len - written);
+ if (just_written == -1)
+ return -1;
+ written += just_written;
+ }
  }
 
  g_check(p->realbuffer);


_______________________________________________
Evolution-patches mailing list
Evolution-patches@...
http://mail.gnome.org/mailman/listinfo/evolution-patches

Re: Patch: Camel stream filter waits properly for slow streams

by Philip Van Hoof :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

José has no GNOME-svn account. I can commit on behalf of José if this
patch is approved.

Please let us know if it's approved.

Thanks!

On Tue, 2008-05-20 at 18:38 +0200, José Dapena Paz wrote:

> El mar, 20-05-2008 a las 17:03 +0200, Philip Van Hoof escribió:
> > Please bring this upstream too, José
> >
> > Response from Jeffrey:
> >
> > jeff_ yea, you should compare against -1
> > jeff_ as long as it returns >0, it wrote all the data
> > jeff_ -1 is error
> > jeff_ 0 is EOF maybe
> > jeff_ if write even returns 0 ever
>
> Ok, prepared patch for camel (it applied without problems). The
> changelog would be mostly the same:
>
> * evolution-data-server/camel/camel-stream-filter.c:
>   (do_write): if the camel_stream_write call does not write the
>   full buffer but it's not due to an error, then loop to go on
>   writing the stream.
>
>
--
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




_______________________________________________
Evolution-patches mailing list
Evolution-patches@...
http://mail.gnome.org/mailman/listinfo/evolution-patches

Re: Patch: Camel stream filter waits properly for slow streams

by Matthew Barnes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2008-05-20 at 18:49 +0200, Philip Van Hoof wrote:
> José has no GNOME-svn account. I can commit on behalf of José if this
> patch is approved.
>
> Please let us know if it's approved.

Please file a bug for this.  Mailing lists are a horrible way to track
patches and are awkward to reference in a ChangeLog entry.

Matthew Barnes

_______________________________________________
Evolution-patches mailing list
Evolution-patches@...
http://mail.gnome.org/mailman/listinfo/evolution-patches

Re: Patch: Camel stream filter waits properly for slow streams

by José Dapena Paz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

El mar, 20-05-2008 a las 13:04 -0400, Matthew Barnes escribió:
> On Tue, 2008-05-20 at 18:49 +0200, Philip Van Hoof wrote:
> > José has no GNOME-svn account. I can commit on behalf of José if this
> > patch is approved.
> >
> > Please let us know if it's approved.
>
> Please file a bug for this.  Mailing lists are a horrible way to track
> patches and are awkward to reference in a ChangeLog entry.

        Bug is #534080:
        http://bugzilla.gnome.org/show_bug.cgi?id=534080

        I attached the patch there too. Mmm but I forgot to add the bug id to
the patch uploaded. This should be added in the commit.

--
José Dapena Paz <jdapena@...>
Igalia

_______________________________________________
Evolution-patches mailing list
Evolution-patches@...
http://mail.gnome.org/mailman/listinfo/evolution-patches