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 15:07:56 +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

This is an updated patch that contain the if as you suggested to avoid
overflow.
It contains also fix for the other select in net.c. I didn't add
tds_poll cause
- it avoids to reinitialize (FD_ZERO) fd_set structs at every call if
poll is not available
- it's quite small so less problems and easy to backport
It does not change pool but I don't think it's a big problem.
If nobody objects I would backport it in a couple of day... you to get
RC2 :)

freddy77

Attachment: vedi.diff.gz
Description: vedi.diff.gz




Archive powered by MHonArc 2.6.24.

Top of Page