Date: Sun, 02 Nov 2014 12:27:32 -0800 From: Xin Li <delphij@delphij.net> To: Konstantin Belousov <kostikbel@gmail.com>, d@delphij.net Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Mark R V Murray <mark@grondar.org> Subject: Re: svn commit: r273958 - head/sys/dev/random Message-ID: <545693B4.8030602@delphij.net> In-Reply-To: <20141102201331.GE53947@kib.kiev.ua> References: <201411020201.sA221unt091493@svn.freebsd.org> <720EB74E-094A-43F3-8B1C-47BC7F6FECC3@grondar.org> <1414934579.17308.248.camel@revolution.hippie.lan> <6FB65828-6A79-4BDE-A9F7-BC472BA538CE@grondar.org> <CAJ-VmomeOwE3LOpehhJ__G=FCoBDRXrrn%2BSfjwPFODts6YYHNQ@mail.gmail.com> <20141102192057.GB53947@kib.kiev.ua> <29A795E1-19E2-49E4-9653-143D3F6F3F12@grondar.org> <20141102194625.GC53947@kib.kiev.ua> <751CD860-95B9-4F68-AE69-976B42823AD0@grondar.org> <54568E41.8030305@delphij.net> <20141102201331.GE53947@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------070609020704050205090900 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, Mark, I'd like to propose the attached patch for review. It replaces tsleep's with sx_sleep's, then checks the return value and quit the loop. Cheers, - -- Xin LI <delphij@delphij.net> https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0 iQIcBAEBCgAGBQJUVpO0AAoJEJW2GBstM+nsTcoQAKQglUQUKCh4h+flynK+of1J I8pyCJTqkJHsvQu7Lj8Nh4gd6OQM3+XdpEGymA/wB1Q906cNI8ieLwuXCOmCxYhw xs2XJL5cyp1myDqCp3BRrNta8PPSF8gxfnCeU/0LuItrvcNaE3axNb/eu4g3u5s7 NZObx84C03uRoHMz+9qG0qkZbutY/qN8YP3DQ1WvkYom/i4UT2NGa1EgHLYa9Ofu REQ/lADumxqn5Cw6viKym1wI1HrCu00X602jGjivEzn1L7DSfKFJjckyLC2IbbdY Ydy4ejsILJRPFDt6PrcSWkaSBIy585wP90YsFvSK4riyy1i3HUF4pE5wQPPG/ogV ATm4S9GZgr4mM3SHZrcaTDyrm9BEsEizqBs/F3yyuKBqZt0xtTjv+tupCN5AG1LX DnfgLj7pNAW2SIF7lul34/CzisoKB7b5oEpL9YWOh8DvZiEgHMex4nRqTNAt9T8F 7f5bGvcMHfkIOQIUanxlganUW2ZgVaDPYQADjrEsfqD2pTwwK7glN0jXKJ9YStGW kzbjAQil9X/fliVSzPubbO0XTqAtjnPwONBbjw06vlrwZlkHbLOTz0VVZ3cAJcei 4CkCiEQtuFWbD9QVCUe6snztRRTI542dIlWSDPhSxYV3+hrkCgCeJ3fMvTutf7YZ ejIPZ/NOkhddVmvjMHKw =XrYs -----END PGP SIGNATURE----- --------------070609020704050205090900 Content-Type: text/plain; charset=UTF-8; name="random-tsleep.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="random-tsleep.diff" Index: sys/dev/random/random_adaptors.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/dev/random/random_adaptors.c (revision 273982) +++ sys/dev/random/random_adaptors.c (working copy) @@ -217,7 +217,7 @@ random_adaptor_read(struct cdev *dev __unused, str =20 /* (Un)Blocking logic */ error =3D 0; - while (!random_adaptor->ra_seeded()) { + while (!random_adaptor->ra_seeded() && error =3D=3D 0) { if (flags & O_NONBLOCK) { error =3D EWOULDBLOCK; break; @@ -224,7 +224,8 @@ random_adaptor_read(struct cdev *dev __unused, str } =20 /* Sleep instead of going into a spin-frenzy */ - tsleep(&random_adaptor, PUSER | PCATCH, "block", hz/10); + error =3D sx_sleep(&random_adaptor, &random_adaptors_lock, + PUSER | PCATCH, "block", hz/10); =20 /* keep tapping away at the pre-read until we seed/unblock. */ (random_adaptor->ra_read)(NULL, 0); @@ -298,7 +299,7 @@ random_adaptor_write(struct cdev *dev __unused, st =20 random_buf =3D malloc(PAGE_SIZE, M_ENTROPY, M_WAITOK); =20 - while (uio->uio_resid > 0) { + while (uio->uio_resid > 0 && error =3D=3D 0) { c =3D MIN(uio->uio_resid, PAGE_SIZE); error =3D uiomove(random_buf, c, uio); if (error) @@ -306,7 +307,8 @@ random_adaptor_write(struct cdev *dev __unused, st (random_adaptor->ra_write)(random_buf, c); =20 /* Introduce an annoying delay to stop swamping */ - tsleep(&random_adaptor, PUSER | PCATCH, "block", hz/10); + error =3D sx_sleep(&random_adaptor, &random_adaptors_lock, + PUSER | PCATCH, "block", hz/10); } =20 free(random_buf, M_ENTROPY); --------------070609020704050205090900 Content-Type: application/octet-stream; name="random-tsleep.diff.sig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="random-tsleep.diff.sig" iQIcBAABCgAGBQJUVpO0AAoJEJW2GBstM+nsokkP/R/K43IDwibhgHgp342TFWgeXs1mvcgq Ao17kPtMb5oC5De7+LwQ6iqbK8Mhk3KhPUbO7tK0WaHIcAr8SG9itLKZDB408TIvrVq1e6Oa NpHdYsCZDZAP7KkWQJKnzw0BXuFjIKjJVWBhcXLrlXD+iO4wxwzPCrPDVWqlT3PamROGaoKK K1kS55rIJLNG5dzfMo3nKWBhw7SHo6SsHk6KRAAfUa2Z10LNF0KJZRyhFkjJNY5SdG/Hr7JG GDQHZoLldH+HnYHu3WIgfyNntGYaOv+OhIXHKjTf8bPHJD3LPASFBnculpCQdirXng1iIihZ 1Pzpzg6qGYbxf1G3pB3+5awemz1cEuCP9Jjg2HDgzj2GNWigRlvKztqfuaMuAvlVfrbd6WAJ +nBGkoTIHmGcPFWkz0Jc9vZc8+oxdMdh7L6ltYmEuqI+T7Q+fvpcneSa7q0UQMF5NyEQNW9p 1PW6lXgwjxXZjEACUjS6Vavtdx2G++HWOZ4r9/21Qh4QIoN5khpSz6jbRFPE6jhgauK5RgdT RrbuOXP0IsTNJSnRWrAB5aly30hnyUDLAmO5WZ6ZvzrLggijUYJiy8UHp/4qpsFYTgCity0v mWdK1iajNjfm22ao0hgRdM3npA2pMAUTXgRh8gl9NyG3zdNS/gu1IdbwJ5mD4srFC7rWlV5Y 8tq6 --------------070609020704050205090900--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?545693B4.8030602>