Skip to content

Commit

Permalink
fix osx build + test
Browse files Browse the repository at this point in the history
Summary:
OSX doesn't have fdopendir so do a poor-mans approximation.

Fixup use of $this in a lexical closure; this isn't broadly supported
in PHP, certainly not in the version deployed on my mac.

Fixup kqueue watching :-(

Test Plan: `arc unit --everything` on OSX

Reviewers: sid0, dsereni

Reviewed By: dsereni

Differential Revision: https://phabricator.fb.com/D912074

Blame Revision: rWAT5c21fc0b3b8854c71c5a7a5151f21fcff9eba5ed
  • Loading branch information
wez committed Aug 2, 2013
1 parent 19c7e8d commit f26c51d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arcanist/lib/WatchmanTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ function waitFor($callable, $timeout = 10, $message = null) {
function waitForWatchmanNoThrow(array $command, $have_data, $timeout = 10) {
$last_output = null;

$instance = $this->watchman_instance;
list($ok, $res) = $this->waitForNoThrow(
function () use ($command, $have_data, &$last_output) {
function () use ($instance, $command, $have_data, &$last_output) {
$out = call_user_func_array(
array($this->watchman_instance, 'request'),
array($instance, 'request'),
$command);
if ($out === false) {
// Connection terminated
Expand Down
9 changes: 9 additions & 0 deletions root.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,13 @@ static DIR *opendir_nofollow(const char *path)
if (fd == -1) {
return NULL;
}
#ifdef __APPLE__
close(fd);
return opendir(path);
#else
// errno should be set appropriately if this is not a directory
return fdopendir(fd);
#endif
}

// POSIX says open with O_NOFOLLOW should set errno to ELOOP if the path is a
Expand Down Expand Up @@ -989,6 +994,8 @@ static void crawler(w_root_t *root, w_string_t *dir_name,
#if HAVE_KQUEUE
{
struct stat st, osdirst;
struct kevent k;

newwd = open(path, O_NOFOLLOW|O_EVTONLY|O_CLOEXEC);

if (newwd == -1) {
Expand Down Expand Up @@ -1016,6 +1023,7 @@ static void crawler(w_root_t *root, w_string_t *dir_name,
return;
}

dir->wd = newwd;
memset(&k, 0, sizeof(k));
EV_SET(&k, dir->wd, EVFILT_VNODE, EV_ADD|EV_CLEAR,
NOTE_WRITE|NOTE_DELETE|NOTE_EXTEND|NOTE_RENAME,
Expand All @@ -1027,6 +1035,7 @@ static void crawler(w_root_t *root, w_string_t *dir_name,
path, strerror(errno));
close(dir->wd);
dir->wd = -1;
}
}
#endif // HAVE_KQUEUE
#if HAVE_PORT_CREATE
Expand Down

0 comments on commit f26c51d

Please sign in to comment.