summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-07-08 11:26:24 -0700
committerTor Norbye <tnorbye@google.com>2013-07-08 11:26:24 -0700
commitc1ace1f7e1e49c81bb4b75377c99f07be340abfe (patch)
tree9d0db96bd3d86ddfec80e7e3554cad9dcc066553 /native
parentc6218e46d5d2017e987ecdbd99b318a95c42abc0 (diff)
downloadidea-c1ace1f7e1e49c81bb4b75377c99f07be340abfe.tar.gz
Snapshot aea001abfc1b38fec3a821bcd5174cc77dc75787 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Icdea2a2bd7ad43b4d05967b1f0479db3bda1c93c
Diffstat (limited to 'native')
-rw-r--r--native/fsNotifier/linux/inotify.c15
-rw-r--r--native/fsNotifier/linux/main.c44
2 files changed, 34 insertions, 25 deletions
diff --git a/native/fsNotifier/linux/inotify.c b/native/fsNotifier/linux/inotify.c
index 444a5bf978a0..77536dc3dcba 100644
--- a/native/fsNotifier/linux/inotify.c
+++ b/native/fsNotifier/linux/inotify.c
@@ -305,14 +305,17 @@ int watch(const char* root, array* mounts) {
struct stat st;
if (stat(root, &st) != 0) {
- if (errno == EACCES) {
- return ERR_IGNORE;
- }
- else if (errno == ENOENT) {
+ if (errno == ENOENT) {
return ERR_MISSING;
}
- userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
- return ERR_ABORT;
+ else if (errno == EACCES || errno == ELOOP || errno == ENAMETOOLONG || errno == ENOTDIR) {
+ userlog(LOG_INFO, "stat(%s): %s", root, strerror(errno));
+ return ERR_CONTINUE;
+ }
+ else {
+ userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
+ return ERR_ABORT;
+ }
}
if (S_ISREG(st.st_mode)) {
diff --git a/native/fsNotifier/linux/main.c b/native/fsNotifier/linux/main.c
index de87fad9479d..3cd65e28fc54 100644
--- a/native/fsNotifier/linux/main.c
+++ b/native/fsNotifier/linux/main.c
@@ -36,7 +36,7 @@
#define LOG_ENV_ERROR "error"
#define LOG_ENV_OFF "off"
-#define VERSION "20130415.2136"
+#define VERSION "20130617.1935"
#define VERSION_MSG "fsnotifier " VERSION "\n"
#define USAGE_MSG \
@@ -73,8 +73,8 @@ static bool self_test = false;
static void init_log();
static void run_self_test();
-static void main_loop();
-static bool read_input();
+static bool main_loop();
+static int read_input();
static bool update_roots(array* new_roots);
static void unregister_roots();
static bool register_roots(array* new_roots, array* unwatchable, array* mounts);
@@ -116,12 +116,15 @@ int main(int argc, char** argv) {
setvbuf(stdin, NULL, _IONBF, 0);
+ int rv = 0;
roots = array_create(20);
- if (init_inotify() && roots != NULL) {
+ if (roots != NULL && init_inotify()) {
set_inotify_callback(&inotify_callback);
if (!self_test) {
- main_loop();
+ if (!main_loop()) {
+ rv = 3;
+ }
}
else {
run_self_test();
@@ -131,14 +134,15 @@ int main(int argc, char** argv) {
}
else {
output("GIVEUP\n");
+ rv = 2;
}
close_inotify();
array_delete(roots);
- userlog(LOG_INFO, "finished");
+ userlog(LOG_INFO, "finished (%d)", rv);
closelog();
- return 0;
+ return rv;
}
@@ -216,7 +220,7 @@ static void run_self_test() {
}
-static void main_loop() {
+static bool main_loop() {
int input_fd = fileno(stdin), inotify_fd = get_inotify_fd();
int nfds = (inotify_fd > input_fd ? inotify_fd : input_fd) + 1;
fd_set rfds;
@@ -233,14 +237,16 @@ static void main_loop() {
if (select(nfds, &rfds, NULL, NULL, &timeout) < 0) {
if (errno != EINTR) {
userlog(LOG_ERR, "select: %s", strerror(errno));
- break;
+ return false;
}
}
else if (FD_ISSET(input_fd, &rfds)) {
- if (!read_input()) break;
+ int result = read_input();
+ if (result == 0) return true;
+ else if (result != ERR_CONTINUE) return false;
}
else if (FD_ISSET(inotify_fd, &rfds)) {
- if (!process_inotify_input()) break;
+ if (!process_inotify_input()) return false;
}
else {
check_missing_roots();
@@ -249,24 +255,24 @@ static void main_loop() {
}
-static bool read_input() {
+static int read_input() {
char* line = read_line(stdin);
userlog(LOG_DEBUG, "input: %s", (line ? line : "<null>"));
if (line == NULL || strcmp(line, "EXIT") == 0) {
userlog(LOG_INFO, "exiting: %s", line);
- return false;
+ return 0;
}
if (strcmp(line, "ROOTS") == 0) {
array* new_roots = array_create(20);
- CHECK_NULL(new_roots, false);
+ CHECK_NULL(new_roots, ERR_ABORT);
while (1) {
line = read_line(stdin);
userlog(LOG_DEBUG, "input: %s", (line ? line : "<null>"));
if (line == NULL || strlen(line) == 0) {
- return false;
+ return 0;
}
else if (strcmp(line, "#") == 0) {
break;
@@ -274,15 +280,15 @@ static bool read_input() {
else {
int l = strlen(line);
if (l > 1 && line[l-1] == '/') line[l-1] = '\0';
- CHECK_NULL(array_push(new_roots, strdup(line)), false);
+ CHECK_NULL(array_push(new_roots, strdup(line)), ERR_ABORT);
}
}
- return update_roots(new_roots);
+ return update_roots(new_roots) ? ERR_CONTINUE : ERR_ABORT;
}
- userlog(LOG_INFO, "unrecognised command: %s", line);
- return true;
+ userlog(LOG_WARNING, "unrecognised command: %s", line);
+ return ERR_CONTINUE;
}