gvfs r2149 - in trunk: . daemon



Author: otte
Date: Tue Dec 30 21:23:55 2008
New Revision: 2149
URL: http://svn.gnome.org/viewvc/gvfs?rev=2149&view=rev

Log:
2008-12-30  Benjamin Otte  <otte gnome org>

	* daemon/gvfsbackendftp.c: (g_vfs_backend_ftp_pop_connection):
	remove fixme for max connection tracking, by remembering the max
	connections on the stack.



Modified:
   trunk/ChangeLog
   trunk/daemon/gvfsbackendftp.c

Modified: trunk/daemon/gvfsbackendftp.c
==============================================================================
--- trunk/daemon/gvfsbackendftp.c	(original)
+++ trunk/daemon/gvfsbackendftp.c	Tue Dec 30 21:23:55 2008
@@ -1322,6 +1322,12 @@
 
       if (ftp->connections < ftp->max_connections)
 	{
+	  /* Save current number of connections here, so we can limit maximum 
+	   * connections later.
+	   * This is necessary for threading reasons (connections can be 
+	   * opened or closed while we are still in the opening process. */
+	  guint maybe_max_connections = ftp->connections;
+
 	  ftp->connections++;
 	  g_mutex_unlock (ftp->mutex);
 	  conn = ftp_connection_create (ftp->addr, job);
@@ -1337,8 +1343,7 @@
 	  conn = NULL;
 	  g_mutex_lock (ftp->mutex);
 	  ftp->connections--;
-	  /* FIXME: This assignment is racy due to the mutex unlock above */
-	  ftp->max_connections = ftp->connections;
+	  ftp->max_connections = MIN (ftp->max_connections, maybe_max_connections);
 	  if (ftp->max_connections == 0)
 	    {
 	      DEBUG ("no more connections left, exiting...");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]