<div dir="ltr"><p style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px;margin-top:0px">In <a href="https://github.com/openbmc/phosphor-hwmon" style="box-sizing:border-box;background-color:initial;color:rgb(3,102,214);text-decoration-line:none">https://github.com/openbmc/phosphor-hwmon</a> => hwmonio.cpp , I saw we use the std::ifstream to open and read a device sensor.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">But, I met an issue with it. In case the sensor was disabled (Ex: the Fan was unplugged), the std::ifstream read will take a long time . The timeout in there is so long. It makes my system have a BIG delay in each checking sensor.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">Other observation : In case the sensor device is ready, the time for sensor reading is expected.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="box-sizing:border-box;font-weight:600">Measuring std::ifstream reading:</span></p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">In case unplugged sensor: 91385 microseconds<br style="box-sizing:border-box">In case plugged sensor. : 507 microseconds</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">The patch to measure the std::ifstream reading, please see attachment !</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="box-sizing:border-box;font-weight:600">Unexpected behavior you saw</span></p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">The timeout in there is so long</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px"><span style="box-sizing:border-box;font-weight:600">Expected behavior</span></p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:14px">Do we have any better solution in this case? take less more timeout.</p><div><div><img src="cid:ii_kfy4siob0" alt="Screen Shot 2020-10-03 at 11.32.36 AM.png" width="499" height="258"><br></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><i>Nguyen Minh Chanh </i></div><div><i>Embedded Software Engineer </i></div></div></div></div></div></div></div>