MCPcopy Index your code
hub / github.com/F-Stack/f-stack / Monitor

Function Monitor

tools/ngctl/main.c:278–310  ·  view source on GitHub ↗

* Thread that monitors csock and dsock while main thread * can be blocked in el_gets(). */

Source from the content-addressed store, hash-verified

276 * can be blocked in el_gets().
277 */
278static void *
279Monitor(void *v __unused)
280{
281 struct sigaction act;
282 const int maxfd = MAX(csock, dsock) + 1;
283
284 act.sa_handler = Unblock;
285 sigemptyset(&act.sa_mask);
286 act.sa_flags = 0;
287 sigaction(SIGUSR1, &act, NULL);
288
289 pthread_mutex_lock(&mutex);
290 for (;;) {
291 fd_set rfds;
292
293 /* See if any data or control messages are arriving. */
294 FD_ZERO(&rfds);
295 FD_SET(csock, &rfds);
296 FD_SET(dsock, &rfds);
297 unblock = 0;
298 if (select(maxfd, &rfds, NULL, NULL, NULL) <= 0) {
299 if (errno == EINTR) {
300 if (unblock == 1)
301 pthread_cond_wait(&cond, &mutex);
302 continue;
303 }
304 err(EX_OSERR, "select");
305 }
306 ReadSockets(&rfds);
307 }
308
309 return (NULL);
310}
311#endif
312
313static char *

Callers

nothing calls this directly

Calls 4

pthread_mutex_lockFunction · 0.85
selectFunction · 0.85
ReadSocketsFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected