ublk-org / ublksrv

ublk: userspace block device driver
MIT License
147 stars 50 forks source link

Allow eventfd to be zero #62

Closed bsbernd closed 9 months ago

bsbernd commented 9 months ago

Result of eventfd() might be zero - this is a valid file descriptor.

Also always return -errno (and 0) from ublksrv_setup_eventfd() and use it for the error message.

bsbernd commented 9 months ago

@ming1 Just wanted to check how to use polling on the ring fd and noticed that q->efd was assumed to be never 0.

ming1 commented 9 months ago

Result of eventfd() might be zero - this is a valid file descriptor.

file descriptor 0 is reserved for standard input, so it shouldn't be returned from eventfd().

Do you see any problem with current way of treating zero as failure?

Thanks,

bsbernd commented 9 months ago

I was just looking something up in the code, without using it. It is ensured that stdin is still open when eventfd is set up, in all cases? Just very unusual to treat fd=0 as special...

ming1 commented 9 months ago

I was just looking something up in the code, without using it. It is ensured that stdin is still open when eventfd is set up, in all cases? Just very unusual to treat fd=0 as special...

Fair enough, merged.

thanks,