All of lore.kernel.org
 help / color / mirror / Atom feed
* SQPOLL fd close(2) question
@ 2020-09-25 16:21 Josef
  2020-09-25 17:56 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Josef @ 2020-09-25 16:21 UTC (permalink / raw)
  To: io-uring, Jens Axboe; +Cc: norman

Hi,

I implemented SQPOLL in netty for 5.8/5.9, to close a fd I need to
delete the entry first, it seems to fail with error -EADDRINUSE when I
remove the fd entry, close(2) it and the same socket(with the same
address) is created again,, is that known?
I assume that io_uring still has some reference to this, however
io_uring_unregister_files works fine but the drawback would be that I
need to wait until the ring is idle

example:
https://gist.github.com/1Jo1/53d01c4c2172bb0762b5dbcf9ef9c623

---
Josef

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SQPOLL fd close(2) question
  2020-09-25 16:21 SQPOLL fd close(2) question Josef
@ 2020-09-25 17:56 ` Jens Axboe
  2020-09-25 23:40   ` Josef
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2020-09-25 17:56 UTC (permalink / raw)
  To: Josef, io-uring; +Cc: norman

On 9/25/20 10:21 AM, Josef wrote:
> Hi,
> 
> I implemented SQPOLL in netty for 5.8/5.9, to close a fd I need to
> delete the entry first, it seems to fail with error -EADDRINUSE when I
> remove the fd entry, close(2) it and the same socket(with the same
> address) is created again,, is that known?
> I assume that io_uring still has some reference to this, however
> io_uring_unregister_files works fine but the drawback would be that I
> need to wait until the ring is idle

If you have a file registered, that holds a reference to it. So when
you then otherwise close it in the app, it's similar to having done
a dup() on it and just closing the original. So yes, this is known and
expected, I'm afraid.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SQPOLL fd close(2) question
  2020-09-25 17:56 ` Jens Axboe
@ 2020-09-25 23:40   ` Josef
  2020-09-26 10:53     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Josef @ 2020-09-25 23:40 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: norman

> If you have a file registered, that holds a reference to it. So when
> you then otherwise close it in the app, it's similar to having done
> a dup() on it and just closing the original. So yes, this is known and
> expected, I'm afraid.

Thanks for clarification, the only way to delete the file registered
reference is to use io_uring_unregister_files right?
I don't think that we can support SQPOLL for 5.8/5.9, but at least for 5.10+ :)

---
Josef Grieb

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SQPOLL fd close(2) question
  2020-09-25 23:40   ` Josef
@ 2020-09-26 10:53     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-09-26 10:53 UTC (permalink / raw)
  To: Josef, io-uring; +Cc: norman

On 9/25/20 5:40 PM, Josef wrote:
>> If you have a file registered, that holds a reference to it. So when
>> you then otherwise close it in the app, it's similar to having done
>> a dup() on it and just closing the original. So yes, this is known and
>> expected, I'm afraid.
> 
> Thanks for clarification, the only way to delete the file registered
> reference is to use io_uring_unregister_files right?

Correct, that's the only way to trigger the final fput() that'll
close the socket (for real).

> I don't think that we can support SQPOLL for 5.8/5.9, but at least for 5.10+ :)

It'll be a lot more generically useful once we have non-registered file
support, so I'd probably just ignore it for now for your use case.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-26 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 16:21 SQPOLL fd close(2) question Josef
2020-09-25 17:56 ` Jens Axboe
2020-09-25 23:40   ` Josef
2020-09-26 10:53     ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.