* errno.cc (errmap): Change mapping of NO_SYSTEM_RESOURCES to EFBIG.

* fhandler.cc (MAX_OVERLAPPED_WRITE_LEN): New constant.
(MIN_OVERLAPPED_WRITE_LEN): Ditto.
(fhandler_base_overlapped::close): Accommodate change in arguments to
wait_overlapped.
(fhandler_base_overlapped::setup_overlapped): Add __stdcall and regparm
modifiers.
(fhandler_base_overlapped::destroy_overlapped): Ditto.
(fhandler_base_overlapped::has_ongoing_io): Ditto.
(fhandler_base_overlapped::wait_overlapped): Modify to return an enum returning
various states.  Accept nonblocking parameter.
(fhandler_base_overlapped::read_overlapped): Add __stdcall and regparm
modifiers.  Rework to attempt to be smarter about reacting to states returned
by wait_overlapped.
(fhandler_base_overlapped::write_overlapped): Ditto.  Add fallback option for
when wait_overlapped detects that smaller chunks must be written.
(fhandler_base_overlapped::write_overlapped_fallback): Ditto.
* fhandler.h (DEFAULT_PIPEBUFSIZE): Move definition here from pipe.cc.
(fhandler_base::has_ongoing_io): Define with __stdcall and regparm modifiers.
(fhandler_base_overlapped::wait_return): New enum.
(fhandler_base_overlapped::max_atomic_write): New variable.
(fhandler_base_overlapped:: wait_overlapped): Accommodate changes mentioned
above to arguments and modifiers.
(fhandler_base_overlapped::setup_overlapped): Ditto for modifiers.
(fhandler_base_overlapped::read_overlapped): Ditto.
(fhandler_base_overlapped::write_overlapped): Ditto.
(fhandler_base_overlapped::destroy_overlapped): Ditto.
(fhandler_base_overlapped::has_ongoing_io): Ditto.
(fhandler_base_overlapped::fhandler_base_overlapped): Zero max_atomic_write.
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Set max_atomic_write to the
size of the DEFAULT_PIPEBUFSIZE.
(fhandler_fifo::wait): Accommodate change in arguments to wait_overlapped.
* pipe.cc (fhandler_pipe::fhandler_pipe): Set max_atomic_write to the size of
the DEFAULT_PIPEBUFSIZE.
(fhandler_pipe::create_selectable): Allow minimum size of DEFAULT_PIPEBUFSIZE.
(DEFAULT_PIPEBUFSIZE): Delete here, move to fhandler.h.
This commit is contained in:
Christopher Faylor
2011-03-09 16:47:44 +00:00
parent e7b5eaaac9
commit 779ece3ce0
6 changed files with 193 additions and 57 deletions

View File

@ -29,6 +29,7 @@ details. */
Using this blocksize in read/write calls in the application results
in a much better performance than using smaller values. */
#define PREFERRED_IO_BLKSIZE ((blksize_t) 65536)
#define DEFAULT_PIPEBUFSIZE PREFERRED_IO_BLKSIZE
extern const char *windows_device_names[];
extern struct __cygwin_perfile *perfile_table;
@ -397,7 +398,7 @@ public:
bool issymlink () {return pc.issymlink ();}
bool device_access_denied (int) __attribute__ ((regparm (2)));
int fhaccess (int flags, bool) __attribute__ ((regparm (3)));
virtual bool has_ongoing_io () {return false;}
virtual bool __stdcall has_ongoing_io () __attribute__ ((regparm (1))) {return false;}
};
class fhandler_mailslot : public fhandler_base
@ -565,23 +566,33 @@ class fhandler_socket: public fhandler_base
class fhandler_base_overlapped: public fhandler_base
{
protected:
enum wait_return
{
overlapped_success = 0,
overlapped_signal,
overlapped_error,
overlapped_fallback
};
bool io_pending;
OVERLAPPED io_status;
OVERLAPPED *overlapped;
size_t max_atomic_write;
public:
int wait_overlapped (bool, bool, DWORD *, DWORD = 0) __attribute__ ((regparm (3)));
int setup_overlapped () __attribute__ ((regparm (1)));
void destroy_overlapped () __attribute__ ((regparm (1)));
wait_return __stdcall wait_overlapped (bool, bool, DWORD *, bool, DWORD = 0) __attribute__ ((regparm (3)));
int __stdcall setup_overlapped () __attribute__ ((regparm (1)));
void __stdcall destroy_overlapped () __attribute__ ((regparm (1)));
void __stdcall read_overlapped (void *ptr, size_t& len) __attribute__ ((regparm (3)));
ssize_t __stdcall write_overlapped (const void *ptr, size_t len);
ssize_t __stdcall write_overlapped (const void *ptr, size_t len) __attribute__ ((regparm (3)));
ssize_t __stdcall write_overlapped_fallback (const void *ptr, size_t orig_len)
__attribute__ ((regparm (3)));
OVERLAPPED *&get_overlapped () {return overlapped;}
OVERLAPPED *get_overlapped_buffer () {return &io_status;}
void set_overlapped (OVERLAPPED *ov) {overlapped = ov;}
fhandler_base_overlapped (): io_pending (false), overlapped (NULL)
fhandler_base_overlapped (): io_pending (false), overlapped (NULL), max_atomic_write (0)
{
memset (&io_status, 0, sizeof io_status);
}
bool has_ongoing_io ();
bool __stdcall has_ongoing_io () __attribute__ ((regparm (1)));
void fixup_after_fork (HANDLE);
void fixup_after_exec ();