Check-in [3a7004a8cd]
Overview
Comment:Updated to explicitly use sigaction and BSD-style signal handlers, needed to properly deal with SIGPIPE when closing connections
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3a7004a8cd300481f419f134e7955d3b692476f7
User & Date: rkeene on 2016-09-22 18:01:12
Other Links: manifest | tags
Context
2016-09-22
18:34
Updated to use nanosleep() instead of usleep() which requires a _BSD_SOURCE macro check-in: 1fb0b13c23 user: rkeene tags: trunk
18:01
Updated to explicitly use sigaction and BSD-style signal handlers, needed to properly deal with SIGPIPE when closing connections check-in: 3a7004a8cd user: rkeene tags: trunk
2016-08-17
16:23
Post-release version increment check-in: 1233e63987 user: rkeene tags: trunk
Changes

Modified filed.c from [73ad6aa47c] to [ca95c3f44a].

296
297
298
299
300
301
302


303
304
305
306
307
308
309
310
311
312
313
314
315
316

317




318
319
320



321

322
323
324
325
326
327
328

	return(0);
}

/* Initialize process */
static int filed_init(unsigned int cache_size) {
	static int called = 0;


	ssize_t read_ret = 0;
	unsigned int random_value = 0;
	int cache_ret;
	int random_fd;

	if (called) {
		return(0);
	}

	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);
	}








>
>














>
|
>
>
>
>
|


>
>
>
|
>







296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339

	return(0);
}

/* Initialize process */
static int filed_init(unsigned int cache_size) {
	static int called = 0;
	struct sigaction signal_handler_info;
	sigset_t signal_handler_mask;
	ssize_t read_ret = 0;
	unsigned int random_value = 0;
	int cache_ret;
	int random_fd;

	if (called) {
		return(0);
	}

	called = 1;

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

	/* Establish signal handlers */
	/* SIGPIPE should interrupt system calls */
	sigfillset(&signal_handler_mask);
	signal_handler_info.sa_handler = filed_signal_handler;
	signal_handler_info.sa_mask = signal_handler_mask;
	signal_handler_info.sa_flags = SA_RESTART;
	sigaction(SIGPIPE, &signal_handler_info, NULL);

	/* Handle SIGHUP to release all caches */
	sigfillset(&signal_handler_mask);
	signal_handler_info.sa_handler = filed_signal_handler;
	signal_handler_info.sa_mask = signal_handler_mask;
	signal_handler_info.sa_flags = 0;
	sigaction(SIGHUP, &signal_handler_info, NULL);

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