Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.w32
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
all : tthttpd.exe

tthttpd.exe : main.o httpd.o utils.o
g++ -O2 -mtune=i686 -mthreads -o $@ main.o httpd.o utils.o -lws2_32
g++ -O2 -mthreads -o $@ main.o httpd.o utils.o -lws2_32

.cxx.o :
g++ -O2 -mtune=i686 -mthreads -Wall -c $<
g++ -O2 -mthreads -Wall -c $<

clean :
rm *.o tthttpd
15 changes: 3 additions & 12 deletions httpd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static bool filetime2unixtime(const FILETIME* ft, struct tm* tm) {

if (!FileTimeToLocalFileTime(ft, &lt)) return false;
if (!FileTimeToSystemTime(&lt, &st)) return false;
memset(tm, 0, sizeof(tm));
memset(tm, 0, sizeof(*tm));
tm->tm_year = st.wYear - 1900;
tm->tm_mon = st.wMonth - 1;
tm->tm_mday = st.wDay;
Expand Down Expand Up @@ -644,7 +644,6 @@ static long long res_read(RES_INFO* res_info, char* data, unsigned long size) {

static RES_INFO* res_popen(std::vector<std::string>& args, std::vector<std::string>& envs) {
int envs_len = 1;
int n;
char *envs_ptr;
char *ptr;
std::vector<std::string>::const_iterator it;
Expand Down Expand Up @@ -700,7 +699,7 @@ static RES_INFO* res_popen(std::vector<std::string>& args, std::vector<std::stri
si.hStdOutput = hClientOut_wr;
si.hStdError = hClientOut_wr;

for(it = args.begin(), n = 0; it != args.end(); it++, n++) {
for(it = args.begin(); it != args.end(); it++) {
if (it != args.begin()) command += " ";
command += *it;
}
Expand Down Expand Up @@ -1290,21 +1289,13 @@ static void send_response_content(server* httpd, int msgsock, RES_INFO* res_info
if (res < 0) break;
if (res > 0) {
if (VERBOSE(3))
#ifdef _WIN32
printf(" reading part %I64d bytes\n", res);
#else
printf(" reading part %lld bytes\n", res);
#endif
printf(" reading part %lld bytes\n", (long long)res);
send(msgsock, buf, res, 0);
if (total > 0) {
total -= res;
}
} else {
#ifdef _WIN32
Sleep(1);
#else
usleep(10);
#endif
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions httpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include <process.h>
#include <direct.h>
#include <io.h>
/* Sleep() takes milliseconds. round up so that sub-millisecond waits
* still yield the cpu. */
#define usleep(usec) Sleep(((usec) + 999) / 1000)
#else
#include <sys/types.h>
#include <sys/socket.h>
Expand Down
Loading