Skip to content

Commit

Permalink
enet 1.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jun 2, 2013
1 parent 5cfde11 commit e9eb3d7
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 127 deletions.
8 changes: 8 additions & 0 deletions src/enet/ChangeLog
@@ -1,3 +1,11 @@
ENet 1.3.8 (June 2, 2013):

* added enet_linked_version() for checking the linked version
* added enet_socket_get_address() for querying the local address of a socket
* silenced some debugging prints unless ENET_DEBUG is defined during compilation
* handle EINTR in enet_socket_wait() so that enet_host_service() doesn't propagate errors from signals
* optimized enet_host_bandwidth_throttle() to be less expensive for large numbers of peers

ENet 1.3.7 (March 6, 2013):

* added ENET_PACKET_FLAG_SENT to indicate that a packet is being freed because it has been sent
Expand Down
2 changes: 1 addition & 1 deletion src/enet/Makefile.am
Expand Up @@ -16,7 +16,7 @@ enetinclude_HEADERS = \
lib_LTLIBRARIES = libenet.la
libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c
# see info '(libtool) Updating version info' before making a release
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 4:0:2
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 5:0:3
INCLUDES = -I$(top_srcdir)/include

ACLOCAL_AMFLAGS = -Im4
6 changes: 6 additions & 0 deletions src/enet/callbacks.c
Expand Up @@ -27,6 +27,12 @@ enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits

return enet_initialize ();
}

ENetVersion
enet_linked_version (void)
{
return ENET_VERSION;
}

void *
enet_malloc (size_t size)
Expand Down
45 changes: 10 additions & 35 deletions src/enet/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libenet 1.3.7.
# Generated by GNU Autoconf 2.69 for libenet 1.3.8.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libenet'
PACKAGE_TARNAME='libenet'
PACKAGE_VERSION='1.3.7'
PACKAGE_STRING='libenet 1.3.7'
PACKAGE_VERSION='1.3.8'
PACKAGE_STRING='libenet 1.3.8'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

Expand Down Expand Up @@ -1306,7 +1306,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libenet 1.3.7 to adapt to many kinds of systems.
\`configure' configures libenet 1.3.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1376,7 +1376,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libenet 1.3.7:";;
short | recursive ) echo "Configuration of libenet 1.3.8:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1479,7 +1479,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libenet configure 1.3.7
libenet configure 1.3.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1868,7 +1868,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libenet $as_me 1.3.7, which was
It was created by libenet $as_me 1.3.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -2684,7 +2684,7 @@ fi

# Define the identity of the package.
PACKAGE='libenet'
VERSION='1.3.7'
VERSION='1.3.8'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -11369,31 +11369,6 @@ if test "x$ac_cv_type_socklen_t" = xyes; then :
fi


cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include </usr/include/sys/socket.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then :
$as_echo "#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN" >>confdefs.h

fi
rm -f conftest*

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <socket.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "MSG_MAXIOVLEN" >/dev/null 2>&1; then :
$as_echo "#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN" >>confdefs.h

fi
rm -f conftest*


ac_config_files="$ac_config_files Makefile libenet.pc"

cat >confcache <<\_ACEOF
Expand Down Expand Up @@ -11958,7 +11933,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libenet $as_me 1.3.7, which was
This file was extended by libenet $as_me 1.3.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -12015,7 +11990,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libenet config.status 1.3.7
libenet config.status 1.3.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
5 changes: 1 addition & 4 deletions src/enet/configure.ac
@@ -1,4 +1,4 @@
AC_INIT([libenet], [1.3.7])
AC_INIT([libenet], [1.3.8])
AC_CONFIG_SRCDIR([include/enet/enet.h])
AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE([enable])
Expand All @@ -22,9 +22,6 @@ AC_CHECK_TYPE(socklen_t, [AC_DEFINE(HAS_SOCKLEN_T)], ,
#include <sys/socket.h>
)

AC_EGREP_HEADER(MSG_MAXIOVLEN, /usr/include/sys/socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN]))
AC_EGREP_HEADER(MSG_MAXIOVLEN, socket.h, AC_DEFINE(ENET_BUFFER_MAXIMUM, [MSG_MAXIOVLEN]))

AC_CONFIG_FILES([Makefile
libenet.pc])
AC_OUTPUT
2 changes: 1 addition & 1 deletion src/enet/docs/mainpage.dox
Expand Up @@ -36,7 +36,7 @@ portable, and easily embeddable.
You can retrieve the source to ENet by downloading it in either .tar.gz form
or accessing the github distribution directly.

The most recent stable release (1.3.7) can be downloaded <a href="http://enet.bespin.org/download/enet-1.3.7.tar.gz">here</a>.
The most recent stable release (1.3.8) can be downloaded <a href="http://enet.bespin.org/download/enet-1.3.8.tar.gz">here</a>.
The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded <a href="http://enet.bespin.org/download/enet-1.2.5.tar.gz">here</a>

You can find the most recent ENet source at <a href="https://github.com/lsalzman/enet">the github repository</a>.
Expand Down
95 changes: 49 additions & 46 deletions src/enet/host.c
Expand Up @@ -66,7 +66,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE);

if (address != NULL)
if (address != NULL && enet_socket_get_address (host -> socket, & host -> address) < 0)
host -> address = * address;

if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
Expand Down Expand Up @@ -102,6 +102,9 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
host -> totalReceivedData = 0;
host -> totalReceivedPackets = 0;

host -> connectedPeers = 0;
host -> bandwidthLimitedPeers = 0;

host -> compressor.context = NULL;
host -> compressor.compress = NULL;
host -> compressor.decompress = NULL;
Expand Down Expand Up @@ -328,46 +331,44 @@ enet_host_bandwidth_throttle (ENetHost * host)
{
enet_uint32 timeCurrent = enet_time_get (),
elapsedTime = timeCurrent - host -> bandwidthThrottleEpoch,
peersTotal = 0,
dataTotal = 0,
peersRemaining,
bandwidth,
peersRemaining = (enet_uint32) host -> connectedPeers,
dataTotal = ~0,
bandwidth = ~0,
throttle = 0,
bandwidthLimit = 0;
int needsAdjustment;
int needsAdjustment = host -> bandwidthLimitedPeers > 0 ? 1 : 0;
ENetPeer * peer;
ENetProtocol command;

if (elapsedTime < ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL)
return;

for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
continue;

++ peersTotal;
dataTotal += peer -> outgoingDataTotal;
}
host -> bandwidthThrottleEpoch = timeCurrent;

if (peersTotal == 0)
if (peersRemaining == 0)
return;

peersRemaining = peersTotal;
needsAdjustment = 1;
if (host -> outgoingBandwidth != 0)
{
dataTotal = 0;
bandwidth = (host -> outgoingBandwidth * elapsedTime) / 1000;

if (host -> outgoingBandwidth == 0)
bandwidth = ~0;
else
bandwidth = (host -> outgoingBandwidth * elapsedTime) / 1000;
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
continue;

dataTotal += peer -> outgoingDataTotal;
}
}

while (peersRemaining > 0 && needsAdjustment != 0)
{
needsAdjustment = 0;

if (dataTotal < bandwidth)
if (dataTotal <= bandwidth)
throttle = ENET_PEER_PACKET_THROTTLE_SCALE;
else
throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal;
Expand Down Expand Up @@ -398,7 +399,9 @@ enet_host_bandwidth_throttle (ENetHost * host)

peer -> outgoingBandwidthThrottleEpoch = timeCurrent;


peer -> incomingDataTotal = 0;
peer -> outgoingDataTotal = 0;

needsAdjustment = 1;
-- peersRemaining;
bandwidth -= peerBandwidth;
Expand All @@ -407,25 +410,35 @@ enet_host_bandwidth_throttle (ENetHost * host)
}

if (peersRemaining > 0)
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) ||
peer -> outgoingBandwidthThrottleEpoch == timeCurrent)
continue;
if (dataTotal <= bandwidth)
throttle = ENET_PEER_PACKET_THROTTLE_SCALE;
else
throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal;

for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) ||
peer -> outgoingBandwidthThrottleEpoch == timeCurrent)
continue;

peer -> packetThrottleLimit = throttle;

peer -> packetThrottleLimit = throttle;
if (peer -> packetThrottle > peer -> packetThrottleLimit)
peer -> packetThrottle = peer -> packetThrottleLimit;

if (peer -> packetThrottle > peer -> packetThrottleLimit)
peer -> packetThrottle = peer -> packetThrottleLimit;
peer -> incomingDataTotal = 0;
peer -> outgoingDataTotal = 0;
}
}

if (host -> recalculateBandwidthLimits)
{
host -> recalculateBandwidthLimits = 0;

peersRemaining = peersTotal;
peersRemaining = (enet_uint32) host -> connectedPeers;
bandwidth = host -> incomingBandwidth;
needsAdjustment = 1;

Expand Down Expand Up @@ -476,16 +489,6 @@ enet_host_bandwidth_throttle (ENetHost * host)
enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);
}
}

host -> bandwidthThrottleEpoch = timeCurrent;

for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
peer -> incomingDataTotal = 0;
peer -> outgoingDataTotal = 0;
}
}

/** @} */

0 comments on commit e9eb3d7

Please sign in to comment.