Skip to content

Commit

Permalink
Get things compiling again.
Browse files Browse the repository at this point in the history
headius committed Jan 12, 2016
1 parent 7453422 commit e98da35
Showing 6 changed files with 22 additions and 22 deletions.
13 changes: 1 addition & 12 deletions core/src/main/java/org/jruby/ext/socket/Addrinfo.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
import org.jruby.RubyObject;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
@@ -69,28 +68,24 @@ public Addrinfo(Ruby runtime, RubyClass cls, NetworkInterface networkInterface,
this.interfaceLink = true;
this.isBroadcast = isBroadcast;
this.interfaceName = networkInterface.getName();
this.socketType = SocketType.SOCKET;
}

public Addrinfo(Ruby runtime, RubyClass cls, InetAddress inetAddress) {
super(runtime, cls);
this.socketAddress = new InetSocketAddress(inetAddress, 0);
this.socketType = SocketType.SOCKET;
}

public Addrinfo(Ruby runtime, RubyClass cls, InetAddress inetAddress, int port, Sock sock) {
super(runtime, cls);
this.socketAddress = new InetSocketAddress(inetAddress, port);
this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue());
this.socketType = SocketType.SOCKET;
setSockAndProtocol(sock);
}

public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress, Sock sock, SocketType socketType) {
public Addrinfo(Ruby runtime, RubyClass cls, SocketAddress socketAddress, Sock sock) {
super(runtime, cls);
this.socketAddress = socketAddress;
this.pfamily = ProtocolFamily.valueOf(getAddressFamily().intValue());
this.socketType = socketType;
setSockAndProtocol(sock);
}

@@ -182,7 +177,6 @@ private void initializeCommon(ThreadContext context, IRubyObject sockaddr, IRuby
case AF_UNIX: /* ["AF_UNIX", "/tmp/sock"] */
IRubyObject path = sockaddAry.eltOk(1).convertToString();
socketAddress = new UnixSocketAddress(new File(path.toString()));
this.socketType = SocketType.UNIX;
this.sock = Sock.SOCK_STREAM;

return;
@@ -252,8 +246,6 @@ private void initializeCommon(ThreadContext context, IRubyObject sockaddr, IRuby

this.pfamily = family == null || family.isNil() ? PF_UNSPEC : SocketUtils.protocolFamilyFromArg(family);

this.socketType = SocketType.SOCKET;

this.sock = sock == null || sock.isNil() ? Sock.SOCK_STREAM : SocketUtils.sockFromArg(sock);

this.protocol = protocol == null || protocol.isNil() ? protocolFromAddress() : SocketUtils.protocolFromArg(protocol);
@@ -523,7 +515,6 @@ public static IRubyObject unix(ThreadContext context, IRubyObject recv, IRubyObj

addrinfo.socketAddress = new UnixSocketAddress(new File(path.convertToString().toString()));
addrinfo.sock = Sock.SOCK_STREAM;
addrinfo.socketType = SocketType.UNIX;
addrinfo.pfamily = PF_UNIX;

return addrinfo;
@@ -535,7 +526,6 @@ public static IRubyObject unix(ThreadContext context, IRubyObject recv, IRubyObj

addrinfo.socketAddress = new UnixSocketAddress(new File(path.convertToString().toString()));
addrinfo.sock = SocketUtils.sockFromArg(type);
addrinfo.socketType = SocketType.UNIX;
addrinfo.pfamily = PF_UNIX;

return addrinfo;
@@ -930,7 +920,6 @@ AddressFamily getAddressFamily() {
private SocketAddress socketAddress;
private ProtocolFamily pfamily = PF_UNSPEC;
private Sock sock;
private SocketType socketType;
private String interfaceName;
private boolean interfaceLink;
private NetworkInterface networkInterface;
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Original file line number Diff line number Diff line change
@@ -359,7 +359,7 @@ public IRubyObject local_address(ThreadContext context) {

if (address != null) {
SocketType socketType = SocketType.forChannel(getChannel());
return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType);
return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType());
}

UnixSocketAddress unix = getUnixSocketAddress();
@@ -375,7 +375,7 @@ public IRubyObject remote_address(ThreadContext context) {

if (address != null) {
SocketType socketType = SocketType.forChannel(getChannel());
return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType);
return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType());
}

UnixSocketAddress unix = getUnixRemoteSocket();
@@ -741,7 +741,7 @@ protected static SocketLevel levelFromArg(IRubyObject _level) {
return level;
}

protected abstract IRubyObject addrFor(ThreadContext context, InetSocketAddress addr, boolean reverse);
protected abstract IRubyObject addrFor(ThreadContext context, SocketAddress addr, boolean reverse);

@Deprecated
public IRubyObject recv(IRubyObject[] args) {
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/ext/socket/RubyIPSocket.java
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@

import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

/**
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
@@ -197,8 +198,12 @@ public static Boolean doReverseLookup(ThreadContext context, IRubyObject norever
}
}

protected IRubyObject addrFor(ThreadContext context, InetSocketAddress addr, boolean reverse) {
protected IRubyObject addrFor(ThreadContext context, SocketAddress _addr, boolean reverse) {
final Ruby runtime = context.runtime;
if (!(_addr instanceof InetSocketAddress)) {
throw context.runtime.newTypeError("invalid SocketAddress type passed to RubyIPSocket.addrFor");
}
InetSocketAddress addr = (InetSocketAddress) _addr;
IRubyObject[] ret = new IRubyObject[4];
if (addr.getAddress() instanceof Inet6Address) {
ret[0] = runtime.newString("AF_INET6");
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ext/socket/RubySocket.java
Original file line number Diff line number Diff line change
@@ -798,10 +798,10 @@ private SocketAddress addressForChannel(ThreadContext context, IRubyObject arg)
}

@Override
protected IRubyObject addrFor(ThreadContext context, InetSocketAddress addr, boolean reverse) {
protected IRubyObject addrFor(ThreadContext context, SocketAddress addr, boolean reverse) {
final Ruby runtime = context.runtime;

return new Addrinfo(runtime, runtime.getClass("Addrinfo"), addr.getAddress(), addr.getPort(), Sock.SOCK_DGRAM);
return new Addrinfo(runtime, runtime.getClass("Addrinfo"), addr, soType);
}

@JRubyMethod
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ext/socket/RubyUNIXSocket.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@

import jnr.constants.platform.Fcntl;
import jnr.constants.platform.OpenFlags;
import jnr.constants.platform.Sock;
import jnr.constants.platform.SocketLevel;
import jnr.constants.platform.SocketOption;
import jnr.ffi.LastError;
@@ -61,6 +62,7 @@
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.Channel;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -383,6 +385,12 @@ protected void init_sock(Ruby runtime, Channel channel) {
init_sock(runtime, channel, null);
}

protected IRubyObject addrFor(ThreadContext context, SocketAddress addr, boolean reverse) {
final Ruby runtime = context.runtime;

return new Addrinfo(runtime, runtime.getClass("Addrinfo"), addr, Sock.SOCK_STREAM);
}

//private UnixSocketChannel asUnixSocket() {
// return (UnixSocketChannel)getOpenFile().fd().ch;
//}
6 changes: 2 additions & 4 deletions core/src/main/java/org/jruby/ext/socket/SocketUtils.java
Original file line number Diff line number Diff line change
@@ -272,15 +272,13 @@ public void addrinfo(InetAddress address, int port, Sock sock, Boolean reverse)
if (sock_dgram) {
l.add(new Addrinfo(runtime, runtime.getClass("Addrinfo"),
new InetSocketAddress(address, port),
Sock.SOCK_DGRAM,
SocketType.DATAGRAM));
Sock.SOCK_DGRAM));
}

if (sock_stream) {
l.add(new Addrinfo(runtime, runtime.getClass("Addrinfo"),
new InetSocketAddress(address, port),
Sock.SOCK_STREAM,
SocketType.SOCKET));
Sock.SOCK_STREAM));
}
}
});

0 comments on commit e98da35

Please sign in to comment.