[Dovecot] 1.0.beta2 released

Václav Haisman V.Haisman at sh.cvut.cz
Sun Jan 29 13:47:15 EET 2006



Timo Sirainen wrote:
> On Mon, 2006-01-23 at 18:50 +0100, Vaclav Haisman wrote:
>> I have attached patch that should fix all kqueue issues (I hope). It is 
>> smaller than it looks because I also reindented both kqueue files with 
>> tabs as is the rest of the source.
> 
> if ((fds[fd].mode & (IO_READ | IO_ERROR)) == 0 &&
>     (fcntl(io->fd, F_GETFD, 0) != -1 || errno != EBADF))
> 	if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) == -1) {
> 
> Can't this be fixed some other way so that those EBADFs don't happen? If
> not, is it guaranteed that it gives EBADF, and not accidentally succeed
> because some other fd was just opened with same number as io->fd?
> 
> Also can't the above just as well be written as:
> 
> if ((fds[fd].mode & (IO_READ | IO_ERROR)) == 0)
> 	if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) == -1 && errno != EBADF) {
The nature of kqueue is that it automatically removes/unregisters all
filters associated with handle if the handle is closed and thus if the
user of the ioloop code tries to remove the handle after it has been
already closed then he gets EBADF.

I think the way you wrote it actually looks better.

> 
>> The other attached patch is what I used for easier debugging. I think it 
>> could help somebody else too.
> 
> I've tried to keep the error messages as unique as needed so that file
> names and numbers wouldn't be needed :) But I'll add it to
> http://dovecot.org/patches/ in case it's needed some day by someone.
> 

Vaclav Haisman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 542 bytes
Desc: OpenPGP digital signature
Url : http://dovecot.org/pipermail/dovecot/attachments/20060129/a567de8c/signature.pgp


More information about the dovecot mailing list