From 7e86800c9f35b7403ff8b4c3dde06cc611a79d15 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 19 Aug 2004 21:45:42 +0000 Subject: [PATCH] OOB work and http name stack fix --- library/httpd/responder.factor | 6 +++--- native/fd.c | 1 + native/iomux.c | 8 ++------ native/socket.c | 5 +++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/library/httpd/responder.factor b/library/httpd/responder.factor index c920346dcc..51431fb425 100644 --- a/library/httpd/responder.factor +++ b/library/httpd/responder.factor @@ -69,9 +69,9 @@ USE: httpd dup f-or-"" [ drop "default-argument" get ] when ; : call-responder ( method argument responder -- ) - [ - over [ responder-argument swap get call ] with-request - ] bind ; + pick [ + [ responder-argument swap get call ] bind + ] with-request ; : no-such-responder ( name -- ) "404 no such responder: " swap cat2 httpd-error ; diff --git a/native/fd.c b/native/fd.c index a0d9ffdddc..6acc0d6737 100644 --- a/native/fd.c +++ b/native/fd.c @@ -89,6 +89,7 @@ bool read_line_step(PORT* port) /* We've reached the end of the above loop, without seeing a newline or EOF, so read again */ + port->buf_pos = port->buf_fill; port->line_ready = false; return false; } diff --git a/native/iomux.c b/native/iomux.c index 55d809eefd..33d975b890 100644 --- a/native/iomux.c +++ b/native/iomux.c @@ -125,7 +125,9 @@ bool perform_read_line_io_task(PORT* port) return true; } else + { return read_line_step(port); + } } bool perform_write_io_task(PORT* port) @@ -232,12 +234,6 @@ CELL next_io_task(void) select(read_fd_count > write_fd_count ? read_fd_count : write_fd_count, &read_fd_set,&write_fd_set,NULL,NULL); - for(i = 0; i < 100; i++) - { - if(FD_ISSET(i,&except_fd_set)) - _exit(1); - } - callback = perform_io_tasks(&read_fd_set,read_fd_count,read_io_tasks); if(callback != F) return callback; diff --git a/native/socket.c b/native/socket.c index 2c06f3a403..24b65c521e 100644 --- a/native/socket.c +++ b/native/socket.c @@ -99,6 +99,8 @@ CELL accept_connection(PORT* p) struct sockaddr_in clientname; size_t size = sizeof(clientname); + int oobinline = 1; + int new = accept(p->fd,(struct sockaddr *)&clientname,&size); if(new < 0) { @@ -108,6 +110,9 @@ CELL accept_connection(PORT* p) io_error(__FUNCTION__); } + if(setsockopt(new,SOL_SOCKET,SO_OOBINLINE,&oobinline,sizeof(int)) < 0) + io_error(__FUNCTION__); + p->client_host = tag_object(from_c_string(inet_ntoa( clientname.sin_addr))); p->client_port = tag_fixnum(ntohs(clientname.sin_port));