summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2006-04-17 19:05:20 +0000
committerMarcus Meissner <marcus@jet.franken.de>2006-04-17 19:05:20 +0000
commitbdc9109d2a257d42d796c140ed5d96ccff27f067 (patch)
tree98353d65acf82770f643238fe73f7b0a50e69b14
parentde3ef8841044d864a8e33ecea48fc660ec4ff23c (diff)
downloadlibgphoto2-bdc9109d2a257d42d796c140ed5d96ccff27f067.tar.gz
stat the devices before opening, to safe time on locking attempts
(saves 0.6 seconds with SUSE resmgr on a 500mhz machine) git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@8745 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--libgphoto2_port/serial/unix.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libgphoto2_port/serial/unix.c b/libgphoto2_port/serial/unix.c
index 515cb9a25..66bdf2c24 100644
--- a/libgphoto2_port/serial/unix.c
+++ b/libgphoto2_port/serial/unix.c
@@ -335,6 +335,10 @@ gp_port_library_list (GPPortInfoList *list)
if (r)
continue;
#endif
+ /* Very first of all, if the device node is not there,
+ * there is no need to try locking. */
+ if ((stat (path, &s) == -1) && ((errno == ENOENT) || (errno == ENODEV)))
+ continue;
/* First of all, try to lock the device */
if (gp_port_serial_lock (NULL, path) < 0)