summaryrefslogtreecommitdiffstats
path: root/net/base/file_stream_posix.cc
Commit message (Collapse)AuthorAgeFilesLines
* POSIX: Add a macro for handling EINTR.agl@chromium.org2009-05-011-18/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On POSIX systems, system calls can be interrupted by signals. In this case, they'll return EINTR, indicating that the system call needs to be restarted. (The situation is a little more complicated than this with SA_RESTART, but you can read man 7 signal if you like.) The short of it is that you need to catch EINTR and restart the call for these system calls: * read, readv, write, writev, ioctl * open() when dealing with a fifo * wait* * Anything socket based (send*, recv*, connect, accept etc) * flock and lock control with fcntl * mq_ functions which can block * futex * sem_wait (and timed wait) * pause, sigsuspend, sigtimedwait, sigwaitinfo * poll, epoll_wait, select and 'p' versions of the same * msgrcv, msgsnd, semop, semtimedop * close (although, on Linux, EINTR won't happen here) * any sleep functions (careful, you need to handle this are restart with different arguments) We've been a little sloppy with this until now. This patch adds a macro for dealing with this and corrects every case of these system calls (that I found). The macro is HANDLE_EINTR in base/eintr_wrapper.h. It's safe to include on Windows and is a no-op there. On POSIX, it uses GCC magic to return the correct type based on the expression and restarts the system call if it throws EINTR. And you can use it like: HANDLE_EINTR(close(fd)); Or: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer, len)); *BEWARE* that it will evaluate the argument multiple times, so this is not safe: HANDLE_EINTR(close(FireMissiles())); http://groups.google.com/group/chromium-dev/browse_thread/thread/41a35b2a457d73a0 http://codereview.chromium.org/100225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15102 0039d316-1c4b-4281-b951-d872f2087c98
* * Switch the posix FileStream code over to using WorkerPool for asynchronous ↵willchan@chromium.org2009-03-241-48/+282
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operations. * Add a bunch of tests for asynchronous operations. * Fix lint errors. Before: Summary iterations 5 pages 20 milliseconds 18585 mean per set 3717.00 mean per page 185.85 timer lag 2663.00 timer lag per page 26.63 After: Summary iterations 5 pages 20 milliseconds 9279 mean per set 1855.80 mean per page 92.79 timer lag 689.00 timer lag per page 6.89 Review URL: http://codereview.chromium.org/48111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12398 0039d316-1c4b-4281-b951-d872f2087c98
* Adds truncate to FileStream.sky@google.com2009-03-091-0/+17
| | | | | | | | | BUG=none TEST=none Review URL: http://codereview.chromium.org/39301 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11245 0039d316-1c4b-4281-b951-d872f2087c98
* Fixes CRLF and trailing white spaces.maruel@chromium.org2009-03-051-1/+1
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10982 0039d316-1c4b-4281-b951-d872f2087c98
* Add a new method ReadUntilComplete to FileStream which ensures that all ↵jhawkins@chromium.org2009-02-131-0/+21
| | | | | | | | requested bytes are read from the file in one call, assuming no errors occurr or EOF is reached. Review URL: http://codereview.chromium.org/21363 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9803 0039d316-1c4b-4281-b951-d872f2087c98
* Add constructor to net::FileStream to create it with a base::PlatformFile ↵hclam@chromium.org2009-02-091-0/+6
| | | | | | | | | | handle. Constructor added to both _win and _posix implementations and provided a unit test. Review URL: http://codereview.chromium.org/20137 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9428 0039d316-1c4b-4281-b951-d872f2087c98
* Change FileStream to use FilePath instead of wstring.erikkay@google.com2009-01-261-2/+2
| | | | | | Review URL: http://codereview.chromium.org/18764 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8663 0039d316-1c4b-4281-b951-d872f2087c98
* * Add write and read/write support to FileStream (renamed from FileInputStream).erikkay@google.com2008-11-031-0/+177
* Moved net/disk_cache/os_file to base/platform_file. Review URL: http://codereview.chromium.org/8843 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4454 0039d316-1c4b-4281-b951-d872f2087c98