Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: runtime/bin/file_system_watcher_linux.cc

Issue 165723007: Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tiny fix. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_system_watcher_android.cc ('k') | runtime/bin/file_system_watcher_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/file_system_watcher.h" 8 #include "bin/file_system_watcher.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <sys/inotify.h> // NOLINT 11 #include <sys/inotify.h> // NOLINT
12 12
13 #include "bin/fdutils.h" 13 #include "bin/fdutils.h"
14 #include "bin/socket.h" 14 #include "bin/socket.h"
15 15
16 #include "platform/signal_blocker.h"
17
16 18
17 namespace dart { 19 namespace dart {
18 namespace bin { 20 namespace bin {
19 21
20 bool FileSystemWatcher::IsSupported() { 22 bool FileSystemWatcher::IsSupported() {
21 return true; 23 return true;
22 } 24 }
23 25
24 26
25 intptr_t FileSystemWatcher::Init() { 27 intptr_t FileSystemWatcher::Init() {
26 int id = TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC)); 28 int id = NO_RETRY_EXPECTED(inotify_init1(IN_CLOEXEC));
27 if (id < 0) return -1; 29 if (id < 0) return -1;
28 // Some systems dosn't support setting this as non-blocking. Since watching 30 // Some systems dosn't support setting this as non-blocking. Since watching
29 // internals are kept away from the user, we know it's possible to continue, 31 // internals are kept away from the user, we know it's possible to continue,
30 // even if setting non-blocking fails. 32 // even if setting non-blocking fails.
31 FDUtils::SetNonBlocking(id); 33 FDUtils::SetNonBlocking(id);
32 return id; 34 return id;
33 } 35 }
34 36
35 37
36 void FileSystemWatcher::Close(intptr_t id) { 38 void FileSystemWatcher::Close(intptr_t id) {
37 USE(id); 39 USE(id);
38 } 40 }
39 41
40 42
41 intptr_t FileSystemWatcher::WatchPath(intptr_t id, 43 intptr_t FileSystemWatcher::WatchPath(intptr_t id,
42 const char* path, 44 const char* path,
43 int events, 45 int events,
44 bool recursive) { 46 bool recursive) {
45 int list_events = IN_DELETE_SELF | IN_MOVE_SELF; 47 int list_events = IN_DELETE_SELF | IN_MOVE_SELF;
46 if (events & kCreate) list_events |= IN_CREATE; 48 if (events & kCreate) list_events |= IN_CREATE;
47 if (events & kModifyContent) list_events |= IN_CLOSE_WRITE | IN_ATTRIB; 49 if (events & kModifyContent) list_events |= IN_CLOSE_WRITE | IN_ATTRIB;
48 if (events & kDelete) list_events |= IN_DELETE; 50 if (events & kDelete) list_events |= IN_DELETE;
49 if (events & kMove) list_events |= IN_MOVE; 51 if (events & kMove) list_events |= IN_MOVE;
50 int path_id = TEMP_FAILURE_RETRY(inotify_add_watch(id, path, list_events)); 52 int path_id = NO_RETRY_EXPECTED(inotify_add_watch(id, path, list_events));
51 if (path_id < 0) { 53 if (path_id < 0) {
52 return -1; 54 return -1;
53 } 55 }
54 return path_id; 56 return path_id;
55 } 57 }
56 58
57 59
58 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) { 60 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
59 VOID_TEMP_FAILURE_RETRY(inotify_rm_watch(id, path_id)); 61 VOID_NO_RETRY_EXPECTED(inotify_rm_watch(id, path_id));
60 } 62 }
61 63
62 64
63 intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) { 65 intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
64 USE(path_id); 66 USE(path_id);
65 return id; 67 return id;
66 } 68 }
67 69
68 70
69 Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) { 71 Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 111 }
110 ASSERT(offset == bytes); 112 ASSERT(offset == bytes);
111 return events; 113 return events;
112 } 114 }
113 115
114 } // namespace bin 116 } // namespace bin
115 } // namespace dart 117 } // namespace dart
116 118
117 #endif // defined(TARGET_OS_LINUX) 119 #endif // defined(TARGET_OS_LINUX)
118 120
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_android.cc ('k') | runtime/bin/file_system_watcher_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698