Skip to Content.
Sympa Menu

freetds - Re: [freetds] Heavy load patch for net.c

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Heavy load patch for net.c
  • Date: Fri, 11 Jan 2008 10:16:41 +0100

> On Jan 10, 10:01pm, freddy77 AT gmail.com (Frediano Ziglio) wrote:
> -- Subject: [freetds] Heavy load patch for net.c
>
> | Hi,
> | fixing stability problem for Asterisk (see Federico mail today) I
> | found that problem was related to select. select require some fd_set
> | structures wihich contains a bit fields with any file
> descriptor. Bits
> | are set with FD_SET that do not check for bounds so if descriptor is
> | greater or equal to FD_SETSIZE a buffer occur. The solution
> if fd_set is
> | implemented using a bitfield (under Windows is implemented
> as an array
> | of file descriptors so limit is the number of file, not
> value) is using
> | poll (if supported, if not probably system does not support much
> | files...).
> |
> | I wrote the patch attached but there are some problems:
> | - is written quite fastly without many tests
> | - it change a critical part (one which required a lot of attention)
> | - there are still a select call in net.c to change (and
> perhaps patch
> | should be rewritten in another way)
> | - here (in Italy) is not time to make any commit :)
> |
> | Any comment is welcome. Probably tds_select should be splitted in a
> | tds_poll and a tds_select where tds_poll accept a file descriptor
> | instead of a TDSSOCKET*. Perhaps should tds_poll be not static with
> | TDSSELxxx defined in tds.h so to use in another contexts (like pool
> | server) ??
>
> Looks good; I would add an assert(FD_SETSIZE > tds->s) to
> avoid the overflow.
>
> christos

assert is not compiled if NDEBUG is defined so I prefer a

#if !defined(WIN32) && defined(FD_SETSIZE)
if (s >= FD_SETSIZE) {
sock_errno = EINVAL;
return -1;
}
#endif

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page