- flags = (long) fcntl(housepipe[1], F_GETFL);
- flags |= O_NONBLOCK;
- fcntl(housepipe[1], F_SETFL, flags);
-
- while(1) {
- do {
- did_something = 0;
- tv.tv_sec = HOUSEKEEPING_WAKEUP;
- tv.tv_usec = 0;
- FD_ZERO(&readfds);
- FD_SET(housepipe[0], &readfds);
- select(housepipe[0] + 1, &readfds, 0L, 0L, &tv);
- if (FD_ISSET(housepipe[0], &readfds)) {
- did_something = 1;
- }
-
- if (did_something) {
- read(housepipe[0], house_cmd, 256);
- }
- else {
- memset(house_cmd, 0, 256);
- strcpy(house_cmd, "MINUTE");
- }
-
-
- /* Do whatever this cmd requires */
- if (!strcmp(house_cmd, "MINUTE")) {
- terminate_idle_sessions();
- }
-
- else if (!strcmp(house_cmd, "SCHED_SHUTDOWN")) {
- check_sched_shutdown();
- }
-
- else {
- lprintf(7, "Unknown housekeeping command\n");
- }
-
- } while (did_something);
+ cdb_begin_transaction();
+ CtdlForEachRoom(check_ref_counts_backend, (void *)new_refcounts );
+ cdb_end_transaction();
+
+ for (a=0; a<MAXFLOORS; ++a) {
+ lgetfloor(&flbuf, a);
+ flbuf.f_ref_count = new_refcounts[a];
+ if (new_refcounts[a] > 0) {
+ flbuf.f_flags = flbuf.f_flags | QR_INUSE;
+ }
+ else {
+ flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
+ }
+ lputfloor(&flbuf, a);
+ syslog(LOG_DEBUG, "housekeeping: floor %d has %d rooms", a, new_refcounts[a]);