khttpd: patch for range support + accumulated patches
The following patch adds the following functionality to khttpd: - Range support. Only simple ranges (from-to) are supported. Range suport enables the debian apt tool to resume aborted http file-transfers. Very important if one plans to run a kernel/debian mirror with khttpd. - Virtual Host support (see docs in patch) - Persistant connections - simple logging via printk if /proc/sys/net/khttpd/logging is set to 1. diff -urN linux-orig/net/khttpd/accept.c linux/net/khttpd/accept.c --- linux-orig/net/khttpd/accept.c Sat Jan 22 11:54:58 2000 +++ linux/net/khttpd/accept.c Fri Jan 12 21:19:55 2001 @@ -107,6 +107,7 @@ memset(NewRequest,0,sizeof(struct http_request)); NewRequest->sock = NewSock; + NewRequest->LastActive = jiffies; NewRequest->Next = threadinfo[CPUNR].WaitForHeaderQueue; diff -urN linux-orig/net/khttpd/datasending.c linux/net/khttpd/datasending.c --- linux-orig/net/khttpd/datasending.c Fri Nov 17 11:36:27 2000 +++ linux/net/khttpd/datasending.c Sat Jan 13 17:58:21 2001 @@ -105,7 +105,7 @@ Space = sock_wspace(CurrentRequest->sock->sk); - ReadSize = min(4*4096,CurrentRequest->FileLength - CurrentRequest->BytesSent); + ReadSize = min(4*4096,CurrentRequest->End - +(CurrentRequest->BytesSent+CurrentRequest->Offset)); ReadSize = min(ReadSize , Space ); if (ReadSize>0) @@ -119,7 +119,7 @@ read_descriptor_t desc; loff_t *ppos; - CurrentRequest->filp->f_pos = CurrentRequest->BytesSent; + CurrentRequest->filp->f_pos = +CurrentRequest->BytesSent+CurrentRequest->Offset; ppos = >filp->f_pos; @@ -137,7 +137,7 @@ else /* FS doesn't support sendfile() */ { mm_segment_t oldfs; - CurrentRequest->filp->f_pos = CurrentRequest->BytesSent; + CurrentRequest->filp->f_pos = +CurrentRequest->BytesSent+CurrentRequest->Offset; oldfs = get_fs(); set_fs(KERNEL_DS); retval = CurrentRequest->filp->f_op->read(CurrentRequest->filp, Block[CPUNR], ReadSize, >filp->f_pos); @@ -160,7 +160,7 @@ If end-of-file or closed connection: Finish this request by moving it to the "logging" queue. */ - if ((CurrentRequest->BytesSent>=CurrentRequest->FileLength)|| + if +((CurrentRequest->BytesSent+CurrentRequest->Offset>=CurrentRequest->End)|| (CurrentRequest->sock->sk->state!=TCP_ESTABLISHED && CurrentRequest->sock->sk->state!=TCP_CLOSE_WAIT)) { diff -urN linux-orig/net/khttpd/logging.c linux/net/khttpd/logging.c --- linux-orig/net/khttpd/logging.c Wed Aug 18 09:45:10 1999 +++ linux/net/khttpd/logging.c Fri Jan 12 21:27:05 2001 @@ -29,6 +29,8 @@ #include #include "structure.h" #include "prototypes.h" +#include "sysctl.h" + /* @@ -58,9 +60,22 @@ while (CurrentRequest!=NULL) { + CurrentRequest->ReqCount++; + CurrentRequest->LastActive = jiffies; + + if (sysctl_khttpd_logging) { + CurrentRequest->FileName[CurrentRequest->FileNameLength]=0; + printk(KERN_NOTICE "File=%s Host=%s Length=%d +Userspace=%d\n",CurrentRequest->FileName,CurrentRequest->Host,CurrentRequest->FileLength,CurrentRequest->IsForUserspace); + } Req = CurrentRequest->Next; - CleanUpRequest(CurrentRequest); + if (CurrentRequest->Persistent) { + sanitize_request(CurrentRequest); + CurrentRequest->Next = threadinfo[CPUNR].WaitForHeaderQueue; + threadinfo[CPUNR].WaitForHeaderQueue = CurrentRequest; + } + else + CleanUpRequest(CurrentRequest); threadinfo[CPUNR].LoggingQueue = Req; diff -urN linux-orig/net/khttpd/misc.c linux/net/khttpd/misc.c --- linux-orig/net/khttpd/misc.cThu Sep 2 11:47:20 1999 +++ linux/net/khttpd/misc.c Fri Jan 12 21:19:55 2001 @@ -132,6 +132,89 @@ LeaveFunction("CleanUpRequest"); } +static char Buffer[1024]; + +static void DummyRead(struct socket *sock, int Size) +{ + struct msghdr msg; + struct ioveciov; + int len,totalbytes=0; + + mm_segment_toldfs; + + + EnterFunction("DummyRead"); + +
khttpd: patch for range support + accumulated patches
The following patch adds the following functionality to khttpd: - Range support. Only simple ranges (from-to) are supported. Range suport enables the debian apt tool to resume aborted http file-transfers. Very important if one plans to run a kernel/debian mirror with khttpd. - Virtual Host support (see docs in patch) - Persistant connections - simple logging via printk if /proc/sys/net/khttpd/logging is set to 1. diff -urN linux-orig/net/khttpd/accept.c linux/net/khttpd/accept.c --- linux-orig/net/khttpd/accept.c Sat Jan 22 11:54:58 2000 +++ linux/net/khttpd/accept.c Fri Jan 12 21:19:55 2001 @@ -107,6 +107,7 @@ memset(NewRequest,0,sizeof(struct http_request)); NewRequest-sock = NewSock; + NewRequest-LastActive = jiffies; NewRequest-Next = threadinfo[CPUNR].WaitForHeaderQueue; diff -urN linux-orig/net/khttpd/datasending.c linux/net/khttpd/datasending.c --- linux-orig/net/khttpd/datasending.c Fri Nov 17 11:36:27 2000 +++ linux/net/khttpd/datasending.c Sat Jan 13 17:58:21 2001 @@ -105,7 +105,7 @@ Space = sock_wspace(CurrentRequest-sock-sk); - ReadSize = min(4*4096,CurrentRequest-FileLength - CurrentRequest-BytesSent); + ReadSize = min(4*4096,CurrentRequest-End - +(CurrentRequest-BytesSent+CurrentRequest-Offset)); ReadSize = min(ReadSize , Space ); if (ReadSize0) @@ -119,7 +119,7 @@ read_descriptor_t desc; loff_t *ppos; - CurrentRequest-filp-f_pos = CurrentRequest-BytesSent; + CurrentRequest-filp-f_pos = +CurrentRequest-BytesSent+CurrentRequest-Offset; ppos = CurrentRequest-filp-f_pos; @@ -137,7 +137,7 @@ else /* FS doesn't support sendfile() */ { mm_segment_t oldfs; - CurrentRequest-filp-f_pos = CurrentRequest-BytesSent; + CurrentRequest-filp-f_pos = +CurrentRequest-BytesSent+CurrentRequest-Offset; oldfs = get_fs(); set_fs(KERNEL_DS); retval = CurrentRequest-filp-f_op-read(CurrentRequest-filp, Block[CPUNR], ReadSize, CurrentRequest-filp-f_pos); @@ -160,7 +160,7 @@ If end-of-file or closed connection: Finish this request by moving it to the "logging" queue. */ - if ((CurrentRequest-BytesSent=CurrentRequest-FileLength)|| + if +((CurrentRequest-BytesSent+CurrentRequest-Offset=CurrentRequest-End)|| (CurrentRequest-sock-sk-state!=TCP_ESTABLISHED CurrentRequest-sock-sk-state!=TCP_CLOSE_WAIT)) { diff -urN linux-orig/net/khttpd/logging.c linux/net/khttpd/logging.c --- linux-orig/net/khttpd/logging.c Wed Aug 18 09:45:10 1999 +++ linux/net/khttpd/logging.c Fri Jan 12 21:27:05 2001 @@ -29,6 +29,8 @@ #include asm/uaccess.h #include "structure.h" #include "prototypes.h" +#include "sysctl.h" + /* @@ -58,9 +60,22 @@ while (CurrentRequest!=NULL) { + CurrentRequest-ReqCount++; + CurrentRequest-LastActive = jiffies; + + if (sysctl_khttpd_logging) { + CurrentRequest-FileName[CurrentRequest-FileNameLength]=0; + printk(KERN_NOTICE "File=%s Host=%s Length=%d +Userspace=%d\n",CurrentRequest-FileName,CurrentRequest-Host,CurrentRequest-FileLength,CurrentRequest-IsForUserspace); + } Req = CurrentRequest-Next; - CleanUpRequest(CurrentRequest); + if (CurrentRequest-Persistent) { + sanitize_request(CurrentRequest); + CurrentRequest-Next = threadinfo[CPUNR].WaitForHeaderQueue; + threadinfo[CPUNR].WaitForHeaderQueue = CurrentRequest; + } + else + CleanUpRequest(CurrentRequest); threadinfo[CPUNR].LoggingQueue = Req; diff -urN linux-orig/net/khttpd/misc.c linux/net/khttpd/misc.c --- linux-orig/net/khttpd/misc.cThu Sep 2 11:47:20 1999 +++ linux/net/khttpd/misc.c Fri Jan 12 21:19:55 2001 @@ -132,6 +132,89 @@ LeaveFunction("CleanUpRequest"); } +static char Buffer[1024]; + +static void DummyRead(struct socket *sock, int Size) +{ + struct msghdr msg; + struct ioveciov; + int len,totalbytes=0; + + mm_segment_toldfs; + + + EnterFunction("DummyRead"); + + + if