On jeu., 2010-12-16 at 09:07 -0500, Charles Lepple wrote: > On Dec 16, 2010, at 7:16 AM, Frédéric Bohé wrote: > > > As a side note, beware that your implementation of usleep could lead > > to > > call Sleep(0) (immediate return) if n<1000. usleep is supposed to > > round > > up the time spent depending on system activity and timers granularity. > > Related: http://trac.networkupstools.org/projects/nut/changeset/2729 > > To fix the rounding, I would recommend adding a constant to the > numerator: > > timeout = (d_sec*1000) + (d_usec+999)/1000; > > versus: > > timeout = (d_sec*1000) + (d_usec/1000) + (((d_usec % 1000)!=0)?1:0); > > The same could be applied to the usleep -> Sleep function. It saves an > extra call to the mod function.
good point, changed. Thanks. -------------------------------------------------------------------------- _______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev
