Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid upssched infinite tight loops with (probably) closed sockets #1965

Merged
merged 8 commits into from
Jun 23, 2023

Conversation

jimklimov
Copy link
Member

@jimklimov jimklimov commented Jun 13, 2023

Closes: #1964
Probably fallout from #1274 - CC @dtsecon for review

Now it is all quiet (literally, my fans whirred up without the fix):

:; killall upssched ; make -s -j 8 && \
    UPSNAME=heartbeat@localhost NOTIFYTYPE=ONBATT \
    NUT_STATEPATH=/dev/shm NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc \
    ./clients/upssched -DDDDD

   0.000000     [D2] parse_at: is 'heartbeat@localhost' in AT command the 'heartbeat@localhost' we were launched to process?
   0.000052     [D1] parse_at: 'heartbeat@localhost' in AT command matched the 'heartbeat@localhost' UPSNAME we were launched to process
   0.000064     [D1] parse_at: processing CANCEL-TIMER
   0.000087     [D2] parse_at: is 'heartbeat@localhost' in AT command the 'heartbeat@localhost' we were launched to process?
   0.000094     [D1] parse_at: 'heartbeat@localhost' in AT command matched the 'heartbeat@localhost' UPSNAME we were launched to process
   0.000101     [D1] parse_at: processing START-TIMER
   0.000211     [D1] Keeping stderr open due to debug verbosity 5
   0.000257     Timer daemon started
   0.000265     [D2] Timer daemon waiting for connections on pipefd 10
   0.250397     [D3] new connection on fd 7
   0.250466     New timer: heartbeat-failure-timer (15 seconds)
   0.250513     [D1] Exiting upssched (CLI process)
   0.250586     [D4] read() from fd 7 returned 0 too many times in a row, aborting sock_read(); errno=0: Success
   0.250594     [D3] closing connection on fd 7

And that is it, the daemon is holding the clock.

  15.263748   Event: heartbeat-failure-timer
  30.311007     Timer queue empty, exiting
  30.311052     [D1] Timer queue empty, closing pipe and exiting upssched daemon

And it has truly exited:

:; ps -ef | grep -v grep | grep upssch

@jimklimov jimklimov added bug upssched Questions and issues about upssched (timer helper for upsmon) labels Jun 13, 2023
@jimklimov jimklimov added this to the 2.8.1 milestone Jun 13, 2023
jimklimov added a commit to jimklimov/nut that referenced this pull request Jun 13, 2023
jimklimov added a commit to jimklimov/nut that referenced this pull request Jun 13, 2023
@jimklimov
Copy link
Member Author

jimklimov commented Jun 15, 2023

Hm, Jenkins says build #2 succeeded all 140 stages. So on coding side, PR is good to go, and does solve a practical problem.

On content side... gonna wait till next week if @dtsecon has time to comment about this change to his earlier fix in the area.

@jimklimov jimklimov added the ready / code review Author (and CI) consider the PR worthy of human rewievers' time label Jun 15, 2023
@jimklimov
Copy link
Member Author

Rebased over master to stay clean, while waiting for reviews...

@jimklimov jimklimov merged commit f3138ae into networkupstools:master Jun 23, 2023
44 checks passed
@jimklimov jimklimov deleted the upssched-loop branch June 23, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ready / code review Author (and CI) consider the PR worthy of human rewievers' time upssched Questions and issues about upssched (timer helper for upsmon)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

upssched v2.8.0 hogs CPU after a while (Debian 12 package)
1 participant