From 9a02d3a1a87d3f8a466459a933858fcf37a3c1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Thu, 14 Oct 1999 20:26:14 -0700 Subject: [PATCH] now works (better) on linux Rev: src/modules/files/sendfile.c:1.30 --- src/modules/files/sendfile.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/files/sendfile.c b/src/modules/files/sendfile.c index 742f6f00ef..9e755a3c53 100644 --- a/src/modules/files/sendfile.c +++ b/src/modules/files/sendfile.c @@ -1,5 +1,5 @@ /* - * $Id: sendfile.c,v 1.29 1999/10/14 19:37:47 grubba Exp $ + * $Id: sendfile.c,v 1.30 1999/10/15 03:26:14 hubbe Exp $ * * Sends headers + from_fd[off..off+len-1] + trailers to to_fd asyncronously. * @@ -463,6 +463,10 @@ void worker(void *this_) if (len > MMAP_SIZE) { len = MMAP_SIZE; } + + /* Hope this is a correct fix. /Hubbe */ + if(len == 0) goto send_trailers; + mem = mmap(NULL, len, PROT_READ, MAP_FILE|MAP_SHARED, this->from_fd, this->offset); if (((long)mem) == ((long)MAP_FAILED)) { @@ -493,6 +497,8 @@ void worker(void *this_) } munmap(mem, len); } + + /* shouldn't there be a goto here ? /Hubbe */ } } use_read_write: @@ -923,6 +929,12 @@ static void sf_create(INT32 args) sf.from->flags |= FILE_LOCK_FD; } + /* It is a good idea to increase num_threads before the thread + * is actually created, otherwise the backend (or somebody) may + * be hogging the interpreter lock... /Hubbe + */ + num_threads++; + /* The worker will have a ref. */ th_farm(worker, THIS); #if 0 @@ -937,7 +949,6 @@ static void sf_create(INT32 args) "Failed to create thread.\n"); } #endif /* 0 */ - num_threads++; } return; } -- GitLab