sockets: don't deadlock when connecting to own pipe address

This commit is contained in:
Björn Linse
2017-05-06 09:31:36 +02:00
parent 6a75938758
commit 5a151555c8
4 changed files with 92 additions and 16 deletions

View File

@@ -97,6 +97,18 @@ char *server_address_new(void)
#endif
}
/// Check if this instance owns a pipe address.
/// The argument must already be resolved to an absolute path!
bool server_owns_pipe_address(const char *path)
{
for (int i = 0; i < watchers.ga_len; i++) {
if (!strcmp(path, ((SocketWatcher **)watchers.ga_data)[i]->addr)) {
return true;
}
}
return false;
}
/// Starts listening for API calls.
///
/// The socket type is determined by parsing `endpoint`: If it's a valid IPv4