Diff

Differences From Artifact [521ac713bc]:

To Artifact [c245fb8d4f]:


  1114   1114   	/* Create listening socket */
  1115   1115   	fd = filed_listen(bind_addr, port);
  1116   1116   	if (fd < 0) {
  1117   1117   		perror("filed_listen");
  1118   1118   
  1119   1119   		return(1);
  1120   1120   	}
         1121  +
         1122  +	/* Become a daemon */
         1123  +	if (daemon_enabled) {
         1124  +		init_ret = filed_daemonize();
         1125  +		if (init_ret != 0) {
         1126  +			perror("filed_daemonize");
         1127  +
         1128  +			return(6);
         1129  +		}
         1130  +	}
  1121   1131   
  1122   1132   	/* Chroot, if appropriate */
  1123   1133   	if (newroot) {
  1124   1134   		chdir_ret = chdir(newroot);
  1125   1135   		if (chdir_ret != 0) {
  1126   1136   			perror("chdir");
  1127   1137   
................................................................................
  1142   1152   		if (setuid_ret != 0) {
  1143   1153   			perror("setuid");
  1144   1154   
  1145   1155   			return(1);
  1146   1156   		}
  1147   1157   	}
  1148   1158   
  1149         -	/* Become a daemon */
  1150         -	if (daemon_enabled) {
  1151         -		filed_daemonize();
  1152         -	}
  1153         -
  1154   1159   	/* Initialize */
  1155   1160   	init_ret = filed_init(cache_size);
  1156   1161   	if (init_ret != 0) {
  1157   1162   		perror("filed_init");
  1158   1163   
  1159   1164   		return(3);
  1160   1165   	}
................................................................................
  1168   1173   	}
  1169   1174   
  1170   1175   	/* Create worker threads */
  1171   1176   	init_ret = filed_worker_threads_init(fd, thread_count);
  1172   1177   	if (init_ret != 0) {
  1173   1178   		perror("filed_worker_threads_init");
  1174   1179   
  1175         -		return(4);
         1180  +		return(5);
  1176   1181   	}
  1177   1182   
  1178   1183   	/* Wait for threads to exit */
  1179   1184   	/* XXX:TODO: Monitor thread usage */
  1180   1185   	while (1) {
  1181   1186   		sleep(60);
  1182   1187   	}
  1183   1188   
  1184   1189   	/* Return in failure */
  1185   1190   	return(2);
  1186   1191   }