Coda File System

Re: Replication on more than two servers?

From: Daniel Schmitt <pnambic_at_kidata.de>
Date: Thu, 14 Oct 1999 11:57:36 +0200
> related code fragment...
>         int i = sscanf(string, "%lx %s %s %s %s %s %s %s %s\n",
>                        &vsgaddr, Host[0], Host[1],
>                        Host[2], Host[3], Host[4],
>                        Host[5], Host[6], Host[7]);
>         if (i == 0) break;
>         /* number of hosts = i - 1 */
>         for (int j = 0; j < i - 1; j++){
>             he = gethostbyname(Host[j]);
>             Haddr[j] = ntohl(*(unsigned long *)(he->h_addr));
>         }
>         vsgent *newve = new vsgent(vsgaddr, Haddr, i-1);
> 
> Ok, got it, the sscanf returns -1. Or EOF, which I would understand if
> the function was fscanf, not with sscanf. Could this be new behaviour in
> glibc2.1?
That seems to be the case. To wit, I found the following in the glibc2.1 info
file:

 - Function: int sscanf (const char *S, const char *TEMPLATE, ...)
   This is like `scanf', except that the characters are taken from the
   null-terminated string S instead of from a stream.  Reaching the
   end of the string is treated as an end-of-file condition.

According to the docs, this behavior is mandated by the ANSI/ISO C standard.
 
> In any case the following change will probably fix the problem.
> 
>                        Host[2], Host[3], Host[4],
>                        Host[5], Host[6], Host[7]);
> -        if (i == 0) break;
> +        if (i < 2) break;     /* not enough fields read to create a vsg */
>         /* number of hosts = i - 1 */
>         for (int j = 0; j < i - 1; j++){
That did it indeed (I made that change in an otherwise vanilla 5.3.2 release).
Thanks a lot! I kept the system running overnight, copying files back and forth
from a bunch of scripts, and so far it's been rock solid. Keep up the great
work!

Ciao,

Daniel.

-- 
daniel schmitt - lead system architect - kidata ag, koenigswinter, germany
Received on 1999-10-14 05:59:05