On Thu, Jan 14, 2010 at 12:28:19AM +0100, Cyril Bonté wrote:
> Hi again Hervé,
> 
> Le Mercredi 13 Janvier 2010 12:56:30, Hervé COMMOWICK a écrit :
> > Hi Cyril,
> > 
> > I know the check is not perfect, because it doesn't handle a correct 
> > disconnection.
> > Mysql expect the client to talk, and i think it's weird... in the 
> > future, i think it will be better to do a *real* mysql ping, but at the 
> > moment, the checks API doesn't let me handle this in a cleaner way.
> 
> This is not a patch but a start of reflection :
> 
> In the function event_srv_chk_r(int fd),
> after this condition :
>       if (trash[4] != -1) {

Hmmm I didn't notice that one. You should cast this test,
because trash is defined as char[] and some platforms use
unsigned char by default (eg: PPC) so this test will never
match on such platforms.

So the fix consists in one of those four possibilities,
which are all equivalent but may mean different things
for the reader :

     if ((signed char)trash[4] != -1)

     if ((unsigned char)trash[4] != 255)

     if (trash[4] != (char)-1)

     if (trash[4] != '\xff')

I tend to find the last one more readable but maybe -1 was
really the value to test against so the first and third ones
might be better.

Willy


Reply via email to