Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Yahoo!, Google, Bing

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] write_to_descriptor doe...
Forum Rules | Mark all | Recent Posts

[Bug] write_to_descriptor doesn't check if the socket is blocking input
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 3:58 pm   Last edited May 11, 2005, 6:40 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: The write_to_descriptor function doesn't check if the socket is blocking input.
Danger: medium
Found by: Orion Elder
Fixed by: Orion Elder, Rustry
-----
[comm.c]

Find the write_to_descriptor function and replace it with:

/*
 * Lowest level output function. Write a block of text to the file descriptor.
 * If this gives errors on very long blocks (like 'ofind all'), try lowering
 * the max block size.
 *
 * Added block checking to prevent random booting of the descriptor. Thanks go
 * out to Rustry for his suggestions. -Orion
 */
bool write_to_descriptor( int desc, char *txt, int length )
{
    int iStart = 0;
    int nWrite = 0;
    int nBlock = 0;
    int iErr   = 0;

    if ( length <= 0 )
        length = strlen(txt);

    for ( iStart = 0; iStart < length; iStart += nWrite )
    {
        nBlock = UMIN( length - iStart, 4096 );
        nWrite = send( desc, txt + iStart, nBlock, 0 );

        if ( nWrite == -1 )
        {
#ifdef WIN32
            iErr = WSAGetLastError ();
#else
            iErr = errno;
#endif
            if ( iErr == EWOULDBLOCK )
            {
                /*
                 * This is a SPAMMY little bug error. I would suggest
                 * not using it, but I've included it in case. -Orion
                 *
                perror( "Write_to_descriptor: Send is blocking" );
                 */
                nWrite = 0;
                continue;
            }
            else
            {
                perror( "Write_to_descriptor" );
                return FALSE;
            }
        }
    }

    return TRUE;
}


This fix has been installed on both an AFKMud and a Chronicles MUD for awhile now, with no noticable problems.
       
Pages:<< prev 1 next >>