Commits

Ruslan Osmanov committed c54e3c1

Fix: restart watcher internally in case when priority property is written for an active watcher

  • Participants
  • Parent commits e8d6dca

Comments (0)

Files changed (2)

 	int active = ev_is_active(watcher);
 
     if (active) {
-        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Modifying active watcher");
+        php_error_docref(NULL TSRMLS_CC, E_WARNING,
+        		"Modifying active watcher. Restarting the watcher internally.");
     }
 
 	priority = Z_LVAL_P(value);
 	    return FAILURE;
 	}
 
-	/* TODO: stop if active */
+	if (active) {
+		php_ev_stop_watcher(watcher TSRMLS_CC);
+	}
+
 	php_ev_set_watcher_priority(watcher, priority TSRMLS_CC);
-	/* TODO: start if active */
+
+	if (active) {
+		php_ev_start_watcher(watcher TSRMLS_CC);
+	}
 
 	return SUCCESS;
 }

File tests/08_priority.phpt

 Check for priorities
 --FILE--
 <?php 
-#error_reporting(0);
+error_reporting(0);
 
 $t0 = new EvTimer(-1, 0, function ($w, $r) { echo "ok 4\n"; });
 $t_ = new EvTimer(-1, 0, function ($w, $r) { echo "ok 5\n"; });