if the used systemd version supported ProtectSystem=strict but didn't
support StateDirectory (issue seen at least with systemd 232 in Debian 9)
- Debian and Red Hat init.d example files had wrong path for the pid file
+ - Interfaces could end up staying marked as 'disabled' in the database even
+ after becoming back active and monitored, only the shown status was wrong
+ without resulting in any data loss
- New
- Automatic interface selection when the Interface configuration setting
is left empty (new default)
}
}
- /* update interface timestamp in database */
- if (!db_setupdated(iterator->interface, iterator->updated)) {
- handledatabaseerror(s);
- break;
- }
-
if (!iterator->active && !logcount) {
/* throw away if interface hasn't seen any data and is disabled */
if (!iterator->currx && !iterator->curtx) {
break;
}
}
+ }
- /* update interface activity status in database if changed */
- if (!db_setactive(iterator->interface, iterator->active)) {
- handledatabaseerror(s);
- break;
- }
+ /* update interface timestamp in database */
+ if (!db_setupdated(iterator->interface, iterator->updated)) {
+ handledatabaseerror(s);
+ break;
+ }
+
+ /* update interface activity status in database */
+ if (!db_setactive(iterator->interface, iterator->active)) {
+ handledatabaseerror(s);
+ break;
}
iterator = iterator->next;
}
}
- /* change updated only if more recent than previous when timestamp provided */
- if (timestamp > 0) {
- sqlite3_snprintf(1024, sql, "update interface set active=1, updated=datetime(%s, 'localtime') where id=%" PRId64 " and updated < datetime(%s, 'localtime')", nowdate, (int64_t)ifaceid, nowdate);
- } else {
- sqlite3_snprintf(1024, sql, "update interface set active=1, updated=datetime(%s, 'localtime') where id=%" PRId64 "", nowdate, (int64_t)ifaceid);
- }
- if (!db_exec(sql)) {
- /* no transaction rollback needed here as failure of the first step results in no transaction being active */
- return 0;
- }
-
/* total */
if (rx > 0 || tx > 0) {
sqlite3_snprintf(1024, sql, "update interface set rxtotal=rxtotal+%" PRIu64 ", txtotal=txtotal+%" PRIu64 " where id=%" PRId64 "", rx, tx, (int64_t)ifaceid);
}
END_TEST
-START_TEST(db_addtraffic_dated_does_not_turn_back_time)
+START_TEST(db_addtraffic_dated_does_not_touch_updated_time)
{
int ret;
interfaceinfo info;
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(info.rxtotal, 3);
ck_assert_int_eq(info.txtotal, 3);
- ck_assert_int_eq(info.updated, 2100000000);
+ ck_assert_int_lt(info.updated, 2100000000);
ret = db_addtraffic_dated("eth0", 1, 1, 1000);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(info.rxtotal, 4);
ck_assert_int_eq(info.txtotal, 4);
- ck_assert_int_eq(info.updated, 2100000000);
+ ck_assert_int_lt(info.updated, 2100000000);
ret = db_addtraffic("eth0", 1, 1);
ck_assert_int_eq(ret, 1);
tcase_add_test(tc_dbsql, db_setinfo_can_not_update_nonexisting_name);
tcase_add_test(tc_dbsql, db_addtraffic_with_no_traffic_does_nothing);
tcase_add_test(tc_dbsql, db_addtraffic_can_add_traffic_and_interfaces);
- tcase_add_test(tc_dbsql, db_addtraffic_dated_does_not_turn_back_time);
+ tcase_add_test(tc_dbsql, db_addtraffic_dated_does_not_touch_updated_time);
tcase_add_test(tc_dbsql, db_getinterfacecount_counts_interfaces);
tcase_add_test(tc_dbsql, db_getinterfacecountbyname_counts_interfaces);
tcase_add_test(tc_dbsql, db_setactive_fails_with_no_open_db);