diff --git a/ecrire/inc_cron.php3 b/ecrire/inc_cron.php3
index 41b193697d4fda99ddc41e1ca357257f94b60f69..3280d66e0029c15e0eb4dea1b950351c17eb5376 100644
--- a/ecrire/inc_cron.php3
+++ b/ecrire/inc_cron.php3
@@ -46,14 +46,15 @@ function spip_cron($taches=array()) {
 	global $frequence_taches;
 	$t = time();
 
-	if (!@file_exists(_FILE_MYSQL_OUT)
-	OR ($t - @filemtime(_FILE_MYSQL_OUT) > 300)) {
-		include(_FILE_CONNECT);
-		if (!$GLOBALS['db_ok']) {
-			@touch(_FILE_MYSQL_OUT);
-			spip_log('pas de connexion DB pour taches de fond (cron)');
-			return;
-		}
+	if (@file_exists(_FILE_MYSQL_OUT)
+	AND ($t - @filemtime(_FILE_MYSQL_OUT) < 300))
+		return;
+
+	include(_FILE_CONNECT);
+	if (!$GLOBALS['db_ok']) {
+		@touch(_FILE_MYSQL_OUT);
+		spip_log('pas de connexion DB pour taches de fond (cron)');
+		return;
 	}
 
 	if (!$taches)
diff --git a/ecrire/inc_debug_sql.php3 b/ecrire/inc_debug_sql.php3
index 38a2f2271d4cade99c7b5c815503b856fd70c9c1..e49ccccda70c50c30fcb11d03f4f4fe9d586a1f0 100644
--- a/ecrire/inc_debug_sql.php3
+++ b/ecrire/inc_debug_sql.php3
@@ -37,7 +37,6 @@ function erreur_requete_boucle($query, $id_boucle, $type) {
 
 	// Calmer le jeu avec MySQL (si jamais on est en saturation)
 	@touch(_FILE_MYSQL_OUT);	// pour spip_cron
-	@touch(_FILE_LOCK);		// lock hebergeur
 	spip_log('Erreur MySQL: on limite les acces quelques minutes');
 	$GLOBALS['bouton_admin_debug'] = true;
 
diff --git a/ecrire/inc_version.php3 b/ecrire/inc_version.php3
index d89942e9b96de795f6d070fa40d91e1396c860b9..8b15fe0d2871d23bb2773bb0faa78d89b8f2dd29 100644
--- a/ecrire/inc_version.php3
+++ b/ecrire/inc_version.php3
@@ -320,7 +320,6 @@ $test_dirs = array(_DIR_CACHE, _DIR_IMG, _DIR_SESSIONS);
 
 // les fichiers qu'on y met, entre autres,
 
-define_once('_FILE_LOCK', _DIR_SESSIONS . 'lock');
 define_once('_FILE_CRON_LOCK', _DIR_SESSIONS . 'cron.lock');
 define_once('_FILE_MYSQL_OUT', _DIR_SESSIONS . 'mysql_out');
 define_once('_FILE_GARBAGE', _DIR_SESSIONS . '.poubelle');
@@ -914,41 +913,6 @@ function table_objet($type) {
 }
 
 
-//
-// Savoir si on peut lancer de gros calculs, et eventuellement poser un lock SQL
-// Resultat : true=vas-y ; false=stop
-//
-function timeout($lock=false, $action=true, $connect_mysql=true) {
-	static $ok = true;
-	global $db_ok;
-
-	// Fichier lock hebergeur ?  (age maxi, 10 minutes)
-
-	if (@file_exists(_FILE_LOCK)
-	AND ((time() - @filemtime(_FILE_LOCK)) < 600))
-		return $ok = false;
-
-	// Ne rien faire ?
-	if (!$action || !$ok)
-		return $ok;
-
-	$ok = false;
-
-	// Base connectee ?
-	if ($connect_mysql) {
-		include_local(_FILE_CONNECT);
-		if (!$db_ok)
-			return false;
-
-		// Verrou demande ?
-		if ($lock AND !spip_get_lock($lock))
-			return false;
-	}
-
-	// C'est bon
-	return true;
-}
-
 //
 // spip_timer : on l'appelle deux fois et on a la difference, affichable
 //
diff --git a/ecrire/index.php3 b/ecrire/index.php3
index 3b6c1be824c9f05210e2fbba270d9a872236f17a..2e12e3ecd90136be6fcba3b56925b4dfb5f42834 100644
--- a/ecrire/index.php3
+++ b/ecrire/index.php3
@@ -537,10 +537,13 @@ if (abs($t_jour - date('d')) > 2) {
 //
 if (!$bonjour) {
 	if ($optimiser == 'oui' || (time() - lire_meta('date_optimisation')) > 24 * 3600) {
-		if (timeout('optimisation')) {
+		if (!file_exists($lock = _DIR_SESSIONS.'optimisation.lock')
+		OR (time()-filemtime($lock) > 3600)) {
+			touch($lock);
 			ecrire_meta("date_optimisation", time());
 			ecrire_metas();
 			include ("optimiser.php3");
+			unlink($lock);
 		}
 	}
 }