From: Jens Axboe <[email protected]>
To: Josef <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: io_uring file descriptor address already in use error
Date: Tue, 25 Aug 2020 09:17:57 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 8/25/20 9:12 AM, Jens Axboe wrote:
> On 8/25/20 9:00 AM, Josef wrote:
>> Hi,
>>
>> I found a bug submitting a server socket poll in io_uring. The file
>> descriptor is not really closed when calling close(2), if I bind a new
>> socket with the same address & port I'll get an "Already in use" error
>> message
>>
>> example to reproduce it
>> https://gist.github.com/1Jo1/3ace601884b86f7495fd5241190494dc
>
> Not sure this is an actual bug, but depends on how you look at it. Your
> poll command has a reference to the file, which means that when you close
> it here:
>
> assert(close(sock_listen_fd1) == 0);
>
> then that's not the final close. If you move the io_uring_queue_exit()
> before that last create_server_socket() it should work, since the poll
> will have been canceled (and hence the file closed) at that point.
>
> That said, I don't believe we actually need the file after arming the
> poll, so we could potentially close it once we've armed it. That would
> make your example work.
Actually we do need the file, in case we're re-arming poll. But as stated
in the above email, this isn't unexpected behavior. You could cancel the
poll before trying to setup the new server socket, that'd close it as
well. Then the close() would actually close it. Ordering of the two
operations wouldn't matter.
--
Jens Axboe
next prev parent reply other threads:[~2020-08-25 15:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 15:00 io_uring file descriptor address already in use error Josef
2020-08-25 15:12 ` Jens Axboe
2020-08-25 15:17 ` Jens Axboe [this message]
2020-08-25 15:48 ` Jens Axboe
2020-08-25 16:38 ` Josef
2020-08-25 16:47 ` Jens Axboe
2020-08-26 3:01 ` Josef
2020-08-26 13:44 ` Jens Axboe
2020-08-26 18:25 ` Josef
2020-08-26 18:39 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox