Check-in [20fd373453]
Overview
Comment:Added support for SIGHUP flushing all caches
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 20fd373453e3b0784c3f9e9d57ee691dbcdefb10
User & Date: rkeene on 2014-06-16 17:15:19
Other Links: manifest | tags
Context
2014-06-20
04:45
Explicitly ignore the return value of read() for random data check-in: 6ab9a334b8 user: rkeene tags: trunk
2014-06-16
17:15
Added support for SIGHUP flushing all caches check-in: 20fd373453 user: rkeene tags: trunk
2014-02-19
16:32
Post-release version increment check-in: d65da49b32 user: rkeene tags: trunk
Changes

Modified filed.c from [d44c0f8297] to [3f7bad2ab6].

135
136
137
138
139
140
141






























142
143
144
145
146
147
148
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







struct filed_fileinfo *filed_fileinfo_fdcache = NULL;
unsigned int filed_fileinfo_fdcache_size = 0;

/** Logging **/
struct filed_log_entry *filed_log_msg_list;
pthread_mutex_t filed_log_msg_list_mutex;
pthread_cond_t filed_log_msg_list_ready;

/* Signal Handler */
static void filed_signal_handler(int signal_number) {
	struct filed_fileinfo *cache;
	unsigned int idx;

	switch (signal_number) {
		case SIGHUP:
			for (idx = 0; idx < filed_fileinfo_fdcache_size; idx++) {
				cache = &filed_fileinfo_fdcache[idx];

				pthread_mutex_lock(&cache->mutex);

				cache->path[0] = '\0';
				if (cache->fd >= 0) {
					close(cache->fd);

					cache->fd = -1;
				}

				cache->lastmod = "";
				cache->type = "";

				pthread_mutex_unlock(&cache->mutex);
			}
			break;
	}

	return;
}

/* Initialize cache */
static int filed_init_cache(unsigned int cache_size) {
	unsigned int idx;
	int mutex_init_ret;

	/* Cache may not be re-initialized */
187
188
189
190
191
192
193



194
195
196
197
198
199
200
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233







+
+
+







	called = 1;

	/* Attempt to lock all memory to physical RAM (but don't care if we can't) */
	mlockall(MCL_CURRENT | MCL_FUTURE);

	/* Ignore SIGPIPE */
	signal(SIGPIPE, SIG_IGN);

	/* Handle SIGHUP to release all caches */
	signal(SIGHUP, filed_signal_handler);

	/* Initialize cache structure */
	cache_ret = filed_init_cache(cache_size);
	if (cache_ret != 0) {
		return(cache_ret);
	}