Strange behavior with posix async I/O
Hi - Any help with this one sure would be appreciated.
OS: Centos 5 Kernel 2.6.22
Compiler: Gnu C++
I'm using the posix async I/O routines (io_prep_pread, io_prep_pwrite, io_submit) to read and write some data files asynchronously, harvesting the completion status using io_getevents and I'm experiencing some behavior that I can't explain. If this is normal behavior, the "documentation" certainly hides it well.
The first maddening thing is that when I run my application in gdb, io_getevents continually returns a status of -4. (I think this is -EAGAIN) I'm calling it with my I/O context variable, a minimum event count of 1, a maximum of 10 and the timer parameter is NULL. So what's up with this? Why am I getting a -4 while in gdb? It makes it slightly more challenging to debug any problems. I DO eventually get a '1' when an outstanding I/O completes, so I've coded around this anomaly.
Next, (and more importantly) I'm getting odd behavior if I inadvertently try to read past the end of file. No, I shouldn't be trying to read past the end of file, but darn it, if I do try, the OS should TELL me that I had an end of file error. The problem is, when this event completes, the res and res2 fields of the io_event struct are zero. Zero tells me nothing, other than "there were zero bytes transferred". Well, yeah. But WHY? I should have some I/O status SOMEwhere that indicates the reason for the error, but I get nothing. Can anyone shed some light on this?
Thanks in advance.
Greg
|