Diff

Differences From Artifact [fcb400b744]:

To Artifact [b4d256af0b]:


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

	return(fd);
}

/* Log a message */
//#define FILED_DONT_LOG
#ifdef FILED_DONT_LOG
#  define filed_logging_thread_init() 0
#  define filed_log_msg_debug(x, ...) /**/
#  define filed_log_msg(x) /**/
#else
#ifdef FILED_DEBUG
#  define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
#else
#  define filed_log_msg_debug(x, ...) /**/







|







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

	return(fd);
}

/* Log a message */
//#define FILED_DONT_LOG
#ifdef FILED_DONT_LOG
#  define filed_logging_thread_init(x) 0
#  define filed_log_msg_debug(x, ...) /**/
#  define filed_log_msg(x) /**/
#else
#ifdef FILED_DEBUG
#  define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
#else
#  define filed_log_msg_debug(x, ...) /**/
221
222
223
224
225
226
227

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258

			prev = curr;
		}

		curr = prev;
		while (curr) {
			fprintf(fp, "%s THREAD=%llu\n", curr->buffer, (unsigned long long) curr->thread);


			prev = curr;
			curr = curr->_prev;

			free(prev);
		}
	}

	return(NULL);
}

static int filed_logging_thread_init(const char *logfile) {
	struct filed_logging_thread_args *args;
	pthread_t thread_id;
	FILE *logfp;

	if (strcmp(logfile, "-") == 0) {
		logfp = stdout;
	} else {
		logfp = fopen(logfile, "a+");
		if (logfp == NULL) {
			return(1);
		}
	}

	args = malloc(sizeof(*args));
	args->fp = logfp;

	filed_log_msg_list = NULL;

	pthread_mutex_init(&filed_log_msg_list_mutex, NULL);







>











|


<
<
<
<
<
<
<
<
<
<







221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242










243
244
245
246
247
248
249

			prev = curr;
		}

		curr = prev;
		while (curr) {
			fprintf(fp, "%s THREAD=%llu\n", curr->buffer, (unsigned long long) curr->thread);
			fflush(fp);

			prev = curr;
			curr = curr->_prev;

			free(prev);
		}
	}

	return(NULL);
}

static int filed_logging_thread_init(FILE *logfp) {
	struct filed_logging_thread_args *args;
	pthread_t thread_id;











	args = malloc(sizeof(*args));
	args->fp = logfp;

	filed_log_msg_list = NULL;

	pthread_mutex_init(&filed_log_msg_list_mutex, NULL);
1002
1003
1004
1005
1006
1007
1008

1009
1010
1011
1012
1013
1014
1015
	return(0);
}

/* Run process */
int main(int argc, char **argv) {
	struct option options[10];
	const char *bind_addr = BIND_ADDR, *newroot = NULL, *log_file = LOG_FILE;

	uid_t user = 0;
	int port = PORT, thread_count = THREAD_COUNT;
	int cache_size = CACHE_SIZE;
	int init_ret, chroot_ret, setuid_ret, lookup_ret, chdir_ret;
	int setuid_enabled = 0, daemon_enabled = 0;
	int ch;
	int fd;







>







993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
	return(0);
}

/* Run process */
int main(int argc, char **argv) {
	struct option options[10];
	const char *bind_addr = BIND_ADDR, *newroot = NULL, *log_file = LOG_FILE;
	FILE *log_fp;
	uid_t user = 0;
	int port = PORT, thread_count = THREAD_COUNT;
	int cache_size = CACHE_SIZE;
	int init_ret, chroot_ret, setuid_ret, lookup_ret, chdir_ret;
	int setuid_enabled = 0, daemon_enabled = 0;
	int ch;
	int fd;
1064
1065
1066
1067
1068
1069
1070












1071
1072
1073
1074
1075
1076
1077
				return(1);
			case 'h':
				filed_print_help(stdout, 1, NULL);

				return(0);
		}
	}













	/* Create listening socket */
	fd = filed_listen(bind_addr, port);
	if (fd < 0) {
		perror("filed_listen");

		return(1);







>
>
>
>
>
>
>
>
>
>
>
>







1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
				return(1);
			case 'h':
				filed_print_help(stdout, 1, NULL);

				return(0);
		}
	}

	/* Open log file */
	if (strcmp(log_file, "-") == 0) {
		log_fp = stdout;
	} else {
		log_fp = fopen(log_file, "a+");
		if (log_fp == NULL) {
			perror("fopen");

			return(4);
		}
	}

	/* Create listening socket */
	fd = filed_listen(bind_addr, port);
	if (fd < 0) {
		perror("filed_listen");

		return(1);
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
	if (init_ret != 0) {
		perror("filed_init");

		return(3);
	}

	/* Create logging thread */
	init_ret = filed_logging_thread_init(log_file);
	if (init_ret != 0) {
		perror("filed_logging_thread_init");

		return(4);
	}

	/* Create worker threads */







|







1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
	if (init_ret != 0) {
		perror("filed_init");

		return(3);
	}

	/* Create logging thread */
	init_ret = filed_logging_thread_init(log_fp);
	if (init_ret != 0) {
		perror("filed_logging_thread_init");

		return(4);
	}

	/* Create worker threads */