Changeset 3782

Show
Ignore:
Timestamp:
10/20/08 12:07:35
Author:
svillar
Message:
  • Merged from trunk r3776, do not write in chunks in the filesystem
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • releases/modest/diablo-pe2/ChangeLog

    r3780 r3782  
     12008-10-20  Sergio Villar Senin  <svillar@igalia.com> 
     2 
     3        * Ported several fixes from trunk 
     4 
    152008-10-20  Jose Dapena Paz  <jdapena@igalia.com> 
    26 
    37        * Disable IMAP IDLE support as it's still broken and 
    48          can cause hangs. 
     9 
     102008-10-16  Sergio Villar Senin  <svillar@igalia.com> 
     11 
     12        * libtinymail-camel/camel-lite/camel/camel-file-utils.c: (camel_write) 
     13        only write in chunks when writing to sockets, do not do it when 
     14        writing to a local filesystem. This speeds up writings a lot. 
    515 
    6162008-10-06  Sergio Villar Senin  <svillar@igalia.com> 
  • releases/modest/diablo-pe2/libtinymail-camel/camel-lite/camel/camel-file-utils.c

    r3774 r3782  
    570570} 
    571571 
    572  
    573 /** 
    574  * camel_write: 
    575  * @fd: file descriptor 
    576  * @buf: buffer to write 
    577  * @n: number of bytes of @buf to write 
    578  * 
    579  * Cancellable libc write() replacement. 
    580  * 
    581  * Code that intends to be portable to Win32 should call this function 
    582  * only on file descriptors returned from open(), not on sockets. 
    583  * 
    584  * Returns number of bytes written or -1 on fail. On failure, errno will 
    585  * be set appropriately. 
    586  **/ 
    587 ssize_t 
    588 camel_write (int fd, const char *buf, size_t n) 
     572static ssize_t 
     573camel_write_shared (int fd, const char *buf, size_t n, gboolean write_in_chunks) 
    589574{ 
    590575        ssize_t w, written = 0; 
     
    602587        if (cancel_fd == -1) { 
    603588                do { 
    604                         /* Write in chunks of max WRITE_CHUNK_SIZE bytes */ 
    605                         ssize_t actual = MIN (n - written, WRITE_CHUNK_SIZE); 
    606  
    607                         do { 
    608                                 w = write (fd, buf + written, actual /* n - written */); 
    609                         } while (w == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); 
     589                        if (write_in_chunks) { 
     590                                /* Write in chunks of max WRITE_CHUNK_SIZE bytes */ 
     591                                ssize_t actual = MIN (n - written, WRITE_CHUNK_SIZE); 
     592                                do { 
     593                                        w = write (fd, buf + written, actual); 
     594                                } while (w == -1 && (errno == EINTR || errno == EAGAIN ||  
     595                                                     errno == EWOULDBLOCK));                     
     596                        } else { 
     597                                do { 
     598                                        w = write (fd, buf + written, n - written); 
     599                                } while (w == -1 && (errno == EINTR || errno == EAGAIN ||  
     600                                                     errno == EWOULDBLOCK));             
     601                        } 
    610602                        if (w > 0) 
    611603                                written += w; 
     
    625617                        struct timeval tv; 
    626618                        int res; 
    627  
    628                         /* Write in chunks of max WRITE_CHUNK_SIZE bytes */ 
    629                         ssize_t actual = MIN (n - written, WRITE_CHUNK_SIZE); 
    630619 
    631620                        FD_ZERO (&rdset); 
     
    646635                                errno = EINTR; 
    647636                        else { 
    648                                 do { 
    649                                         w = write (fd, buf + written, actual /*n - written*/); 
    650                                 } while (w == -1 && errno == EINTR); 
    651  
     637                                if (write_in_chunks) { 
     638                                        /* Write in chunks of max WRITE_CHUNK_SIZE bytes */ 
     639                                        ssize_t actual = MIN (n - written, WRITE_CHUNK_SIZE); 
     640                                        do { 
     641                                                w = write (fd, buf + written, actual); 
     642                                        } while (w == -1 && (errno == EINTR || errno == EAGAIN ||  
     643                                                             errno == EWOULDBLOCK));                     
     644                                } else { 
     645                                        do { 
     646                                                w = write (fd, buf + written, n - written); 
     647                                        } while (w == -1 && (errno == EINTR || errno == EAGAIN ||  
     648                                                             errno == EWOULDBLOCK));     
     649                                } 
    652650                                if (w == -1) { 
    653651                                        if (errno == EAGAIN || errno == EWOULDBLOCK) 
     
    668666 
    669667        return written; 
     668} 
     669 
     670 
     671/** 
     672 * camel_write: 
     673 * @fd: file descriptor 
     674 * @buf: buffer to write 
     675 * @n: number of bytes of @buf to write 
     676 * 
     677 * Cancellable libc write() replacement. 
     678 * 
     679 * Code that intends to be portable to Win32 should call this function 
     680 * only on file descriptors returned from open(), not on sockets. 
     681 * 
     682 * Returns number of bytes written or -1 on fail. On failure, errno will 
     683 * be set appropriately. 
     684 **/ 
     685ssize_t 
     686camel_write (int fd, const char *buf, size_t n) 
     687{ 
     688        camel_write_shared (fd, buf, n, FALSE); 
    670689} 
    671690 
     
    907926{ 
    908927#ifndef G_OS_WIN32 
    909         return camel_write (fd, buf, n); 
     928        return camel_write_shared (fd, buf, n, TRUE); 
    910929#else 
    911930        ssize_t w, written = 0;