Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use travis-ci build matrix to test different compilers #901

Merged
merged 6 commits into from
Dec 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
language: d

#compiler:
# - dmd

install:
# dmd
# dub
- DMD_VER=2.066.0
- DMD=dmd_${DMD_VER}-0_amd64.deb
- DUB_VER=0.9.22
- DUB=dub-${DUB_VER}-linux-x86_64
- wget http://downloads.dlang.org/releases/2014/${DMD}
- sudo dpkg -i ${DMD} || true
- sudo apt-get -y update || true
- sudo apt-get -fy install || true
- sudo dpkg -i ${DMD}
- wget http://code.dlang.org/files/${DUB}.tar.gz
- sudo tar -C /usr/local/bin -zxf ${DUB}.tar.gz
d:
- dmd-2.065.0
- dmd-2.066.1
- ldc-0.14.0
- ldc-0.15.1
- gdc-4.9.0

script:
- dub test
- for ex in `\ls -1 examples/`; do (echo "[INFO] Building example $ex"; cd examples/$ex && dub build) || exit 1; done
- for ex in `\ls -1 tests/`; do (echo "[INFO] Running test $ex"; cd tests/$ex && dub) || exit 1; done
- dub test --compiler=$DC
- for ex in `\ls -1 examples/`; do (echo "[INFO] Building example $ex"; cd examples/$ex && dub build --compiler=$DC) || exit 1; done
- for ex in `\ls -1 tests/`; do (echo "[INFO] Running test $ex"; cd tests/$ex && dub --compiler=$DC) || exit 1; done

services:
- mongodb
- redis-server

sudo: false
137 changes: 69 additions & 68 deletions source/vibe/core/drivers/libevent2_tcp.d
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,75 @@ package nothrow extern(C)
version (VibeDebugCatchAll) alias UncaughtException = Throwable;
else alias UncaughtException = Exception;

// should be a nested static struct in onConnect, but that triggers an ICE in ldc2-0.14.0
private extern(D) struct ClientTask {
TCPContext* listen_ctx;
NetworkAddress bind_addr;
NetworkAddress remote_addr;
int sockfd;
TCPListenOptions options;

void execute()
{
assert(sockfd > 0);
if( evutil_make_socket_nonblocking(sockfd) ){
logError("Error setting non-blocking I/O on an incoming connection.");
}

auto eventloop = getThreadLibeventEventLoop();
auto drivercore = getThreadLibeventDriverCore();

// Initialize a buffered I/O event
auto buf_event = bufferevent_socket_new(eventloop, sockfd, bufferevent_options.BEV_OPT_CLOSE_ON_FREE);
if( !buf_event ){
logError("Error initializing buffered I/O event for fd %d.", sockfd);
return;
}

auto client_ctx = TCPContextAlloc.alloc(drivercore, eventloop, sockfd, buf_event, bind_addr, remote_addr);
assert(client_ctx.event !is null, "event is null although it was just != null?");
bufferevent_setcb(buf_event, &onSocketRead, &onSocketWrite, &onSocketEvent, client_ctx);
if( bufferevent_enable(buf_event, EV_READ|EV_WRITE) ){
bufferevent_free(buf_event);
TCPContextAlloc.free(client_ctx);
logError("Error enabling buffered I/O event for fd %d.", sockfd);
return;
}

assert(client_ctx.event !is null, "Client task called without event!?");
if (options & TCPListenOptions.disableAutoClose) {
auto conn = new Libevent2TCPConnection(client_ctx);
assert(conn.connected, "Connection closed directly after accept?!");
logDebug("start task (fd %d).", client_ctx.socketfd);
try {
listen_ctx.connectionCallback(conn);
logDebug("task out (fd %d).", client_ctx.socketfd);
} catch (Exception e) {
logWarn("Handling of connection failed: %s", e.msg);
logDiagnostic("%s", e.toString().sanitize);
} finally {
logDebug("task finished.");
FreeListObjectAlloc!ClientTask.free(&this);
}
} else {
auto conn = FreeListRef!Libevent2TCPConnection(client_ctx);
assert(conn.connected, "Connection closed directly after accept?!");
logDebug("start task (fd %d).", client_ctx.socketfd);
try {
listen_ctx.connectionCallback(conn);
logDebug("task out (fd %d).", client_ctx.socketfd);
} catch (Exception e) {
logWarn("Handling of connection failed: %s", e.msg);
logDiagnostic("%s", e.toString().sanitize);
} finally {
logDebug("task finished.");
FreeListObjectAlloc!ClientTask.free(&this);
conn.close();
}
}
}
}

void onConnect(evutil_socket_t listenfd, short evtype, void *arg)
{
logTrace("connect callback");
Expand All @@ -465,74 +534,6 @@ package nothrow extern(C)
return;
}

static struct ClientTask {
TCPContext* listen_ctx;
NetworkAddress bind_addr;
NetworkAddress remote_addr;
int sockfd;
TCPListenOptions options;

void execute()
{
assert(sockfd > 0);
if( evutil_make_socket_nonblocking(sockfd) ){
logError("Error setting non-blocking I/O on an incoming connection.");
}

auto eventloop = getThreadLibeventEventLoop();
auto drivercore = getThreadLibeventDriverCore();

// Initialize a buffered I/O event
auto buf_event = bufferevent_socket_new(eventloop, sockfd, bufferevent_options.BEV_OPT_CLOSE_ON_FREE);
if( !buf_event ){
logError("Error initializing buffered I/O event for fd %d.", sockfd);
return;
}

auto client_ctx = TCPContextAlloc.alloc(drivercore, eventloop, sockfd, buf_event, bind_addr, remote_addr);
assert(client_ctx.event !is null, "event is null although it was just != null?");
bufferevent_setcb(buf_event, &onSocketRead, &onSocketWrite, &onSocketEvent, client_ctx);
if( bufferevent_enable(buf_event, EV_READ|EV_WRITE) ){
bufferevent_free(buf_event);
TCPContextAlloc.free(client_ctx);
logError("Error enabling buffered I/O event for fd %d.", sockfd);
return;
}

assert(client_ctx.event !is null, "Client task called without event!?");
if (options & TCPListenOptions.disableAutoClose) {
auto conn = new Libevent2TCPConnection(client_ctx);
assert(conn.connected, "Connection closed directly after accept?!");
logDebug("start task (fd %d).", client_ctx.socketfd);
try {
listen_ctx.connectionCallback(conn);
logDebug("task out (fd %d).", client_ctx.socketfd);
} catch (Exception e) {
logWarn("Handling of connection failed: %s", e.msg);
logDiagnostic("%s", e.toString().sanitize);
} finally {
logDebug("task finished.");
FreeListObjectAlloc!ClientTask.free(&this);
}
} else {
auto conn = FreeListRef!Libevent2TCPConnection(client_ctx);
assert(conn.connected, "Connection closed directly after accept?!");
logDebug("start task (fd %d).", client_ctx.socketfd);
try {
listen_ctx.connectionCallback(conn);
logDebug("task out (fd %d).", client_ctx.socketfd);
} catch (Exception e) {
logWarn("Handling of connection failed: %s", e.msg);
logDiagnostic("%s", e.toString().sanitize);
} finally {
logDebug("task finished.");
FreeListObjectAlloc!ClientTask.free(&this);
conn.close();
}
}
}
}

try {
// Accept and configure incoming connections (up to 10 connections in one go)
foreach( i; 0 .. 10 ){
Expand Down
2 changes: 1 addition & 1 deletion source/vibe/db/mongo/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final class MongoClient {
writeln("Current databases are: ", names);
---
*/
auto getDatabases()
auto getDatabases()()
{
return lockConnection.listDatabases()
.map!(info => MongoDatabase(this, info.name));
Expand Down
2 changes: 1 addition & 1 deletion source/vibe/internal/meta/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ template isRWField(T, string M)
import std.typetuple;

static void testAssign()() {
static T t = void;
T t = void;
__traits(getMember, t, M) = __traits(getMember, t, M);
}

Expand Down