- function run()
- {
- do {
-
- $flinks = $this->refreshFlinks();
-
- foreach ($flinks as $f){
-
- // We have to disconnect from the DB before forking so
- // each sub-process will open its own connection and
- // avoid stomping on the others
-
- $conn = &$f->getDatabaseConnection();
- $conn->disconnect();
-
- $pid = pcntl_fork();
-
- if ($pid == -1) {
- die ("Couldn't fork!");
- }
-
- if ($pid) {
-
- // Parent
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Parent: forked new status fetcher process " . $pid);
- }
-
- $this->children[] = $pid;
-
- } else {
-
- // Child
- $this->getTimeline($f);
- exit();
- }
-
- // Remove child from ps list as it finishes
- while(($c = pcntl_wait($status, WNOHANG OR WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Child $c finished.");
- }
-
- $this->remove_ps($this->children, $c);
- }
-
- // Wait! We have too many damn kids.
- if (sizeof($this->children) > MAXCHILDREN) {
+ /**
+ * Find all the Twitter foreign links for users who have requested
+ * importing of their friends' timelines
+ *
+ * @return array flinks an array of Foreign_link objects
+ */