Exemple #1
0
        SetTcpBufSize(Socket socket, int rcvSize, int sndSize, Communicator communicator)
        {
            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.
                    BufSizeWarnInfo winfo = communicator.GetBufSizeWarn(Transport.TCP);
                    if (!winfo.RcvWarn || rcvSize != winfo.RcvSize)
                    {
                        communicator.Logger.Warning(
                            $"TCP receive buffer size: requested size of {rcvSize} adjusted to {size}");
                        communicator.SetRcvBufSizeWarn(Transport.TCP, 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.
                    BufSizeWarnInfo winfo = communicator.GetBufSizeWarn(Transport.TCP);
                    if (!winfo.SndWarn || sndSize != winfo.SndSize)
                    {
                        communicator.Logger.Warning(
                            $"TCP send buffer size: requested size of {sndSize} adjusted to {size}");
                        communicator.SetSndBufSizeWarn(Transport.TCP, sndSize);
                    }
                }
            }
        }
Exemple #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.
                    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.
                    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);
                    }
                }
            }
        }
Exemple #3
0
        internal static void SetBufSize(Socket socket, Communicator communicator, Transport transport)
        {
            int rcvSize = communicator.GetPropertyAsByteSize($"Ice.{transport}.RcvSize") ?? 0;

            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.
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, rcvSize);
                int size = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer) !;
                if (size < rcvSize)
                {
                    // Warn if the size that was set is less than the requested size and we have not already warned.
                    BufSizeWarnInfo warningInfo = communicator.GetBufSizeWarn(Transport.TCP);
                    if (!warningInfo.RcvWarn || rcvSize != warningInfo.RcvSize)
                    {
                        communicator.Logger.Warning(
                            $"{transport} receive buffer size: requested size of {rcvSize} adjusted to {size}");
                        communicator.SetRcvBufSizeWarn(Transport.TCP, rcvSize);
                    }
                }
            }

            int sndSize = communicator.GetPropertyAsByteSize($"Ice.{transport}.SndSize") ?? 0;

            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.
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, sndSize);
                int size = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer) !;
                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.
                    BufSizeWarnInfo warningInfo = communicator.GetBufSizeWarn(Transport.TCP);
                    if (!warningInfo.SndWarn || sndSize != warningInfo.SndSize)
                    {
                        communicator.Logger.Warning(
                            $"{transport} send buffer size: requested size of {sndSize} adjusted to {size}");
                        communicator.SetSndBufSizeWarn(Transport.TCP, sndSize);
                    }
                }
            }
        }
Exemple #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)
                    {
                        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);
                            }
                        }
                    }
                }
            }
        }
Exemple #5
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 = _communicator.GetPropertyAsInt(prop) ?? dfltSize;
                }
                //
                // Check for sanity.
                //
                if (sizeRequested < (UdpOverhead + Ice1Definitions.HeaderSize))
                {
                    _communicator.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)
                    {
                        BufSizeWarnInfo winfo = _communicator.GetBufSizeWarn(EndpointType.UDP);
                        if ((isSnd && (!winfo.SndWarn || winfo.SndSize != sizeRequested)) ||
                            (!isSnd && (!winfo.RcvWarn || winfo.RcvSize != sizeRequested)))
                        {
                            _communicator.Logger.Warning(
                                $"UDP {direction} buffer size: requested size of {sizeRequested} adjusted to {sizeSet}");

                            if (isSnd)
                            {
                                _communicator.SetSndBufSizeWarn(EndpointType.UDP, sizeRequested);
                            }
                            else
                            {
                                _communicator.SetRcvBufSizeWarn(EndpointType.UDP, sizeRequested);
                            }
                        }
                    }
                }
            }
        }