MCPcopy Create free account
hub / github.com/USBGuard/usbguard / thread

Method thread

src/Library/UEventDeviceManager.cpp:171–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 }
170
171 void UEventDeviceManager::thread()
172 {
173 USBGUARD_LOG(Trace) << "Entering main loop.";
174
175 try {
176 const int max_fd = std::max(_uevent_fd, _wakeup_fd);
177 fd_set readset;
178
179 while (!_thread.stopRequested()) {
180 struct timeval tv_timeout = { 5, 0 };
181 FD_ZERO(&readset);
182 FD_SET(_uevent_fd, &readset);
183 FD_SET(_wakeup_fd, &readset);
184
185 switch (select(max_fd + 1, &readset, NULL, NULL, &tv_timeout)) {
186 case 1: /* uevent or wakeup */
187 case 2: /* uevent and wakeup */
188 if (FD_ISSET(_wakeup_fd, &readset)) {
189 USBGUARD_LOG(Debug) << "Wakeup event.";
190 continue;
191 }
192
193 if (FD_ISSET(_uevent_fd, &readset)) {
194 USBGUARD_LOG(Debug) << "UEvent read event.";
195 ueventProcessRead();
196 }
197
198 break;
199
200 case 0: /* Timeout */
201 continue;
202
203 case -1: /* Error */
204 default:
205 USBGUARD_LOG(Error) << "UEventDeviceManager thread: select failed: errno=" << errno;
206 _thread.stop();
207 }
208 } /* Thread main loop */
209 }
210 catch (const Exception& ex) {
211 USBGUARD_LOG(Error) << "UEventDeviceManager thread: " << ex.message();
212 }
213
214 USBGUARD_LOG(Trace) << "Leaving main loop.";
215 }
216
217 void UEventDeviceManager::ueventProcessRead()
218 {

Callers

nothing calls this directly

Calls 2

stopRequestedMethod · 0.80
stopMethod · 0.45

Tested by

no test coverage detected