]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Merge pull request #1337 from SaberUK/master+merge
authorPeter Powell <petpow@saberuk.com>
Wed, 12 Jul 2017 13:25:28 +0000 (14:25 +0100)
committerGitHub <noreply@github.com>
Wed, 12 Jul 2017 13:25:28 +0000 (14:25 +0100)
Merge v2.0.23 and v2.0.24 into master.

.github/ISSUE_TEMPLATE.md [new file with mode: 0644]
docs/Doxyfile
include/socketengine.h
make/configure.pm
make/directive.pm
modulemanager
src/socketengine.cpp
src/socketengines/socketengine_epoll.cpp
src/socketengines/socketengine_kqueue.cpp
src/socketengines/socketengine_ports.cpp
src/socketengines/socketengine_select.cpp

diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644 (file)
index 0000000..6fdf33b
--- /dev/null
@@ -0,0 +1,40 @@
+<!-- 
+---------------------------------------------------
+GENERAL SUPPORT INFORMATION
+---------------------------------------------------
+
+The GitHub issue tracker is for bug reports and feature requests.
+General support can be found at the following locations:
+
+IRC:
+irc.inspircd.org #inspircd
+
+Example configs:
+2.0         - https://github.com/inspircd/inspircd/tree/insp20/docs/conf
+3.0 (alpha) - https://github.com/inspircd/inspircd/tree/master/docs/conf
+
+Wiki:
+https://wiki.inspircd.org/
+-->
+
+**Description**
+
+<!--
+Briefly describe the problem you are having in a few paragraphs.
+-->
+
+**Steps to reproduce the issue:**
+1.
+2.
+3.
+
+**Describe the results you received:**
+
+
+**Describe the results you expected:**
+
+
+**Additional information you deem important (e.g. issue happens only occasionally):**
+
+**Output of `./bin/inspircd --version`:**
+
index 807020af51104b127c467f4c9a6de06447fe209c..f4e526bc775905893ee413c258bc3f34f9b087d1 100644 (file)
@@ -1,6 +1,6 @@
 DOXYFILE_ENCODING      = UTF-8
 PROJECT_NAME           = InspIRCd
-PROJECT_NUMBER         = 2.0
+PROJECT_NUMBER         = 3.0
 PROJECT_BRIEF          =
 PROJECT_LOGO           =
 OUTPUT_DIRECTORY       = docs/doxygen
index c0026bfc6f2513335b0af7ba3853a12d017cff6b..b006439520eb514a26ac833d0108ff72ed2c9d0f 100644 (file)
@@ -244,11 +244,19 @@ class CoreExport SocketEngine
                 */
                Statistics() : lastempty(0), TotalEvents(0), ReadEvents(0), WriteEvents(0), ErrorEvents(0) { }
 
-               /** Increase the counters for bytes sent/received in this second.
-                * @param len_in Bytes received, 0 if updating number of bytes written.
-                * @param len_out Bytes sent, 0 if updating number of bytes read.
+               /** Update counters for network data received.
+                * This should be called after every read-type syscall.
+                * @param len_in Number of bytes received, or -1 for error, as typically
+                * returned by a read-style syscall.
                 */
-               void Update(size_t len_in, size_t len_out);
+               void UpdateReadCounters(int len_in);
+
+               /** Update counters for network data sent.
+                * This should be called after every write-type syscall.
+                * @param len_out Number of bytes sent, or -1 for error, as typically
+                * returned by a read-style syscall.
+                */
+               void UpdateWriteCounters(int len_out);
 
                /** Get data transfer statistics.
                 * @param kbitspersec_in Filled with incoming traffic in this second in kbit/s.
index 48bd8db3842a445d352f79a7236f240261a11c74..dbbbf650978ec6af386201428b34594c221adafd 100644 (file)
@@ -208,9 +208,9 @@ sub test_file($$;$) {
 sub test_header($$;$) {
        my ($compiler, $header, $args) = @_;
        $args //= '';
-       open(COMPILER, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0;
-       print COMPILER "#include <$header>";
-       close(COMPILER);
+       open(my $fh, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0;
+       print $fh "#include <$header>";
+       close $fh;
        return !$?;
 }
 
@@ -257,11 +257,11 @@ sub parse_templates($$$) {
        # Iterate through files in make/template.
        foreach (<make/template/*>) {
                print_format "Parsing <|GREEN $_|> ...\n";
-               open(TEMPLATE, $_) or print_error "unable to read $_: $!";
+               open(my $fh, $_) or print_error "unable to read $_: $!";
                my (@lines, $mode, @platforms, %targets);
 
                # First pass: parse template variables and directives.
-               while (my $line = <TEMPLATE>) {
+               while (my $line = <$fh>) {
                        chomp $line;
 
                        # Does this line match a variable?
@@ -301,7 +301,7 @@ sub parse_templates($$$) {
                        }
                        push @lines, $line;
                }
-               close(TEMPLATE);
+               close $fh;
 
                # Only proceed if this file should be templated on this platform.
                if ($#platforms < 0 || grep { $_ eq $^O } @platforms) {
@@ -397,11 +397,11 @@ sub parse_templates($$$) {
 
                                # Write the template file.
                                print_format "Writing <|GREEN $target|> ...\n";
-                               open(TARGET, '>', $target) or print_error "unable to write $target: $!";
+                               open(my $fh, '>', $target) or print_error "unable to write $target: $!";
                                foreach (@final_lines) {
-                                       say TARGET $_;
+                                       say $fh $_;
                                }
-                               close(TARGET);
+                               close $fh;
 
                                # Set file permissions.
                                if (defined $mode) {
index 4501fc5ec40b71ea445ce5ea64e0fd8c3e6c7a91..2e9e7ed6182fb3c2fdd55b7060b317c47964b4c5 100644 (file)
@@ -41,16 +41,16 @@ our @EXPORT = qw(get_directive
 sub get_directive($$;$)
 {
        my ($file, $property, $default) = @_;
-       open(MODULE, $file) or return $default;
+       open(my $fh, $file) or return $default;
 
        my $value = '';
-       while (<MODULE>) {
+       while (<$fh>) {
                if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
                        next unless $1 eq $property;
                        $value .= ' ' . execute_functions($file, $1, $2);
                }
        }
-       close(MODULE);
+       close $fh;
 
        # Strip all extraneous whitespace.
        $value =~ s/^\s+|\s+$//g;
index d44ccbeb95df357049570dc61eaf665863af372a..7471dcc77cab66c188b9e5dcad7ae9c2dafc9fd4 100755 (executable)
@@ -254,7 +254,7 @@ sub resolve_deps {
 }
 
 command 'install', 'Install a third-party module', sub {
-       for my $mod (@ARGV) {
+       for my $mod (@_) {
                my $vers = $mod =~ s/=([-0-9.]+)// ? $1 : undef;
                $mod = lc $mod;
                unless ($modules{$mod}) {
@@ -296,6 +296,7 @@ command 'list', 'List available third-party modules', sub {
                my $vers = join ' ', map { $_ eq $instver ? "\e[1m$_\e[m" : $_ } @vers;
                print "$mod ($vers) - $desc\n";
        }
+       exit 0;
 };
 
 execute_command @ARGV;
index 4183488b723ac0f063c5af9aa71b76a9d9caf688..3735e7530aa899c65567953bce30f109aa39765c 100644 (file)
@@ -203,40 +203,35 @@ void SocketEngine::SetReuse(int fd)
 int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)
 {
        int nbRecvd = recvfrom(fd->GetFd(), (char*)buf, len, flags, from, fromlen);
-       if (nbRecvd > 0)
-               stats.Update(nbRecvd, 0);
+       stats.UpdateReadCounters(nbRecvd);
        return nbRecvd;
 }
 
 int SocketEngine::Send(EventHandler* fd, const void *buf, size_t len, int flags)
 {
        int nbSent = send(fd->GetFd(), (const char*)buf, len, flags);
-       if (nbSent > 0)
-               stats.Update(0, nbSent);
+       stats.UpdateWriteCounters(nbSent);
        return nbSent;
 }
 
 int SocketEngine::Recv(EventHandler* fd, void *buf, size_t len, int flags)
 {
        int nbRecvd = recv(fd->GetFd(), (char*)buf, len, flags);
-       if (nbRecvd > 0)
-               stats.Update(nbRecvd, 0);
+       stats.UpdateReadCounters(nbRecvd);
        return nbRecvd;
 }
 
 int SocketEngine::SendTo(EventHandler* fd, const void *buf, size_t len, int flags, const sockaddr *to, socklen_t tolen)
 {
        int nbSent = sendto(fd->GetFd(), (const char*)buf, len, flags, to, tolen);
-       if (nbSent > 0)
-               stats.Update(0, nbSent);
+       stats.UpdateWriteCounters(nbSent);
        return nbSent;
 }
 
 int SocketEngine::WriteV(EventHandler* fd, const IOVector* iovec, int count)
 {
        int sent = writev(fd->GetFd(), iovec, count);
-       if (sent > 0)
-               stats.Update(0, sent);
+       stats.UpdateWriteCounters(sent);
        return sent;
 }
 
@@ -289,11 +284,26 @@ int SocketEngine::Shutdown(int fd, int how)
        return shutdown(fd, how);
 }
 
-void SocketEngine::Statistics::Update(size_t len_in, size_t len_out)
+void SocketEngine::Statistics::UpdateReadCounters(int len_in)
 {
        CheckFlush();
-       indata += len_in;
-       outdata += len_out;
+
+       ReadEvents++;
+       if (len_in > 0)
+               indata += len_in;
+       else if (len_in < 0)
+               ErrorEvents++;
+}
+
+void SocketEngine::Statistics::UpdateWriteCounters(int len_out)
+{
+       CheckFlush();
+
+       WriteEvents++;
+       if (len_out > 0)
+               outdata += len_out;
+       else if (len_out < 0)
+               ErrorEvents++;
 }
 
 void SocketEngine::Statistics::CheckFlush() const
index f0a7c20167dde69c955eddfc40960d2ddeb6d5e3..c442e340dcd46abd7d8b6fa93c0f22d0daacfd93 100644 (file)
@@ -217,7 +217,6 @@ int SocketEngine::DispatchEvents()
                eh->SetEventMask(mask);
                if (ev.events & EPOLLIN)
                {
-                       stats.ReadEvents++;
                        eh->OnEventHandlerRead();
                        if (eh != GetRef(fd))
                                // whoa! we got deleted, better not give out the write event
@@ -225,7 +224,6 @@ int SocketEngine::DispatchEvents()
                }
                if (ev.events & EPOLLOUT)
                {
-                       stats.WriteEvents++;
                        eh->OnEventHandlerWrite();
                }
        }
index 922cb7f2d99d6df40afdf9ec3b76e0a19019764f..9db9023142c034dba9e30298a1714c1ecfaafb2e 100644 (file)
@@ -199,7 +199,6 @@ int SocketEngine::DispatchEvents()
                }
                if (filter == EVFILT_WRITE)
                {
-                       stats.WriteEvents++;
                        /* When mask is FD_WANT_FAST_WRITE or FD_WANT_SINGLE_WRITE,
                         * we set a one-shot write, so we need to clear that bit
                         * to detect when it set again.
@@ -210,7 +209,6 @@ int SocketEngine::DispatchEvents()
                }
                else if (filter == EVFILT_READ)
                {
-                       stats.ReadEvents++;
                        eh->SetEventMask(eh->GetEventMask() & ~FD_READ_WILL_BLOCK);
                        eh->OnEventHandlerRead();
                }
index d94d02664f1b5597d0c2b4b89c9e0f47643054b0..68fa70e3b922a9a1093f3cc2225db03cd2a37fee 100644 (file)
@@ -159,14 +159,12 @@ int SocketEngine::DispatchEvents()
                port_associate(EngineHandle, PORT_SOURCE_FD, fd, mask_to_events(mask), eh);
                if (portev_events & POLLRDNORM)
                {
-                       stats.ReadEvents++;
                        eh->OnEventHandlerRead();
                        if (eh != GetRef(fd))
                                continue;
                }
                if (portev_events & POLLWRNORM)
                {
-                       stats.WriteEvents++;
                        eh->OnEventHandlerWrite();
                }
        }
index 6dfbae88e0e452d8f6a1edc7095e99ebd91366b8..42f634db18c35aa9c9db22f27b76261c6496b6e8 100644 (file)
@@ -147,7 +147,6 @@ int SocketEngine::DispatchEvents()
 
                if (has_read)
                {
-                       stats.ReadEvents++;
                        ev->SetEventMask(ev->GetEventMask() & ~FD_READ_WILL_BLOCK);
                        ev->OnEventHandlerRead();
                        if (ev != GetRef(i))
@@ -156,7 +155,6 @@ int SocketEngine::DispatchEvents()
 
                if (has_write)
                {
-                       stats.WriteEvents++;
                        int newmask = (ev->GetEventMask() & ~(FD_WRITE_WILL_BLOCK | FD_WANT_SINGLE_WRITE));
                        SocketEngine::OnSetEvent(ev, ev->GetEventMask(), newmask);
                        ev->SetEventMask(newmask);