ctld.c (265509) | ctld.c (265511) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: stable/10/usr.sbin/ctld/ctld.c 265509 2014-05-07 07:32:45Z trasz $ | 29 * $FreeBSD: stable/10/usr.sbin/ctld/ctld.c 265511 2014-05-07 07:35:21Z trasz $ |
30 */ 31 32#include <sys/types.h> 33#include <sys/time.h> 34#include <sys/socket.h> 35#include <sys/wait.h> 36#include <netinet/in.h> 37#include <assert.h> --- 1166 unchanged lines hidden (view full) --- 1204 if (errno == EEXIST) 1205 log_errx(1, "daemon already running, pid: %jd.", 1206 (intmax_t)otherpid); 1207 log_err(1, "cannot open or create pidfile \"%s\"", 1208 newconf->conf_pidfile_path); 1209 } 1210 } 1211 | 30 */ 31 32#include <sys/types.h> 33#include <sys/time.h> 34#include <sys/socket.h> 35#include <sys/wait.h> 36#include <netinet/in.h> 37#include <assert.h> --- 1166 unchanged lines hidden (view full) --- 1204 if (errno == EEXIST) 1205 log_errx(1, "daemon already running, pid: %jd.", 1206 (intmax_t)otherpid); 1207 log_err(1, "cannot open or create pidfile \"%s\"", 1208 newconf->conf_pidfile_path); 1209 } 1210 } 1211 |
1212 if (oldconf->conf_kernel_port_on != newconf->conf_kernel_port_on) { 1213 if (newconf->conf_kernel_port_on == true) { 1214 log_debugx("enabling CTL iSCSI port"); 1215 error = kernel_port_on(); 1216 if (error != 0) 1217 log_errx(1, "failed to enable CTL iSCSI port, exiting"); 1218 } else { 1219 error = kernel_port_off(); 1220 if (error != 0) 1221 log_warnx("failed to disable CTL iSCSI port"); 1222 } 1223 } 1224 |
|
1212 TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) { 1213 /* 1214 * First, remove any targets present in the old configuration 1215 * and missing in the new one. 1216 */ 1217 newtarg = target_find(newconf, oldtarg->t_name); 1218 if (newtarg == NULL) { 1219 TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next, --- 612 unchanged lines hidden (view full) --- 1832 newconf = conf_new_from_file(config_path); 1833 if (newconf == NULL) 1834 log_errx(1, "configuration error, exiting"); 1835 if (debug > 0) { 1836 oldconf->conf_debug = debug; 1837 newconf->conf_debug = debug; 1838 } 1839 | 1225 TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) { 1226 /* 1227 * First, remove any targets present in the old configuration 1228 * and missing in the new one. 1229 */ 1230 newtarg = target_find(newconf, oldtarg->t_name); 1231 if (newtarg == NULL) { 1232 TAILQ_FOREACH_SAFE(oldlun, &oldtarg->t_luns, l_next, --- 612 unchanged lines hidden (view full) --- 1845 newconf = conf_new_from_file(config_path); 1846 if (newconf == NULL) 1847 log_errx(1, "configuration error, exiting"); 1848 if (debug > 0) { 1849 oldconf->conf_debug = debug; 1850 newconf->conf_debug = debug; 1851 } 1852 |
1840 log_debugx("enabling CTL iSCSI port"); 1841 error = kernel_port_on(); 1842 if (error != 0) 1843 log_errx(1, "failed to enable CTL iSCSI port, exiting"); 1844 | |
1845 error = conf_apply(oldconf, newconf); 1846 if (error != 0) 1847 log_errx(1, "failed to apply configuration, exiting"); 1848 conf_delete(oldconf); 1849 oldconf = NULL; 1850 1851 register_signals(); 1852 --- 28 unchanged lines hidden (view full) --- 1881 oldconf = NULL; 1882 } 1883 } else if (sigterm_received) { 1884 log_debugx("exiting on signal; " 1885 "reloading empty configuration"); 1886 1887 log_debugx("disabling CTL iSCSI port " 1888 "and terminating all connections"); | 1853 error = conf_apply(oldconf, newconf); 1854 if (error != 0) 1855 log_errx(1, "failed to apply configuration, exiting"); 1856 conf_delete(oldconf); 1857 oldconf = NULL; 1858 1859 register_signals(); 1860 --- 28 unchanged lines hidden (view full) --- 1889 oldconf = NULL; 1890 } 1891 } else if (sigterm_received) { 1892 log_debugx("exiting on signal; " 1893 "reloading empty configuration"); 1894 1895 log_debugx("disabling CTL iSCSI port " 1896 "and terminating all connections"); |
1889 error = kernel_port_off(); 1890 if (error != 0) 1891 log_warnx("failed to disable CTL iSCSI port"); | |
1892 1893 oldconf = newconf; 1894 newconf = conf_new(); 1895 if (debug > 0) 1896 newconf->conf_debug = debug; 1897 error = conf_apply(oldconf, newconf); 1898 if (error != 0) 1899 log_warnx("failed to apply configuration"); 1900 1901 log_warnx("exiting on signal"); 1902 exit(0); 1903 } else { 1904 nchildren -= wait_for_children(false); 1905 assert(nchildren >= 0); 1906 } 1907 } 1908 /* NOTREACHED */ 1909} | 1897 1898 oldconf = newconf; 1899 newconf = conf_new(); 1900 if (debug > 0) 1901 newconf->conf_debug = debug; 1902 error = conf_apply(oldconf, newconf); 1903 if (error != 0) 1904 log_warnx("failed to apply configuration"); 1905 1906 log_warnx("exiting on signal"); 1907 exit(0); 1908 } else { 1909 nchildren -= wait_for_children(false); 1910 assert(nchildren >= 0); 1911 } 1912 } 1913 /* NOTREACHED */ 1914} |