diff --git a/monitor.c b/monitor.c index ee216f3d..0b506cb7 100644 --- a/monitor.c +++ b/monitor.c @@ -124,6 +124,7 @@ int monitor_setup_sockets() WHY_perror("setsockopt"); if (debug&(DEBUG_IO|DEBUG_VERBOSE_IO)) WHY("Monitor server socket setup"); + fd_watch(monitor_named_socket,monitor_poll,POLL_IN); return 0; error: @@ -132,44 +133,6 @@ int monitor_setup_sockets() return -1; } -int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax) -{ - /* Make sure sockets are open */ - monitor_setup_sockets(); - - /* This block should work, but in reality it doesn't. - poll() on linux is ALWAYS claiming that accept() can be - run. So we just have to check it whenever some other fd triggers - poll to break, which fortunately is fairly often. */ - if ((*fdcount)>=fdmax) return -1; - if (monitor_named_socket>-1) - { - if (debug&(DEBUG_IO|DEBUG_VERBOSE_IO)) { - WHYF("Monitor named unix domain socket is poll() slot #%d (fd %d)\n", - *fdcount,monitor_named_socket); - } - fds[*fdcount].fd=monitor_named_socket; - fds[*fdcount].events=POLLIN; - (*fdcount)++; - } - - int i; - if (debug&(DEBUG_IO|DEBUG_VERBOSE_IO)) - WHYF("looking at %d monitor clients",monitor_socket_count); - for(i=0;i=fdmax) return -1; - if (debug&(DEBUG_IO|DEBUG_VERBOSE_IO)) { - WHYF("Monitor named unix domain client socket is poll() slot #%d (fd %d)\n", - *fdcount,monitor_sockets[i].socket); - } - fds[*fdcount].fd=monitor_sockets[i].socket; - fds[*fdcount].events=POLLIN; - (*fdcount)++; - } - - return 0; -} - void monitor_poll(int ignored_fd) { int s; diff --git a/overlay.c b/overlay.c index f1832520..ae7ada39 100644 --- a/overlay.c +++ b/overlay.c @@ -147,8 +147,9 @@ int overlayServerMode() /* Create structures to use 1MB of RAM for testing */ overlay_route_init(1); - /* Setup up MDP unix domain sockets */ + /* Setup up MDP & monitor interface unix domain sockets */ overlay_mdp_setup_sockets(); + monitor_setup_sockets(); /* Get rhizome server started BEFORE populating fd list so that the server's listen socket is in the list for poll() */