Nog een poging...

This commit is contained in:
Thulinma 2010-11-07 23:50:20 +01:00
parent 4776cd08d7
commit 66b8de0a86
2 changed files with 7 additions and 10 deletions

View file

@ -16,6 +16,7 @@ bool inited = false;
bool stopparsing = false; bool stopparsing = false;
timeval lastrec; timeval lastrec;
int CONN_fd = 0;
FILE * CONN = 0; FILE * CONN = 0;
#include "parsechunks.cpp" //chunkstream parsing #include "parsechunks.cpp" //chunkstream parsing
#include "handshake.cpp" //handshaking #include "handshake.cpp" //handshaking
@ -28,7 +29,8 @@ int main(){
int status; int status;
while (server_socket > 0){ while (server_socket > 0){
waitpid((pid_t)-1, &status, WNOHANG); waitpid((pid_t)-1, &status, WNOHANG);
CONN = DDV_Accept(server_socket); CONN_fd = DDV_Accept(server_socket);
CONN = fdopen(CONN_fd, "r+");
pid_t myid = fork(); pid_t myid = fork();
if (myid == 0){ if (myid == 0){
break; break;
@ -72,8 +74,8 @@ int main(){
int poller = epoll_create(1); int poller = epoll_create(1);
struct epoll_event ev; struct epoll_event ev;
ev.events = EPOLLIN; ev.events = EPOLLIN;
ev.data.fd = fileno(CONN); ev.data.fd = CONN_fd;
epoll_ctl(poller, EPOLL_CTL_ADD, fileno(CONN), &ev); epoll_ctl(poller, EPOLL_CTL_ADD, CONN_fd, &ev);
struct epoll_event events[1]; struct epoll_event events[1];

View file

@ -31,11 +31,6 @@ int DDV_Listen(int port){
} }
} }
FILE * DDV_Accept(int sock){ int DDV_Accept(int sock){
int r = accept(sock, 0, 0); return accept(sock, 0, 0);
if (r != -1){
return fdopen(r, "r+");
}else{
return (FILE*)0;
}
} }