Beispiel #1
0
 public void reap(Ice.ConnectionI connection)
 {
     lock (this)
     {
         _reapedConnections.Add(connection);
     }
 }
Beispiel #2
0
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public virtual void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                  bool response, byte compress, int requestId)
        {
            instance_ = instance;

            //
            // Don't recycle the Current object, because servants may keep a reference to it.
            //
            current_           = new Ice.Current();
            current_.id        = new Ice.Identity();
            current_.adapter   = adapter;
            current_.con       = connection;
            current_.requestId = requestId;

            Debug.Assert(cookie_ == null);

            response_ = response;

            compress_ = compress;

            if (response_ && os_ == null)
            {
                os_ = new BasicStream(instance, Ice.Util.currentProtocolEncoding);
            }

            connection_ = connection;
            interceptorAsyncCallbackList_ = null;
        }
Beispiel #3
0
 public BatchOutgoing(Ice.ConnectionI connection, Instance instance, InvocationObserver observer)
 {
     _connection = connection;
     _sent       = false;
     _observer   = observer;
     _os         = new BasicStream(instance, Ice.Util.currentProtocolEncoding);
 }
Beispiel #4
0
 public ConnectionRequestHandler(Reference @ref, Ice.ConnectionI connection, bool compress)
 {
     _reference  = @ref;
     _response   = _reference.getMode() == Reference.Mode.ModeTwoway;
     _connection = connection;
     _compress   = compress;
 }
 public ConnectionRequestHandler(Reference @ref, Ice.ConnectionI connection, bool compress)
 {
     _reference = @ref;
     _response = _reference.getMode() == Reference.Mode.ModeTwoway;
     _connection = connection;
     _compress = compress;
 }
Beispiel #6
0
        //
        // Implementation of Reference.GetConnectionCallback
        //

        public void setConnection(Ice.ConnectionI connection, bool compress)
        {
            lock (this)
            {
                Debug.Assert(_exception == null && _connection == null);
                _connection = connection;
                _compress   = compress;
            }

            //
            // If this proxy is for a non-local object, and we are using a router, then
            // add this proxy to the router info object.
            //
            RouterInfo ri = _reference.getRouterInfo();

            if (ri != null && !ri.addProxy(_proxy, this))
            {
                return; // The request handler will be initialized once addProxy returns.
            }

            //
            // We can now send the queued requests.
            //
            flushRequests();
        }
Beispiel #7
0
        public void flushConnection(Ice.ConnectionI con)
        {
            lock (this)
            {
                ++_useCount;
            }

            try
            {
                Ice.AsyncCallback sentCB = null;
                FlushBatch        flush  = new FlushBatch(this);
                int batchRequestNum      = con.getBatchRequestQueue().swap(flush.getOs());
                if (batchRequestNum == 0)
                {
                    flush.sent();
                }
                else
                {
                    con.sendAsyncRequest(flush, false, false, batchRequestNum, out sentCB);
                }
                Debug.Assert(sentCB == null);
            }
            catch (Ice.LocalException ex)
            {
                doCheck(false);
                throw ex;
            }
        }
Beispiel #8
0
 public void setAdapterOnConnection(Ice.ConnectionI connection)
 {
     lock (this)
     {
         checkForDeactivation();
         connection.setAdapterAndServantManager(this, _servantManager);
     }
 }
Beispiel #9
0
 public void add(Ice.ConnectionI connection)
 {
     lock (this)
     {
         Debug.Assert(instance_ != null);
         _connections.Add(connection);
     }
 }
Beispiel #10
0
 public void remove(Ice.ConnectionI connection)
 {
     lock (this)
     {
         Debug.Assert(instance_ != null);
         _connections.Remove(connection);
     }
 }
Beispiel #11
0
 public override int invokeRemote(Ice.ConnectionI connection, bool compress, bool response)
 {
     cachedConnection_ = connection;
     if (responseImpl(false, true, true))
     {
         invokeResponseAsync();
     }
     return(AsyncStatusSent);
 }
Beispiel #12
0
 public override bool invokeRemote(Ice.ConnectionI con, bool compress, bool resp, out Ice.AsyncCallback sentCB)
 {
     if (_batchRequestNum == 0)
     {
         sentCB = sent();
         return(true);
     }
     cachedConnection_ = con;
     return(con.sendAsyncRequest(this, compress, false, _batchRequestNum, out sentCB));
 }
Beispiel #13
0
 add(Ice.ConnectionI connection, Ice.Instrumentation.Observer observer)
 {
     lock (this)
     {
         _connections.Add(connection);
         if (observer != null)
         {
             observer.detach();
         }
     }
 }
Beispiel #14
0
 public FixedReference(Instance instance,
                       Ice.Communicator communicator,
                       Ice.Identity identity,
                       string facet,
                       Reference.Mode mode,
                       bool secure,
                       Ice.ConnectionI connection)
     : base(instance, communicator, identity, facet, mode, secure)
 {
     _fixedConnection = connection;
 }
Beispiel #15
0
 public override bool invokeRemote(Ice.ConnectionI con, bool compress, bool resp, out Ice.AsyncCallback sentCB)
 {
     sentCB            = null;
     cachedConnection_ = con;
     Ice.AsyncCallback cb = finished(true);
     if (cb != null)
     {
         invokeCompletedAsync(cb);
     }
     return(true);
 }
Beispiel #16
0
 public void remove(Ice.ConnectionI connection)
 {
     lock (this)
     {
         Debug.Assert(_connection == connection);
         _connection = null;
         if (_config.timeout > 0)
         {
             _timer.cancel(this);
         }
     }
 }
Beispiel #17
0
 public void add(Ice.ConnectionI connection)
 {
     lock (this)
     {
         Debug.Assert(_connection == null);
         _connection = connection;
         if (_config.timeout > 0)
         {
             _timer.scheduleRepeated(this, _config.timeout / 2);
         }
     }
 }
Beispiel #18
0
        public void remove(Ice.ConnectionI connection)
        {
            if (_config.timeout == 0)
            {
                return;
            }

            lock (this)
            {
                Debug.Assert(_instance != null);
                _changes.Add(new Change(connection, true));
            }
        }
Beispiel #19
0
 public Ice.ConnectionI sendRequest(Outgoing @out)
 {
     Ice.ConnectionI connection = getConnection(true);
     Debug.Assert(connection != null);
     if (!connection.sendRequest(@out, _compress, _response) || _response)
     {
         return(_connection); // The request has been sent or we're expecting a response.
     }
     else
     {
         return(null); // The request hasn't been sent yet.
     }
 }
Beispiel #20
0
        public Incoming(Ice.Communicator communicator, ResponseHandler handler, Ice.ConnectionI connection,
                        Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
        {
            _communicator    = communicator;
            _responseHandler = handler;
            _response        = response;
            _compress        = compress;

            _current           = new Ice.Current();
            _current.id        = new Ice.Identity();
            _current.adapter   = adapter;
            _current.con       = connection;
            _current.requestId = requestId;

            _cookie = null;
        }
Beispiel #21
0
        public Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                        bool response, byte compress, int requestId)
            : base(instance, connection, adapter, response, compress, requestId)
        {
            //
            // Prepare the response if necessary.
            //
            if (response)
            {
                os_.writeBlob(IceInternal.Protocol.replyHdr);

                //
                // Add the request ID.
                //
                os_.writeInt(requestId);
            }
        }
        public ConnectionRequestHandler(Reference @ref, Ice.ObjectPrx proxy)
        {
            _reference = @ref;
            _response = _reference.getMode() == Reference.Mode.ModeTwoway;

            _connection = _reference.getConnection(out _compress);

            //
            // If this proxy is for a non-local object, and we are using a router, then
            // add this proxy to the router info object.
            //
            IceInternal.RouterInfo ri = _reference.getRouterInfo();
            if(ri != null)
            {
                ri.addProxy(proxy);
            }
        }
Beispiel #23
0
        public Reference create(Ice.Identity ident, Ice.ConnectionI connection)
        {
            if (ident.name.Length == 0 && ident.category.Length == 0)
            {
                return(null);
            }

            //
            // Create new reference
            //
            return(new FixedReference(
                       instance_,
                       _communicator,
                       ident,
                       "", // Facet
                       connection.endpoint().datagram() ? Reference.Mode.ModeDatagram : Reference.Mode.ModeTwoway,
                       connection.endpoint().secure(),
                       instance_.defaultsAndOverrides().defaultEncoding,
                       connection));
        }
Beispiel #24
0
        protected internal IncomingBase(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                        bool response, byte compress, int requestId)
        {
            instance_ = instance;
            response_ = response;
            compress_ = compress;
            if (response_)
            {
                os_ = new BasicStream(instance, Ice.Util.currentProtocolEncoding);
            }
            connection_ = connection;

            current_           = new Ice.Current();
            current_.id        = new Ice.Identity();
            current_.adapter   = adapter;
            current_.con       = connection;
            current_.requestId = requestId;

            cookie_ = null;
        }
Beispiel #25
0
        public void add(Ice.ConnectionI connection)
        {
            if (_config.timeout == 0)
            {
                return;
            }

            lock (this)
            {
                if (_connections.Count == 0)
                {
                    _connections.Add(connection);
                    _instance.timer().scheduleRepeated(this, _config.timeout / 2);
                }
                else
                {
                    _changes.Add(new Change(connection, false));
                }
            }
        }
Beispiel #26
0
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public void reset(Ice.Communicator communicator, ResponseHandler handler, Ice.ConnectionI connection,
                          Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
        {
            _communicator    = communicator;
            _responseHandler = handler;
            _response        = response;
            _compress        = compress;

            //
            // Don't recycle the Current object, because servants may keep a reference to it.
            //
            _current    = null;
            _adapter    = adapter;
            _connection = connection;
            _requestId  = requestId;

            Debug.Assert(_cookie == null);

            _inParamPos = -1;
        }
Beispiel #27
0
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public void reset(Instance instance, ResponseHandler handler, Ice.ConnectionI connection,
                          Ice.ObjectAdapter adapter, bool response, byte compress, int requestId)
        {
            _instance        = instance;
            _responseHandler = handler;
            _response        = response;
            _compress        = compress;

            //
            // Don't recycle the Current object, because servants may keep a reference to it.
            //
            _current           = new Ice.Current();
            _current.id        = new Ice.Identity();
            _current.adapter   = adapter;
            _current.con       = connection;
            _current.requestId = requestId;

            Debug.Assert(_cookie == null);

            _inParamPos = -1;
        }
Beispiel #28
0
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public override void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                   bool response, byte compress, int requestId)
        {
            _cb         = null;
            _inParamPos = -1;

            base.reset(instance, connection, adapter, response, compress, requestId);

            //
            // Prepare the response if necessary.
            //
            if (response)
            {
                os_.writeBlob(IceInternal.Protocol.replyHdr);

                //
                // Add the request ID.
                //
                os_.writeInt(requestId);
            }
        }
Beispiel #29
0
        public void add(Ice.ConnectionI connection)
        {
            if (_config.timeout == 0)
            {
                return;
            }

            lock (this)
            {
                if (_connections.Count == 0)
                {
                    Debug.Assert(_communicator != null);
                    _connections.Add(connection);
                    _communicator.timer().scheduleRepeated(this, _config.timeout / 2);
                }
                else
                {
                    _changes.Add(new Change(connection, false));
                }
            }
        }
Beispiel #30
0
        public void runTimerTask()
        {
            Ice.ConnectionI[] connections = null;
            lock (this)
            {
                if (instance_ == null)
                {
                    return;
                }

                connections = new Ice.ConnectionI[_connections.Count];
                _connections.CopyTo(connections);
            }

            //
            // Monitor connections outside the thread synchronization,
            // so that connections can be added or removed during
            // monitoring.
            //
            long now = IceInternal.Time.currentMonotonicTimeMillis();

            foreach (Ice.ConnectionI connection in connections)
            {
                try
                {
                    connection.monitor(now);
                }
                catch (System.Exception ex)
                {
                    lock (this)
                    {
                        if (instance_ == null)
                        {
                            return;
                        }
                        instance_.initializationData().logger.error("unknown exception in connection monitor:\n" + ex);
                    }
                }
            }
        }
Beispiel #31
0
        public Reference create(Ice.Identity ident, Ice.ConnectionI connection)
        {
            if (ident.name.Length == 0 && ident.category.Length == 0)
            {
                return(null);
            }

            //
            // Create new reference
            //
            return(new FixedReference(
                       _instance,
                       _communicator,
                       ident,
                       "", // Facet
                       connection.endpoint().datagram() ? Reference.Mode.ModeDatagram : Reference.Mode.ModeTwoway,
                       connection.endpoint().secure(),
                       Ice.Util.Protocol_1_0,
                       _instance.defaultsAndOverrides().defaultEncoding,
                       connection,
                       -1,
                       null,
                       new Ice.Optional <bool>()));
        }
Beispiel #32
0
 internal Change(Ice.ConnectionI connection, bool remove)
 {
     this.connection = connection;
     this.remove     = remove;
 }
Beispiel #33
0
 public BatchOutgoing(Ice.ConnectionI connection, Instance instance)
 {
     _connection = connection;
     _sent = false;
     _os = new BasicStream(instance);
 }
Beispiel #34
0
 public void reap(Ice.ConnectionI connection)
 {
     _parent.reap(connection);
 }
Beispiel #35
0
        public void runTimerTask()
        {
            Ice.ConnectionI[] connections = null;
            lock(this)
            {
                if(instance_ == null)
                {
                    return;
                }

                connections = new Ice.ConnectionI[_connections.Count];
                _connections.CopyTo(connections);
            }

            //
            // Monitor connections outside the thread synchronization,
            // so that connections can be added or removed during
            // monitoring.
            //
            long now = IceInternal.Time.currentMonotonicTimeMillis();
            foreach(Ice.ConnectionI connection in connections)
            {
                try
                {
                    connection.monitor(now);
                }
                catch(System.Exception ex)
                {
                    lock(this)
                    {
                        if(instance_ == null)
                        {
                            return;
                        }
                        instance_.initializationData().logger.error("unknown exception in connection monitor:\n" + ex);
                    }
                }
            }
        }
Beispiel #36
0
 public TimeoutCallback(ConnectionI connection)
 {
     _connection = connection;
 }
Beispiel #37
0
 public void remove(Ice.ConnectionI connection)
 {
     lock(this)
     {
         Debug.Assert(_connection == connection);
         _connection = null;
         if(_config.timeout > 0)
         {
             _timer.cancel(this);
         }
     }
 }
Beispiel #38
0
 public void add(Ice.ConnectionI connection)
 {
     lock(this)
     {
         Debug.Assert(_connection == null);
         _connection = connection;
         if(_config.timeout > 0)
         {
             _timer.scheduleRepeated(this, _config.timeout / 2);
         }
     }
 }
Beispiel #39
0
 internal Change(Ice.ConnectionI connection, bool remove)
 {
     this.connection = connection;
     this.remove = remove;
 }
Beispiel #40
0
        //
        // Implementation of Reference.GetConnectionCallback
        //
        public void setConnection(Ice.ConnectionI connection, bool compress)
        {
            lock(this)
            {
                Debug.Assert(_exception == null && _connection == null);
                _connection = connection;
                _compress = compress;
            }

            //
            // If this proxy is for a non-local object, and we are using a router, then
            // add this proxy to the router info object.
            //
            RouterInfo ri = _reference.getRouterInfo();
            if(ri != null && !ri.addProxy(_proxy, this))
            {
                return; // The request handler will be initialized once addProxy returns.
            }

            //
            // We can now send the queued requests.
            //
            flushRequests();
        }
Beispiel #41
0
        protected internal IncomingBase(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                        bool response, byte compress, int requestId)
        {
            instance_ = instance;
            response_ = response;
            compress_ = compress;
            os_ = new BasicStream(instance);
            connection_ = connection;

            current_ = new Ice.Current();
            current_.id = new Ice.Identity();
            current_.adapter = adapter;
            current_.con = connection;
            current_.requestId = requestId;

            cookie_ = null;
        }
Beispiel #42
0
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public virtual void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                  bool response, byte compress, int requestId)
        {
            instance_ = instance;

            //
            // Don't recycle the Current object, because servants may keep a reference to it.
            //
            current_ = new Ice.Current();
            current_.id = new Ice.Identity();
            current_.adapter = adapter;
            current_.con = connection;
            current_.requestId = requestId;

            Debug.Assert(cookie_ == null);

            response_ = response;

            compress_ = compress;

            if(os_ == null)
            {
                os_ = new BasicStream(instance);
            }

            connection_ = connection;
            interceptorAsyncCallbackList_ = null;
        }
Beispiel #43
0
        internal void adopt(IncomingBase inc)
        {
            instance_ = inc.instance_;
            //inc.instance_ = null; // Don't reset instance_.

            servant_ = inc.servant_;
            inc.servant_ = null;

            locator_ = inc.locator_;
            inc.locator_ = null;

            cookie_ = inc.cookie_;
            inc.cookie_ = null;

            response_ = inc.response_;
            inc.response_ = false;

            compress_ = inc.compress_;
            inc.compress_ = 0;

            //
            // Adopt the stream - it creates less garbage.
            //
            os_ = inc.os_;
            inc.os_ = null;

            connection_ = inc.connection_;
            inc.connection_ = null;
        }
Beispiel #44
0
        protected internal void handleException__(System.Exception exc)
        {
            Debug.Assert(connection_ != null);

            try
            {
                throw exc;
            }
            catch(Ice.RequestFailedException ex)
            {
                if(ex.id == null)
                {
                    ex.id = current_.id;
                }

                if(ex.facet == null)
                {
                    ex.facet = current_.facet;
                }

                if(ex.operation == null || ex.operation.Length == 0)
                {
                    ex.operation = current_.operation;
                }

                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 1)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    if(ex is Ice.ObjectNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyObjectNotExist);
                    }
                    else if(ex is Ice.FacetNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyFacetNotExist);
                    }
                    else if(ex is Ice.OperationNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyOperationNotExist);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                    ex.id.write__(os_);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    if(ex.facet == null || ex.facet.Length == 0)
                    {
                        os_.writeStringSeq(null);
                    }
                    else
                    {
                        string[] facetPath2 = { ex.facet };
                        os_.writeStringSeq(facetPath2);
                    }

                    os_.writeString(ex.operation);

                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(Ice.UnknownLocalException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownLocalException);
                    os_.writeString(ex.unknown);
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(Ice.UnknownUserException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownUserException);
                    os_.writeString(ex.unknown);
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(Ice.UnknownException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownException);
                    os_.writeString(ex.unknown);
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(Ice.LocalException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownLocalException);
                    os_.writeString(ex.ice_name() + "\n" + ex.StackTrace);
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(Ice.UserException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownUserException);
                    os_.writeString(ex.ice_name() + "\n" + ex.StackTrace);
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }
            catch(System.Exception ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault(
                    "Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownException);
                    os_.writeString(ex.ToString());
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }
            }

            connection_ = null;
        }
Beispiel #45
0
        protected bool servantLocatorFinished__()
        {
            Debug.Assert(locator_ != null && servant_ != null);
            try
            {
                locator_.finished(current_, servant_, cookie_);
                return true;
            }
            catch(Ice.UserException ex)
            {
                Debug.Assert(connection_ != null);

                //
                // The operation may have already marshaled a reply; we must overwrite that reply.
                //
                if(response_)
                {
                    os_.endWriteEncaps();
                    os_.resize(Protocol.headerSize + 4, false); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUserException);
                    os_.startWriteEncaps();
                    os_.writeUserException(ex);
                    os_.endWriteEncaps();
                    connection_.sendResponse(os_, compress_);
                }
                else
                {
                    connection_.sendNoResponse();
                }

                connection_ = null;
            }
            catch(System.Exception ex)
            {
                handleException__(ex);
            }
            return false;
        }