| 137 | } |
| 138 | |
| 139 | std::error_code |
| 140 | IPCSocketServer::init() |
| 141 | { |
| 142 | // Need to run some validations on the pathname to avoid issue. Normally this would not be an issue, but some tests may fail on |
| 143 | // this. |
| 144 | if (_conf.sockPathName.empty() || _conf.sockPathName.size() > sizeof _serverAddr.sun_path) { |
| 145 | Dbg(dbg_ctl, "Invalid unix path name, check the size."); |
| 146 | return std::make_error_code(static_cast<std::errc>(ENAMETOOLONG)); |
| 147 | } |
| 148 | |
| 149 | std::error_code ec; // Flag possible errors. |
| 150 | |
| 151 | if (this->create_socket(ec); ec) { |
| 152 | return ec; |
| 153 | } |
| 154 | |
| 155 | Dbg(dbg_ctl, "Using %s as socket path.", _conf.sockPathName.c_str()); |
| 156 | _serverAddr.sun_family = AF_UNIX; |
| 157 | std::strncpy(_serverAddr.sun_path, _conf.sockPathName.c_str(), sizeof(_serverAddr.sun_path) - 1); |
| 158 | |
| 159 | if (this->bind(ec); ec) { |
| 160 | this->close(); |
| 161 | return ec; |
| 162 | } |
| 163 | |
| 164 | if (this->listen(ec); ec) { |
| 165 | this->close(); |
| 166 | return ec; |
| 167 | } |
| 168 | |
| 169 | return ec; |
| 170 | } |
| 171 | |
| 172 | bool |
| 173 | IPCSocketServer::poll_for_new_client(std::chrono::milliseconds timeout) const |
no test coverage detected