[systemd-devel] [PATCH] Add timesync-wait tool

Lukasz Stelmach stlman at poczta.fm
Fri Oct 24 14:13:42 PDT 2014


On 24.10.2014 00:28, Lennart Poettering wrote:
> On Thu, 23.10.14 21:24, Łukasz Stelmach (stlman at poczta.fm) wrote:
> 
>> +int main(int argc, char *argv[]) {
>> +        struct timex tbuf;
>> +        int r;
>> +
>> +        memset(&tbuf, 0, sizeof(tbuf));
> 
> Please initialize this with "= {}" while declaring, instead of using
> memset() here.
> 
>> +        r = adjtimex(&tbuf);
>> +
>> +        while (r != TIME_OK) {
> 
> This check looks wrong. Should check for tbuf.status & STA_UNSYNC, no? 
> 
> Also, we already have the ntp_synced() call for doing this. 

Indeed. I can replace most of the code here with ntp_synced() leaving an
"if" with a break and the sleep();

>> +                sleep(1);
>> +                /* Unfortunately there seem to be no other way than
>> +                polling to get this information. */
>> +                memset(&tbuf, 0, sizeof(tbuf));
> 
> In this case, use zero(), it's nicer, simpler and less error prone.
> 
>> +                r = adjtimex(&tbuf);
>> +        }
> 
> Implementing this with a sleep loop is really ugly. Can't we at least
> calculate the expected sync time from the data returned by adjtimex()?

I don't know how to do it exactly (yet). But my guess is that when the
system starts the information you refer are not good enough to predict
anything?

> The same way as network-wait-online has a timeout this tool should
> probably have one too.

If the timeout is reached the tool exits with a non-zero code. Right?
That makes sense. Is three minutes OK?

Give me a few more evenings to prepare the niceties others have requested.

-- 
Było mi bardzo miło.                   Twoje oczy lubią mnie
>Łukasz<                                     i to mnie zgubi  (c)SNL

REKLAMA: http://ars-fabrica.eu/ sklep z rękodziełem

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 538 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141024/f7f8947f/attachment.sig>


More information about the systemd-devel mailing list