Browse Source

[core] better DragonFlyBSD support (fixes #2746)

(thx xenu)

x-ref:
  "[PATCH] better DragonFlyBSD support; fix crash"
  https://redmine.lighttpd.net/issues/2746
personal/stbuehler/mod-csrf-old
Glenn Strauss 5 years ago
parent
commit
6ec66c4dce
  1. 2
      src/base.h
  2. 4
      src/configfile.c
  3. 8
      src/fdevent.c
  4. 2
      src/network.c
  5. 2
      tests/LightyTest.pm

2
src/base.h

@ -329,7 +329,7 @@ typedef struct {
off_t *global_bytes_per_second_cnt_ptr; /* */
#if defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__OpenBSD__) || defined(__DragonflyBSD__)
|| defined(__OpenBSD__) || defined(__DragonFly__)
buffer *bsd_accept_filter;
#endif

4
src/configfile.c

@ -184,7 +184,7 @@ static int config_insert(server *srv) {
s->ssl_ec_curve = buffer_init();
s->errorfile_prefix = buffer_init();
#if defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__OpenBSD__) || defined(__DragonflyBSD__)
|| defined(__OpenBSD__) || defined(__DragonFly__)
s->bsd_accept_filter = (i == 0)
? buffer_init()
: buffer_init_buffer(srv->config_storage[0]->bsd_accept_filter);
@ -285,7 +285,7 @@ static int config_insert(server *srv) {
cv[70].destination = &(s->listen_backlog);
cv[71].destination = s->error_handler_404;
#if defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__OpenBSD__) || defined(__DragonflyBSD__)
|| defined(__OpenBSD__) || defined(__DragonFly__)
cv[75].destination = s->bsd_accept_filter;
#endif
cv[76].destination = &(s->stream_request_body);

8
src/fdevent.c

@ -254,7 +254,7 @@ int fdevent_event_next_fdndx(fdevents *ev, int ndx) {
#include <netinet/tcp.h>
#if (defined(__APPLE__) && defined(__MACH__)) \
|| defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__OpenBSD__) || defined(__DragonflyBSD__)
|| defined(__OpenBSD__) || defined(__DragonFly__)
#include <netinet/tcp_fsm.h>
#endif
@ -265,12 +265,14 @@ int fdevent_is_tcp_half_closed(int fd) {
socklen_t tlen = sizeof(tcpi);
return (0 == getsockopt(fd, IPPROTO_TCP, TCP_CONNECTION_INFO, &tcpi, &tlen)
&& tcpi.tcpi_state == TCPS_CLOSE_WAIT);
#elif defined(TCPS_CLOSE_WAIT) /* FreeBSD, NetBSD (not present in OpenBSD) */
#elif defined(TCP_INFO) && defined(TCPS_CLOSE_WAIT)
/* FreeBSD, NetBSD (not present in OpenBSD or DragonFlyBSD) */
struct tcp_info tcpi;
socklen_t tlen = sizeof(tcpi);
return (0 == getsockopt(fd, IPPROTO_TCP, TCP_INFO, &tcpi, &tlen)
&& tcpi.tcpi_state == TCPS_CLOSE_WAIT);
#elif defined(TCP_INFO) /* Linux */
#elif defined(TCP_INFO) && defined(__linux__)
/* Linux (TCP_CLOSE_WAIT is enum, so can not #ifdef TCP_CLOSE_WAIT) */
struct tcp_info tcpi;
socklen_t tlen = sizeof(tcpi);/*SOL_TCP == IPPROTO_TCP*/
return (0 == getsockopt(fd, SOL_TCP, TCP_INFO, &tcpi, &tlen)

2
src/network.c

@ -495,7 +495,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
}
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__) \
|| defined(__OpenBSD__) || defined(__DragonflyBSD__)
|| defined(__OpenBSD__) || defined(__DragonFly__)
} else if (!buffer_is_empty(s->bsd_accept_filter)
&& (buffer_is_equal_string(s->bsd_accept_filter, CONST_STR_LEN("httpready"))
|| buffer_is_equal_string(s->bsd_accept_filter, CONST_STR_LEN("dataready")))) {

2
tests/LightyTest.pm

@ -223,7 +223,7 @@ sub handle_http {
print $remote $_.$BLANK;
diag("\n<< ".$_) if $is_debug;
}
shutdown($remote, 1) if ($^O ne "openbsd"); # I've stopped writing data
shutdown($remote, 1) if ($^O ne "openbsd" && $^O ne "dragonfly"); # I've stopped writing data
} else {
diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug;
foreach(@request) {

Loading…
Cancel
Save