forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.cpp
34 lines (29 loc) · 935 Bytes
/
stream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Copyright 2014-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
#include "watchman.h"
std::unique_ptr<watchman_stream> w_stm_connect(int timeoutms) {
// Default to using unix domain sockets unless disabled by config
auto use_unix_domain = Configuration().getBool("use-unix-domain", true);
if (use_unix_domain) {
auto stm = w_stm_connect_unix(get_unix_sock_name().c_str(), timeoutms);
if (stm) {
return stm;
}
}
#ifdef _WIN32
// Fall back to using good? old named pipes!
if (WSAGetLastError() == WSAEAFNOSUPPORT) {
return w_stm_connect_named_pipe(
get_named_pipe_sock_path().c_str(), timeoutms);
}
#endif
return nullptr;
}
int w_poll_events(struct watchman_event_poll* p, int n, int timeoutms) {
#ifdef _WIN32
if (!p->evt->isSocket()) {
return w_poll_events_named_pipe(p, n, timeoutms);
}
#endif
return w_poll_events_sockets(p, n, timeoutms);
}