[PATCH] Use tiny, fast and thread-safe ntplib module instead of ntpdate
Brian C. Lane
bcl at redhat.com
Tue Jul 30 16:22:58 UTC 2013
On Tue, Jul 30, 2013 at 10:35:46AM +0200, Vratislav Podzimek wrote:
> On Mon, 2013-07-29 at 11:57 -0700, Brian C. Lane wrote:
> > On Fri, Jul 26, 2013 at 01:41:04PM +0200, Vratislav Podzimek wrote:
> > > ntpdate is quite a big and slow binary that is not further developed and
> > > basically nobody but us uses it. ntplib is a tiny, fast and thread-safe module
> > > provided by the python-ntplib package containing only the tiny module.
> >
> > Nice find!
> >
> > > + settimeofday(&tv, NULL);
> >
> > Should we be checking the rc and raising an error if it fails?
> Good point, I've added the check and also modified the function a bit to
> get rid of the temporary 'int secs' variable. It could cause problems
> because 'time_t' may be bigger than 'int'. For the same reason I've
> changed the format string for ParseTuple to "L" (long long). This is how
> the function looks now:
>
> static PyObject * doSetSystemTime(PyObject *s, PyObject *args) {
> struct timeval tv;
> tv.tv_usec = 0;
>
> if (!PyArg_ParseTuple(args, "L", &(tv.tv_sec)))
> return NULL;
>
> if (settimeofday(&tv, NULL) != 0)
> PyErr_SetFromErrno(PyExc_SystemError);
>
> Py_INCREF(Py_None);
> return Py_None;
> }
>
> --
> Vratislav Podzimek
>
> Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
Ack
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130730/9aff661d/attachment.sig>
More information about the anaconda-patches
mailing list