Ejemplo n.º 1
0
        SetTcpBufSize(Socket socket, int rcvSize, int sndSize, TransportInstance instance)
        {
            if (rcvSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                SetRecvBufferSize(socket, rcvSize);
                int size = GetRecvBufferSize(socket);
                if (size < rcvSize)
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    Ice.BufSizeWarnInfo winfo = instance.GetBufSizeWarn(Ice.TCPEndpointType.Value);
                    if (!winfo.RcvWarn || rcvSize != winfo.RcvSize)
                    {
                        instance.Logger.Warning(
                            $"TCP receive buffer size: requested size of {rcvSize} adjusted to {size}");
                        instance.SetRcvBufSizeWarn(Ice.TCPEndpointType.Value, rcvSize);
                    }
                }
            }

            if (sndSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                SetSendBufferSize(socket, sndSize);
                int size = GetSendBufferSize(socket);
                if (size < sndSize) // Warn if the size that was set is less than the requested size.
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    Ice.BufSizeWarnInfo winfo = instance.GetBufSizeWarn(Ice.TCPEndpointType.Value);
                    if (!winfo.SndWarn || sndSize != winfo.SndSize)
                    {
                        instance.Logger.Warning(
                            $"TCP send buffer size: requested size of {sndSize} adjusted to {size}");
                        instance.SetSndBufSizeWarn(Ice.TCPEndpointType.Value, sndSize);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        setTcpBufSize(Socket socket, int rcvSize, int sndSize, ProtocolInstance instance)
        {
            if (rcvSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                setRecvBufferSize(socket, rcvSize);
                int size = getRecvBufferSize(socket);
                if (size < rcvSize)
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    Ice.BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
                    if (!winfo.rcvWarn || rcvSize != winfo.rcvSize)
                    {
                        instance.logger().warning("TCP receive buffer size: requested size of " + rcvSize +
                                                  " adjusted to " + size);
                        instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, rcvSize);
                    }
                }
            }

            if (sndSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                setSendBufferSize(socket, sndSize);
                int size = getSendBufferSize(socket);
                if (size < sndSize) // Warn if the size that was set is less than the requested size.
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    Ice.BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
                    if (!winfo.sndWarn || sndSize != winfo.sndSize)
                    {
                        instance.logger().warning("TCP send buffer size: requested size of " + sndSize +
                                                  " adjusted to " + size);
                        instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sndSize);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void SetBufSize(int rcvSize, int sndSize)
        {
            Debug.Assert(_fd != null);

            for (int i = 0; i < 2; ++i)
            {
                bool   isSnd;
                string direction;
                string prop;
                int    dfltSize;
                int    sizeRequested;
                if (i == 0)
                {
                    isSnd         = false;
                    direction     = "receive";
                    prop          = "Ice.UDP.RcvSize";
                    dfltSize      = Network.GetRecvBufferSize(_fd);
                    sizeRequested = rcvSize;
                    _rcvSize      = dfltSize;
                }
                else
                {
                    isSnd         = true;
                    direction     = "send";
                    prop          = "Ice.UDP.SndSize";
                    dfltSize      = Network.GetSendBufferSize(_fd);
                    sizeRequested = sndSize;
                    _sndSize      = dfltSize;
                }

                //
                // Get property for buffer size if size not passed in.
                //
                if (sizeRequested == -1)
                {
                    sizeRequested = _instance.Communicator.GetPropertyAsInt(prop) ?? dfltSize;
                }
                //
                // Check for sanity.
                //
                if (sizeRequested < (UdpOverhead + IceInternal.Protocol.headerSize))
                {
                    _instance.Logger.Warning($"Invalid {prop} value of {sizeRequested} adjusted to {dfltSize}");
                    sizeRequested = dfltSize;
                }

                if (sizeRequested != dfltSize)
                {
                    //
                    // Try to set the buffer size. The kernel will silently adjust
                    // the size to an acceptable value. Then read the size back to
                    // get the size that was actually set.
                    //
                    int sizeSet;
                    if (i == 0)
                    {
                        Network.SetRecvBufferSize(_fd, sizeRequested);
                        _rcvSize = Network.GetRecvBufferSize(_fd);
                        sizeSet  = _rcvSize;
                    }
                    else
                    {
                        Network.SetSendBufferSize(_fd, sizeRequested);
                        _sndSize = Network.GetSendBufferSize(_fd);
                        sizeSet  = _sndSize;
                    }

                    //
                    // Warn if the size that was set is less than the requested size
                    // and we have not already warned
                    //
                    if (sizeSet < sizeRequested)
                    {
                        Ice.BufSizeWarnInfo winfo = _instance.GetBufSizeWarn(Ice.UDPEndpointType.Value);
                        if ((isSnd && (!winfo.SndWarn || winfo.SndSize != sizeRequested)) ||
                            (!isSnd && (!winfo.RcvWarn || winfo.RcvSize != sizeRequested)))
                        {
                            _instance.Logger.Warning(
                                $"UDP {direction} buffer size: requested size of {sizeRequested} adjusted to {sizeSet}");

                            if (isSnd)
                            {
                                _instance.SetSndBufSizeWarn(Ice.UDPEndpointType.Value, sizeRequested);
                            }
                            else
                            {
                                _instance.SetRcvBufSizeWarn(Ice.UDPEndpointType.Value, sizeRequested);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void setBufSize(int rcvSize, int sndSize)
        {
            Debug.Assert(_fd != null);

            for (int i = 0; i < 2; ++i)
            {
                bool   isSnd;
                string direction;
                string prop;
                int    dfltSize;
                int    sizeRequested;
                if (i == 0)
                {
                    isSnd         = false;
                    direction     = "receive";
                    prop          = "Ice.UDP.RcvSize";
                    dfltSize      = Network.getRecvBufferSize(_fd);
                    sizeRequested = rcvSize;
                    _rcvSize      = dfltSize;
                }
                else
                {
                    isSnd         = true;
                    direction     = "send";
                    prop          = "Ice.UDP.SndSize";
                    dfltSize      = Network.getSendBufferSize(_fd);
                    sizeRequested = sndSize;
                    _sndSize      = dfltSize;
                }

                //
                // Get property for buffer size if size not passed in.
                //
                if (sizeRequested == -1)
                {
                    sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize);
                }
                //
                // Check for sanity.
                //
                if (sizeRequested < (_udpOverhead + Protocol.headerSize))
                {
                    _instance.logger().warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " +
                                               dfltSize);
                    sizeRequested = dfltSize;
                }

                if (sizeRequested != dfltSize)
                {
                    //
                    // Try to set the buffer size. The kernel will silently adjust
                    // the size to an acceptable value. Then read the size back to
                    // get the size that was actually set.
                    //
                    int sizeSet;
                    if (i == 0)
                    {
                        Network.setRecvBufferSize(_fd, sizeRequested);
                        _rcvSize = Network.getRecvBufferSize(_fd);
                        sizeSet  = _rcvSize;
                    }
                    else
                    {
                        Network.setSendBufferSize(_fd, sizeRequested);
                        _sndSize = Network.getSendBufferSize(_fd);
                        sizeSet  = _sndSize;
                    }

                    //
                    // Warn if the size that was set is less than the requested size
                    // and we have not already warned
                    //
                    if (sizeSet < sizeRequested)
                    {
                        Ice.BufSizeWarnInfo winfo = _instance.getBufSizeWarn(Ice.UDPEndpointType.value);
                        if ((isSnd && (!winfo.sndWarn || winfo.sndSize != sizeRequested)) ||
                            (!isSnd && (!winfo.rcvWarn || winfo.rcvSize != sizeRequested)))
                        {
                            _instance.logger().warning("UDP " + direction + " buffer size: requested size of " +
                                                       sizeRequested + " adjusted to " + sizeSet);

                            if (isSnd)
                            {
                                _instance.setSndBufSizeWarn(Ice.UDPEndpointType.value, sizeRequested);
                            }
                            else
                            {
                                _instance.setRcvBufSizeWarn(Ice.UDPEndpointType.value, sizeRequested);
                            }
                        }
                    }
                }
            }
        }