Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: uv_fs_{open,read,close}_dir #416

Closed
wants to merge 1 commit into from

Conversation

whitlockjc
Copy link
Contributor

@whitlockjc whitlockjc commented Jun 30, 2015

This PR is for taking the efforts by @misterdjules in #175 and applying those changes to master instead of v1.x per @saghul's suggestion. You should be able to close #175 in favor of this but I'll leave that decision up to you.

Note: This commit also updates uv__fs_readdir to use readdir instead of the deprecated readdir_r.

@whitlockjc
Copy link
Contributor Author

cc'ing the required people...

/cc @saghul @piscisaureus @bnoordhuis

@Fishrock123
Copy link
Contributor

Pinging @saghul @piscisaureus @bnoordhuis again :)

@saghul
Copy link
Member

saghul commented Aug 11, 2015

Sorry, but I won't be able to review this anytime soon.

@whitlockjc
Copy link
Contributor Author

I have rebased this PR due to master deviation. Test suite runs great, although fs_event_watch_dir and fs_event_watch_dir_recursive can randomly fail due to #30 (Fixed in #480).

@rsms
Copy link

rsms commented Aug 24, 2015

+1 — nice work.

@eljefedelrodeodeljefe
Copy link
Contributor

@whitlockjc I opened a related issue on the nodejs bug tracker. Without having a stake in this, can you rebase this, so it will be possible to review?

@whitlockjc
Copy link
Contributor Author

You got it. I didn't realize this hadn't been merged.

@eljefedelrodeodeljefe
Copy link
Contributor

@saghul marked it v2 - maybe that was the reason. Not sure if it is though. If possible try not breaking ABI, then I guess it'll be easier to land. Would be really useful to land this, imo!

@txdv
Copy link
Contributor

txdv commented May 11, 2016

It looks like its only adding additional API calls, how is it breaking anything?

@eljefedelrodeodeljefe
Copy link
Contributor

I am sure @saghul will clarify. Maybe it was just for roadmap.

@whitlockjc
Copy link
Contributor Author

whitlockjc commented May 11, 2016

It's been through a ton of review, there are tests and the ABI was not broken so that's why I was surprised. I'm not sure why it's marked as v2 but it shouldn't be because of the ABI. As for trying not to break the ABI, I don't think people do it unless they have to (at least not after a full pass of code review), as I had to in #590.

Maybe @saghul can chime in.

@whitlockjc
Copy link
Contributor Author

whitlockjc commented May 11, 2016

@eljefedelrodeodeljefe Do you mind linking this issue and the one in node? That would be very useful.

@eljefedelrodeodeljefe
Copy link
Contributor

You mean me probably, right? It's about providing glob, where those APIs would be necessary nodejs/node#6677

@whitlockjc
Copy link
Contributor Author

Sorry about that, I see it was linked higher in the discussion but I didn't see it.

@saghul
Copy link
Member

saghul commented May 11, 2016

This PR modifies the uv_fs_t structure: https://github.com/libuv/libuv/pull/416/files#diff-56343bd7ad8bf449c2693082fb3e4081R1107 That breaks the ABI, and the reason why I tagged it v2.

@@ -1096,6 +1104,9 @@ struct uv_fs_s {
void* ptr;
const char* path;
uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */
const uv_dir_t* dir; /* Stores the result of uv_fs_opendir() */
uv_dirent_t* dirents;
size_t nentries;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's possible without that addition, say with an own struct right? That of course breaks ABI compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I didn't see this. (I actually overlooked it twice because of the styling of the GitHub diff viewer...and this PR is pretty old so I just forgot.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And where would you put those members or the new struct? FYI, I'll be -1 on bending over backwards for ABI compatibility in new features. That way we'd never start working on v2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add methods similar to uv_fs_get_statbuf etc. from 0d6525a ?

@whitlockjc
Copy link
Contributor Author

whitlockjc commented May 11, 2016

Doh...I stand corrected. (It's been quite a while since this was authored so I guess I forgot, and GitHub's diff viewer didn't help too much as I overlooked it.) Well, it all makes sense now. Mark that up as two v2 PRs from me that require ABI changes. ;) My bad @saghul.

@eljefedelrodeodeljefe
Copy link
Contributor

That's fine. We'll get there. Give me a ping when I can support.

@whitlockjc
Copy link
Contributor Author

You got it. I don't mind helping on the node side of things either if you need. I'm already prepared for the node changes related to for #590 when the time comes. :)

@guymguym
Copy link

@whitlockjc One last comment - I believe that for Linux you need to have a mutex per dir since readdir() is not thread safe and as far as I understand the libuv threadpool will be doing these readdir calls, right?

See what the readdir(3) docs has to say:

In the current POSIX.1 specification (POSIX.1-2008), readdir() is not required to be thread-safe. However, in modern implementations (including the glibc implementation), concurrent calls to readdir() that specify different directory streams are thread-safe. In cases where multiple threads must read from the same directory stream, using readdir() with external synchronization is still preferable to the use of the deprecated readdir_r(3) function. It is expected that a future version of POSIX.1 will require that readdir() be thread-safe when concurrently employed on different directory streams.

@whitlockjc
Copy link
Contributor Author

I thought something similar but figured it would come up in review. Glad you brought it up. I'll get it sorted once I've given enough soak time for further review.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite ready yet but getting closer. Thanks for picking this up again.

Question: the use of req->ptr seems unnecessary. Can that be dropped?

include/uv.h Show resolved Hide resolved
src/unix/fs.c Show resolved Hide resolved
src/unix/fs.c Show resolved Hide resolved
src/unix/fs.c Show resolved Hide resolved
src/unix/fs.c Show resolved Hide resolved
test/test-fs-readdir.c Show resolved Hide resolved
test/test-fs-readdir.c Show resolved Hide resolved
src/win/fs.c Show resolved Hide resolved
non_empty_readdir_cb);
}

uv_fs_req_cleanup(req);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't safe, is it? req == &readdir_req and that's (re)initialized on line 375.

test/test-fs-readdir.c Show resolved Hide resolved
@cjihrig
Copy link
Contributor

cjihrig commented May 26, 2018

Ping @whitlockjc. This is so close to finally being ready 😄

@whitlockjc
Copy link
Contributor Author

I'll get on it. I was waiting on #590 to be merged and forgot about this one.

@rijnhard
Copy link

@whitlockjc ping, just making sure this hasn't slipped through the cracks

@whitlockjc
Copy link
Contributor Author

Thanks for the bump @rijnhard, I've just been super busy. I'll make time for this by EOW.

@rijnhard
Copy link

@whitlockjc ping

@whitlockjc
Copy link
Contributor Author

I'm back, sorry for the delay. Work, life and other OSS. :)

@whitlockjc
Copy link
Contributor Author

Would anyone else like to pick this up and drive it? The review feedback from @guymguym and @bnoordhuis is going to take more time than I can seem to come up with right now.

@cjihrig
Copy link
Contributor

cjihrig commented Aug 2, 2018

Would anyone else like to pick this up and drive it?

I'll pick this up.

@guymguym
Copy link

guymguym commented Aug 2, 2018

@cjihrig Let me know if I can help too

@Fishrock123
Copy link
Contributor

Do we know where master is going yet? If someone were to update this, is master still a reasonable target, or will that never make it into a release?

@rijnhard
Copy link

This died again didn't it

@cjihrig
Copy link
Contributor

cjihrig commented Oct 12, 2018

It hasn't died again. I promise.

cjihrig added a commit to cjihrig/libuv that referenced this pull request Oct 27, 2018
This commit also updates `uv__fs_readdir` to use `readdir` instead of
the deprecated `readdir_r`.

Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Oct 29, 2018
This commit also updates `uv__fs_readdir()` to use `readdir()`
instead of the deprecated `readdir_r()`.

Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
@cjihrig
Copy link
Contributor

cjihrig commented Oct 29, 2018

Moving to #2057 with most of @bnoordhuis nits addressed from the last review, as well as some comments of my own.

@cjihrig cjihrig closed this Oct 29, 2018
Fishrock123 pushed a commit to Fishrock123/libuv that referenced this pull request Feb 11, 2019
This commit also updates `uv__fs_readdir()` to use `readdir()`
instead of the deprecated `readdir_r()`.

Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Mar 19, 2019
This commit also updates `uv__fs_readdir()` to use `readdir()`
instead of the deprecated `readdir_r()`.

Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Mar 24, 2019
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Mar 26, 2019
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Mar 26, 2019
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: libuv#2057
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
cjihrig added a commit to cjihrig/libuv that referenced this pull request Mar 26, 2019
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: libuv#2057
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
njlr pushed a commit to buckaroo-pm/libuv that referenced this pull request Apr 5, 2019
Co-authored-by: Julien Gilli <jgilli@nodejs.org>
Co-authored-by: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: libuv#2057
Refs: joyent/libuv#1430
Refs: joyent/libuv#1521
Refs: joyent/libuv#1574
Refs: libuv#175
Refs: nodejs/node#583
Refs: libuv#416
Refs: libuv#170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.