Am 15.04.2011 12:12, schrieb Ingo Weinhold:
On 2011-04-15 at 10:23:10 [+0200], Stephan Aßmus<superstippi@xxxxxx> wrote:Am 15.04.2011 09:59, schrieb Clemens:is there a way to cancel a read()? how would you handle it? (just curious)The read thread doesn't have to block for the whole message. As Ingo found out, IMAP supports fetching in chunks.Moreover the file system can support that closing a FD unblocks pending read()s. Exactly for that purpose the FS interface has two hooks for the close phase (close() and free_cookie()).
Ah yes, I think I've even used this before. At least it is frequently used with semaphores in a similar use case. Delete the semaphore and make blocking threads bail out.
Best regards, -Stephan