diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2016-06-23 15:46:44 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2016-06-23 15:46:44 -0400 |
commit | 8dcbd61a45851f5492425acc1b19e4fd7081424b (patch) | |
tree | 3aa3930248bb9da217a3090687637d44fc4ea440 | |
parent | 72b133f5952f61eb8c695107cbb053d8a522494e (diff) | |
download | lighttpd-git-8dcbd61a45851f5492425acc1b19e4fd7081424b.tar.gz |
[cygwin] fix mod_proxy and mod_fastcgi ioctl use
cygwin does not support ioctl on sockets, returning EOPTNOTSUPP
(would be better if cygwin used Windows ioctlsocket() instead)
Windows uses signed (socklen_t), so add some casts to quiet warnings
Windows path handling is convoluted, so disable one tests in mod_fastcgi
since trailing spaces are removed from URL for _WIN32 and __CYGWIN__ in
response.c
-rw-r--r-- | src/http-header-glue.c | 2 | ||||
-rw-r--r-- | src/mod_fastcgi.c | 11 | ||||
-rw-r--r-- | src/mod_proxy.c | 8 | ||||
-rw-r--r-- | src/mod_scgi.c | 2 | ||||
-rwxr-xr-x | tests/mod-fastcgi.t | 4 |
5 files changed, 22 insertions, 5 deletions
diff --git a/src/http-header-glue.c b/src/http-header-glue.c index c98c5888..441fdb5b 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -143,7 +143,7 @@ int http_response_redirect_to_directory(server *srv, connection *con) { our_addr_len = sizeof(our_addr); if (-1 == getsockname(con->fd, (struct sockaddr *)&our_addr, &our_addr_len) - || our_addr_len > sizeof(our_addr)) { + || our_addr_len > (socklen_t)sizeof(our_addr)) { con->http_status = 500; log_error_write(srv, __FILE__, __LINE__, "ss", diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 62cc367e..d55679f6 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -2009,7 +2009,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, int request_id) { our_addr_len = sizeof(our_addr); if (-1 == getsockname(con->fd, (struct sockaddr *)&our_addr, &our_addr_len) - || our_addr_len > sizeof(our_addr)) { + || our_addr_len > (socklen_t)sizeof(our_addr)) { s = inet_ntop_cache_get_ip(srv, &(srv_sock->addr)); } else { s = inet_ntop_cache_get_ip(srv, &(our_addr)); @@ -2496,7 +2496,7 @@ static int fastcgi_get_packet(server *srv, handler_ctx *hctx, fastcgi_response_p static int fcgi_demux_response(server *srv, handler_ctx *hctx) { int fin = 0; int toread, ret; - ssize_t r; + ssize_t r = 0; plugin_data *p = hctx->plugin_data; connection *con = hctx->remote_conn; @@ -2507,6 +2507,7 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { /* * check how much we have to read */ + #if !defined(_WIN32) && !defined(__CYGWIN__) if (ioctl(hctx->fd, FIONREAD, &toread)) { if (errno == EAGAIN) { fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); @@ -2517,6 +2518,9 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { fcgi_fd); return -1; } + #else + toread = 4096; + #endif if (toread > 0) { char *mem; @@ -2547,7 +2551,8 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { fcgi_fd, strerror(errno)); return -1; } - } else { + } + if (0 == r) { log_error_write(srv, __FILE__, __LINE__, "ssdsb", "unexpected end-of-file (perhaps the fastcgi process died):", "pid:", proc->pid, diff --git a/src/mod_proxy.c b/src/mod_proxy.c index 97fa1fc8..3b877857 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -628,6 +628,7 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { int proxy_fd = hctx->fd; /* check how much we have to read */ + #if !defined(_WIN32) && !defined(__CYGWIN__) if (ioctl(hctx->fd, FIONREAD, &b)) { if (errno == EAGAIN) { fdevent_event_add(srv->ev, &(hctx->fde_ndx), hctx->fd, FDEVENT_IN); @@ -638,6 +639,9 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { proxy_fd); return -1; } + #else + b = 4096; + #endif if (p->conf.debug) { @@ -675,6 +679,10 @@ static int proxy_demux_response(server *srv, handler_ctx *hctx) { return -1; } + #if defined(_WIN32) || defined(__CYGWIN__) + if (0 == r) return 1; /* fin */ + #endif + /* this should be catched by the b > 0 above */ force_assert(r); diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 39d4e662..54163c78 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -1618,7 +1618,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) { our_addr_len = sizeof(our_addr); if (-1 == getsockname(con->fd, (struct sockaddr *)&our_addr, &our_addr_len) - || our_addr_len > sizeof(our_addr)) { + || our_addr_len > (socklen_t)sizeof(our_addr)) { s = inet_ntop_cache_get_ip(srv, &(srv_sock->addr)); } else { s = inet_ntop_cache_get_ip(srv, &(our_addr)); diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index b3680d0d..4efce3fe 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -129,12 +129,16 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; ok($tf->handle_http($t) == 0, 'PATHINFO'); + if ($^O ne "cygwin") { $t->{REQUEST} = ( <<EOF GET /cgi.php%20%20%20 HTTP/1.0 EOF ); $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ]; ok($tf->handle_http($t) == 0, 'No source retrieval'); + } else { + ok(1, 'No source retrieval; skipped on cygwin; see response.c'); + } $t->{REQUEST} = ( <<EOF GET /www/abc/def HTTP/1.0 |