@JRubyMethod(optional = 1) public IRubyObject shutdown(ThreadContext context, IRubyObject[] args) { int how = 2; if (args.length > 0) { how = RubyNumeric.fix2int(args[0]); } try { return shutdownInternal(context, how); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
@JRubyMethod(optional = 1) public IRubyObject shutdown(ThreadContext context, IRubyObject[] args) { int how = 2; if (args.length > 0) { how = RubyNumeric.fix2int(args[0]); } try { return shutdownInternal(context, how); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
private IRubyObject closeHalf(ThreadContext context, int closeHalf) { OpenFile fptr; int otherHalf = closeHalf == OpenFile.READABLE ? OpenFile.WRITABLE : OpenFile.READABLE; fptr = getOpenFileChecked(); if ((fptr.getMode() & otherHalf) == 0) { // shutdown fully return rbIoClose(context); } // shutdown half int how = closeHalf == OpenFile.READABLE ? 0 : 1; shutdownInternal(context, fptr, how); return context.nil; }
private IRubyObject closeHalf(ThreadContext context, int closeHalf) { OpenFile fptr; int otherHalf = closeHalf == OpenFile.READABLE ? OpenFile.WRITABLE : OpenFile.READABLE; fptr = getOpenFileChecked(); if ((fptr.getMode() & otherHalf) == 0) { // shutdown fully return rbIoClose(context); } // shutdown half int how = closeHalf == OpenFile.READABLE ? 0 : 1; shutdownInternal(context, fptr, how); return context.nil; }
@JRubyMethod(optional = 1) public IRubyObject shutdown(ThreadContext context, IRubyObject[] args) { int how = 2; if (args.length > 0) { String howString = null; if (args[0] instanceof RubyString || args[0] instanceof RubySymbol) { howString = args[0].asJavaString(); } else { Ruby runtime = context.runtime; IRubyObject maybeString = TypeConverter.checkStringType(runtime, args[0]); if (!maybeString.isNil()) howString = maybeString.toString(); } if (howString != null) { if (howString.equals("RD") || howString.equals("SHUT_RD")) { how = 0; } else if (howString.equals("WR") || howString.equals("SHUT_WR")) { how = 1; } else if (howString.equals("RDWR") || howString.equals("SHUT_RDWR")) { how = 2; } else { throw SocketUtils.sockerr(context.runtime, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR"); } } else { how = RubyNumeric.fix2int(args[0]); } } OpenFile fptr = getOpenFileChecked(); return shutdownInternal(context, fptr, how); }
@JRubyMethod(optional = 1) public IRubyObject shutdown(ThreadContext context, IRubyObject[] args) { int how = 2; if (args.length > 0) { String howString = null; if (args[0] instanceof RubyString || args[0] instanceof RubySymbol) { howString = args[0].asJavaString(); } else { Ruby runtime = context.runtime; IRubyObject maybeString = TypeConverter.checkStringType(runtime, args[0]); if (!maybeString.isNil()) howString = maybeString.toString(); } if (howString != null) { if (howString.equals("RD") || howString.equals("SHUT_RD")) { how = 0; } else if (howString.equals("WR") || howString.equals("SHUT_WR")) { how = 1; } else if (howString.equals("RDWR") || howString.equals("SHUT_RDWR")) { how = 2; } else { throw SocketUtils.sockerr(context.runtime, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR"); } } else { how = RubyNumeric.fix2int(args[0]); } } OpenFile fptr = getOpenFileChecked(); return shutdownInternal(context, fptr, how); }
@Override @JRubyMethod public IRubyObject close_read(ThreadContext context) { Ruby runtime = context.runtime; if (!openFile.isOpen()) { throw context.runtime.newIOError("not opened for reading"); } if (!openFile.isWritable()) { close(); } else { // shutdown read try { shutdownInternal(context, 0); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } } return context.nil; }
@Override @JRubyMethod public IRubyObject close_read(ThreadContext context) { Ruby runtime = context.runtime; if (!openFile.isOpen()) { throw context.runtime.newIOError("not opened for reading"); } if (!openFile.isWritable()) { close(); } else { // shutdown read try { shutdownInternal(context, 0); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } } return context.nil; }
shutdownInternal(context, fptr, 0); shutdownInternal(context, fptr, 1);
shutdownInternal(context, fptr, 0); shutdownInternal(context, fptr, 1);
shutdownInternal(context, 0); shutdownInternal(context, 1);
shutdownInternal(context, 0); shutdownInternal(context, 1);
@Override @JRubyMethod public IRubyObject close_write(ThreadContext context) { Ruby runtime = context.runtime; if (!openFile.isWritable()) { return runtime.getNil(); } if (openFile.getPipeStream() == null && openFile.isReadable()) { throw runtime.newIOError("closing non-duplex IO for writing"); } if (!openFile.isReadable()) { close(); } else { // shutdown write try { shutdownInternal(context, 1); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } } return context.nil; }
@Override @JRubyMethod public IRubyObject close_write(ThreadContext context) { Ruby runtime = context.runtime; if (!openFile.isWritable()) { return runtime.getNil(); } if (openFile.getPipeStream() == null && openFile.isReadable()) { throw runtime.newIOError("closing non-duplex IO for writing"); } if (!openFile.isReadable()) { close(); } else { // shutdown write try { shutdownInternal(context, 1); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } } return context.nil; }