Bug 30829 - Extra open() call in gypsy_client_start()
Summary: Extra open() call in gypsy_client_start()
Status: RESOLVED FIXED
Alias: None
Product: Gypsy
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: medium critical
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-13 05:20 UTC by Roman Gezikov
Modified: 2012-05-14 07:36 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Roman Gezikov 2010-10-13 05:20:58 UTC
In the function gypsy_client_start() in the following code:


	if (priv->device_path[0] == '/') {
		priv->fd = open (priv->device_path, O_RDONLY | O_NOCTTY | O_NONBLOCK);
		if (priv->fd != -1 && isatty (priv->fd)) {
			/* Reopen read-write for TTY devices,
			 * we'll be detecting whether it's garmin later */
			priv->type = GYPSY_DEVICE_TYPE_SERIAL;
			close (priv->fd);
			priv->fd = open (priv->device_path, O_RDWR | O_NOCTTY | O_NONBLOCK);
		} else {
			priv->type = GYPSY_DEVICE_TYPE_FIFO;
		}
		priv->fd = open (priv->device_path, O_RDWR | O_NOCTTY | O_NONBLOCK);
		if (priv->fd == -1) {
			g_warning ("Error opening device %s: %s", priv->device_path, g_strerror (errno));
			g_set_error (error, GYPSY_ERROR, errno, g_strerror (errno));
			return FALSE;
		}


last call to open() method is not needed.
Comment 1 iain 2012-05-14 07:36:22 UTC
Has been fixed 

commit 754ac3bdf53d7fc3f9383f0e009c71f2b2e26381
Author: iain <iain@linux.intel.com>
Date:   Tue Dec 6 13:00:31 2011 +0000

    Only open TTY devices once
    
    TTY devices were accidentally being opened twice but only closed once. This
    meant that when a device file was removed, but then replaced, a file descrip
    this dead file descriptor was being returned when Gypsy attempted to open th
    new device, causing I/O errors when trying to read from it. Which in turn
    caused some lovely CPU pegging as Gypsy would just enter a busy loop constan
    trying to read from the dead descriptor.
    
    In short, everyone's a winner!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.