Author: mattm Date: 2017-08-09 21:29:10 +0200 (Wed, 09 Aug 2017) New Revision: 29330
Modified: trunk/gvm/ChangeLog trunk/gvm/src/gvmd.c Log: * src/gvmd.c (serve_and_schedule): Check last_schedule_time before the second manage_schedule call, to prevent manage_schedule from running every time pselect exits. Also compare with >=, because the pselect will exit with exactly SCHEDULE_PERIOD seconds if not interrupted. Modified: trunk/gvm/ChangeLog =================================================================== --- trunk/gvm/ChangeLog 2017-08-09 13:23:23 UTC (rev 29329) +++ trunk/gvm/ChangeLog 2017-08-09 19:29:10 UTC (rev 29330) @@ -1,3 +1,10 @@ +2017-08-09 Matthew Mundell <matthew.mund...@greenbone.net> + + * src/gvmd.c (serve_and_schedule): Check last_schedule_time before the + second manage_schedule call, to prevent manage_schedule from running + every time pselect exits. Also compare with >=, because the pselect + will exit with exactly SCHEDULE_PERIOD seconds if not interrupted. + 2017-08-08 Matthew Mundell <matthew.mund...@greenbone.net> * tools/gvm-manage-certs.in: Change certificate paths to match GSA, as in Modified: trunk/gvm/src/gvmd.c =================================================================== --- trunk/gvm/src/gvmd.c 2017-08-09 13:23:23 UTC (rev 29329) +++ trunk/gvm/src/gvmd.c 2017-08-09 19:29:10 UTC (rev 29330) @@ -1265,17 +1265,23 @@ fork_update_nvt_cache (); } - if ((time (NULL) - last_schedule_time) > SCHEDULE_PERIOD) - { - if (manage_schedule (fork_connection_for_scheduler, - scheduling_enabled, - sigmask_normal) - < 0) - exit (EXIT_FAILURE); + if ((time (NULL) - last_schedule_time) >= SCHEDULE_PERIOD) + switch (manage_schedule (fork_connection_for_scheduler, + scheduling_enabled, + sigmask_normal, + fork_update_nvt_cache)) + { + case 0: + last_schedule_time = time (NULL); + g_debug ("%s: last_schedule_time: %li", + __FUNCTION__, last_schedule_time); + break; + case 1: + break; + default: + exit (EXIT_FAILURE); + } - last_schedule_time = time (NULL); - } - timeout.tv_sec = SCHEDULE_PERIOD; timeout.tv_nsec = 0; ret = pselect (nfds, &readfds, NULL, &exceptfds, &timeout, @@ -1311,10 +1317,21 @@ accept_and_maybe_fork (manager_socket_2, sigmask_normal); } - if (manage_schedule (fork_connection_for_scheduler, scheduling_enabled, - sigmask_normal) - < 0) - exit (EXIT_FAILURE); + if ((time (NULL) - last_schedule_time) >= SCHEDULE_PERIOD) + switch (manage_schedule (fork_connection_for_scheduler, + scheduling_enabled, sigmask_normal, + fork_update_nvt_cache)) + { + case 0: + last_schedule_time = time (NULL); + g_debug ("%s: last_schedule_time 2: %li", + __FUNCTION__, last_schedule_time); + break; + case 1: + break; + default: + exit (EXIT_FAILURE); + } if (termination_signal) { @@ -1333,8 +1350,6 @@ sighup_update_nvt_cache = 0; fork_update_nvt_cache (); } - - last_schedule_time = time (NULL); } } _______________________________________________ Openvas-commits mailing list Openvas-commits@wald.intevation.org https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits