iscsid.c (0bfd163f522701b486e066fa2e56624c02f5081a) iscsid.c (1ecb3c585760be3d454d5ab9a53edcc678d8adc2)
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 380 unchanged lines hidden (view full) ---

389 log_debugx("setting session timeout to %d seconds",
390 timeout);
391 error = setitimer(ITIMER_REAL, &itv, NULL);
392 if (error != 0)
393 log_err(1, "setitimer");
394}
395
396static void
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 380 unchanged lines hidden (view full) ---

389 log_debugx("setting session timeout to %d seconds",
390 timeout);
391 error = setitimer(ITIMER_REAL, &itv, NULL);
392 if (error != 0)
393 log_err(1, "setitimer");
394}
395
396static void
397sigchld_handler(int dummy __unused)
398{
399
400 /*
401 * The only purpose of this handler is to make SIGCHLD
402 * interrupt the ISCSIDWAIT ioctl(2), so we can call
403 * wait_for_children().
404 */
405}
406
407static void
408register_sigchld(void)
409{
410 struct sigaction sa;
411 int error;
412
413 bzero(&sa, sizeof(sa));
414 sa.sa_handler = sigchld_handler;
415 sigfillset(&sa.sa_mask);
416 error = sigaction(SIGCHLD, &sa, NULL);
417 if (error != 0)
418 log_err(1, "sigaction");
419
420}
421
422static void
397handle_request(int iscsi_fd, const struct iscsi_daemon_request *request, int timeout)
398{
399 struct connection *conn;
400
401 log_set_peer_addr(request->idr_conf.isc_target_addr);
402 if (request->idr_conf.isc_target[0] != '\0') {
403 log_set_peer_name(request->idr_conf.isc_target);
404 setproctitle("%s (%s)", request->idr_conf.isc_target_addr, request->idr_conf.isc_target);

--- 112 unchanged lines hidden (view full) ---

517 log_warn("cannot daemonize");
518 pidfile_remove(pidfh);
519 exit(1);
520 }
521 }
522
523 pidfile_write(pidfh);
524
423handle_request(int iscsi_fd, const struct iscsi_daemon_request *request, int timeout)
424{
425 struct connection *conn;
426
427 log_set_peer_addr(request->idr_conf.isc_target_addr);
428 if (request->idr_conf.isc_target[0] != '\0') {
429 log_set_peer_name(request->idr_conf.isc_target);
430 setproctitle("%s (%s)", request->idr_conf.isc_target_addr, request->idr_conf.isc_target);

--- 112 unchanged lines hidden (view full) ---

543 log_warn("cannot daemonize");
544 pidfile_remove(pidfh);
545 exit(1);
546 }
547 }
548
549 pidfile_write(pidfh);
550
551 register_sigchld();
552
525 for (;;) {
526 log_debugx("waiting for request from the kernel");
527
528 memset(&request, 0, sizeof(request));
529 error = ioctl(iscsi_fd, ISCSIDWAIT, &request);
530 if (error != 0) {
531 if (errno == EINTR) {
532 nchildren -= wait_for_children(false);

--- 37 unchanged lines hidden ---
553 for (;;) {
554 log_debugx("waiting for request from the kernel");
555
556 memset(&request, 0, sizeof(request));
557 error = ioctl(iscsi_fd, ISCSIDWAIT, &request);
558 if (error != 0) {
559 if (errno == EINTR) {
560 nchildren -= wait_for_children(false);

--- 37 unchanged lines hidden ---