Diff

Differences From Artifact [a9d9efdd38]:

To Artifact [3095917664]:


217
218
219
220
221
222
223

224
225
226
227
228
229
230
...
232
233
234
235
236
237
238


239
240
241
242
243
244
245
246
247


248


249
250
251
252
253
254
255
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
...
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
#  define filed_log_msg_debug(x, ...) /**/
#endif

/* Initialize logging thread */
static void *filed_logging_thread(void *arg_p) {
	struct filed_logging_thread_args *arg;
	struct filed_log_entry *curr, *prev;

	FILE *fp;

	arg = arg_p;

	fp = arg->fp;

	while (1) {
................................................................................
		pthread_cond_wait(&filed_log_msg_list_ready, &filed_log_msg_list_mutex);

		curr = filed_log_msg_list;
		filed_log_msg_list = NULL;

		pthread_mutex_unlock(&filed_log_msg_list_mutex);



		prev = NULL;
		for (; curr; curr = curr->_next) {
			curr->_prev = prev;

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

		fclose(fp);

		return;
	}

	if (request->headers.range.present) {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s RANGE_START=%llu RANGE_LENGTH=%llu",
			fd,
			request->path,
			(unsigned long long) request->headers.range.offset,
			(unsigned long long) request->headers.range.length
		);
	} else {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s", fd, request->path);
	}

	path = request->path;

................................................................................
	} else {
		if (request->headers.range.offset != 0 || request->headers.range.length >= 0) {
			if (request->headers.range.offset >= fileinfo->len) {
				filed_log_msg("PROCESS_REPLY_COMPLETE FD=%i ERROR=416", fd);

				filed_error_page(fp, date_current, 416);
			} else {
				if (request->headers.range.length < 0) {
					filed_log_msg_debug("Computing length to fit in bounds: fileinfo->len = %llu, request->headers.range.offset = %llu",
						(unsigned long long) fileinfo->len,
						(unsigned long long) request->headers.range.offset
					);

					request->headers.range.length = fileinfo->len - request->headers.range.offset;
				}

				filed_log_msg_debug("Partial request, starting at: %llu and running for %llu bytes",
					(unsigned long long) request->headers.range.offset,
					(unsigned long long) request->headers.range.length
				);

				http_code = 206;
			}
		} else {
			if (request->headers.range.present) {
				http_code = 206;







>







 







>
>









>
>
|
>
>







 







|



|







 







|








|

|







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
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
259
260
261
262
...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
#  define filed_log_msg_debug(x, ...) /**/
#endif

/* Initialize logging thread */
static void *filed_logging_thread(void *arg_p) {
	struct filed_logging_thread_args *arg;
	struct filed_log_entry *curr, *prev;
	time_t now;
	FILE *fp;

	arg = arg_p;

	fp = arg->fp;

	while (1) {
................................................................................
		pthread_cond_wait(&filed_log_msg_list_ready, &filed_log_msg_list_mutex);

		curr = filed_log_msg_list;
		filed_log_msg_list = NULL;

		pthread_mutex_unlock(&filed_log_msg_list_mutex);

		now = time(NULL);

		prev = NULL;
		for (; curr; curr = curr->_next) {
			curr->_prev = prev;

			prev = curr;
		}

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

			prev = curr;
			curr = curr->_prev;

			free(prev);
		}
................................................................................

		fclose(fp);

		return;
	}

	if (request->headers.range.present) {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s RANGE_START=%llu RANGE_LENGTH=%lli",
			fd,
			request->path,
			(unsigned long long) request->headers.range.offset,
			(long long) request->headers.range.length
		);
	} else {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s", fd, request->path);
	}

	path = request->path;

................................................................................
	} else {
		if (request->headers.range.offset != 0 || request->headers.range.length >= 0) {
			if (request->headers.range.offset >= fileinfo->len) {
				filed_log_msg("PROCESS_REPLY_COMPLETE FD=%i ERROR=416", fd);

				filed_error_page(fp, date_current, 416);
			} else {
				if (request->headers.range.length == ((off_t) -1)) {
					filed_log_msg_debug("Computing length to fit in bounds: fileinfo->len = %llu, request->headers.range.offset = %llu",
						(unsigned long long) fileinfo->len,
						(unsigned long long) request->headers.range.offset
					);

					request->headers.range.length = fileinfo->len - request->headers.range.offset;
				}

				filed_log_msg_debug("Partial request, starting at: %llu and running for %lli bytes",
					(unsigned long long) request->headers.range.offset,
					(long long) request->headers.range.length
				);

				http_code = 206;
			}
		} else {
			if (request->headers.range.present) {
				http_code = 206;