Index: trunk/phase3/includes/PoolCounter.php |
— | — | @@ -151,44 +151,47 @@ |
152 | 152 | } else { |
153 | 153 | $status = $this->poolCounter->acquireForMe(); |
154 | 154 | } |
155 | | - |
156 | | - if ( $status->isOK() ) { |
157 | | - switch ( $status->value ) { |
158 | | - case PoolCounter::LOCKED: |
159 | | - $result = $this->doWork(); |
160 | | - $this->poolCounter->release(); |
161 | | - return $result; |
| 155 | + |
| 156 | + if ( !$status->isOK() ) { |
| 157 | + // Respond gracefully to complete server breakage: just log it and do the work |
| 158 | + $this->logError( $status ); |
| 159 | + return $this->doWork(); |
| 160 | + } |
| 161 | + |
| 162 | + switch ( $status->value ) { |
| 163 | + case PoolCounter::LOCKED: |
| 164 | + $result = $this->doWork(); |
| 165 | + $this->poolCounter->release(); |
| 166 | + return $result; |
| 167 | + |
| 168 | + case PoolCounter::DONE: |
| 169 | + $result = $this->getCachedWork(); |
| 170 | + if ( $result === false ) { |
| 171 | + /* That someone else work didn't serve us. |
| 172 | + * Acquire the lock for me |
| 173 | + */ |
| 174 | + return $this->execute( true ); |
| 175 | + } |
| 176 | + return $result; |
162 | 177 | |
163 | | - case PoolCounter::DONE: |
164 | | - $result = $this->getCachedWork(); |
165 | | - if ( $result === false ) { |
166 | | - /* That someone else work didn't serve us. |
167 | | - * Acquire the lock for me |
168 | | - */ |
169 | | - return $this->execute( true ); |
170 | | - } |
| 178 | + case PoolCounter::QUEUE_FULL: |
| 179 | + case PoolCounter::TIMEOUT: |
| 180 | + $result = $this->fallback(); |
| 181 | + |
| 182 | + if ( $result !== false ) { |
171 | 183 | return $result; |
172 | | - |
173 | | - case PoolCounter::QUEUE_FULL: |
174 | | - case PoolCounter::TIMEOUT: |
175 | | - $result = $this->fallback(); |
176 | | - |
177 | | - if ( $result !== false ) { |
178 | | - return $result; |
179 | | - } |
180 | | - /* no break */ |
| 184 | + } |
| 185 | + /* no break */ |
| 186 | + |
| 187 | + /* These two cases should never be hit... */ |
| 188 | + case PoolCounter::ERROR: |
| 189 | + default: |
| 190 | + $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' ); |
181 | 191 | |
182 | | - /* These two cases should never be hit... */ |
183 | | - case PoolCounter::ERROR: |
184 | | - default: |
185 | | - $errors = array( PoolCounter::QUEUE_FULL => 'pool-queuefull', PoolCounter::TIMEOUT => 'pool-timeout' ); |
186 | | - |
187 | | - $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' ); |
188 | | - /* continue to the error */ |
189 | | - } |
| 192 | + $status = Status::newFatal( isset($errors[$status->value]) ? $errors[$status->value] : 'pool-errorunknown' ); |
| 193 | + $this->logError( $status ); |
| 194 | + return $this->error( $status ); |
190 | 195 | } |
191 | | - $this->logError( $status ); |
192 | | - return $this->error( $status ); |
193 | 196 | } |
194 | 197 | |
195 | 198 | function __construct( $type, $key ) { |