fix select
git-svn-id: file:///raid/svn-personal/tewi/trunk@101 8739d7e6-ffea-ec47-b151-bdff447c6205
This commit is contained in:
parent
1d765c4f76
commit
cfb7b567f6
|
@ -749,9 +749,13 @@ extern SERVICE_STATUS status;
|
||||||
extern SERVICE_STATUS_HANDLE status_handle;
|
extern SERVICE_STATUS_HANDLE status_handle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(__HAIKU__)
|
||||||
struct thread_entry {
|
struct thread_entry {
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
thread_id thread;
|
||||||
|
#else
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
|
#endif
|
||||||
bool used;
|
bool used;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -759,7 +763,7 @@ struct thread_entry {
|
||||||
void tw_server_loop(void) {
|
void tw_server_loop(void) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int i;
|
int i;
|
||||||
#ifdef __MINGW32__
|
#if defined(__MINGW32__) || defined(__HAIKU__)
|
||||||
struct thread_entry threads[2048];
|
struct thread_entry threads[2048];
|
||||||
for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) {
|
for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) {
|
||||||
threads[i].used = false;
|
threads[i].used = false;
|
||||||
|
@ -783,18 +787,6 @@ void tw_server_loop(void) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if(ret == 0) {
|
} else if(ret == 0) {
|
||||||
#ifdef __MINGW32__
|
|
||||||
for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) {
|
|
||||||
if(threads[i].used) {
|
|
||||||
DWORD ex;
|
|
||||||
GetExitCodeThread(threads[i].handle, &ex);
|
|
||||||
if(ex != STILL_ACTIVE) {
|
|
||||||
CloseHandle(threads[i].handle);
|
|
||||||
threads[i].used = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef SERVICE
|
#ifdef SERVICE
|
||||||
if(status.dwCurrentState == SERVICE_STOP_PENDING) {
|
if(status.dwCurrentState == SERVICE_STOP_PENDING) {
|
||||||
break;
|
break;
|
||||||
|
@ -836,8 +828,28 @@ void tw_server_loop(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__HAIKU__)
|
#elif defined(__HAIKU__)
|
||||||
thread_id thr = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e);
|
for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {
|
||||||
resume_thread(thr);
|
if(threads[j].used) {
|
||||||
|
thread_info info;
|
||||||
|
bool kill = false;
|
||||||
|
if(get_thread_info(threads[j].thread, &info) == B_OK){
|
||||||
|
}else{
|
||||||
|
kill = true;
|
||||||
|
}
|
||||||
|
if(kill){
|
||||||
|
printf("Kill thread %d\n", threads[j].thread);
|
||||||
|
threads[j].used = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {
|
||||||
|
if(!threads[j].used) {
|
||||||
|
threads[j].thread = spawn_thread(tw_server_pass, "Tewi HTTPd", 60, e);
|
||||||
|
threads[j].used = true;
|
||||||
|
resume_thread(threads[j].thread);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if(pid == 0) {
|
if(pid == 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user