Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
481
3,740
19,388
628
PabloL3189
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,643
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 >>