[freetds] Heavy load patch for net.c

Christos Zoulas christos at zoulas.com
Thu Jan 10 16:17:45 EST 2008


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


More information about the FreeTDS mailing list