~ubuntu-branches/ubuntu/saucy/uwsgi/saucy

« back to all changes in this revision

Viewing changes to spooler.c

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-04-30 17:35:22 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120430173522-qucwu1au3s9bflhb
Tags: 1.2+dfsg-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
        // here the file will be unlocked too
238
238
        close(fd);
239
239
 
240
 
        if (!uwsgi.spooler_quiet) 
 
240
        if (!uwsgi.spooler_quiet)
241
241
                uwsgi_log("[spooler] written %d bytes to file %s\n", size + body_len + 4, filename);
242
242
        
243
243
        // and here waiting threads can continue
310
310
                event_queue_add_fd_read(spooler_event_queue, uwsgi.shared->spooler_signal_pipe[1]);
311
311
        }
312
312
 
 
313
        // reset the tasks counter
 
314
        uspool->tasks = 0;
 
315
 
313
316
        for (;;) {
314
317
 
315
318
 
337
340
                if (event_queue_wait(spooler_event_queue, timeout, &interesting_fd) > 0) {
338
341
                        if (uwsgi.master_process) {
339
342
                                if (interesting_fd == uwsgi.shared->spooler_signal_pipe[1]) {
340
 
                                        uint8_t uwsgi_signal;
341
 
                                        if (read(interesting_fd, &uwsgi_signal, 1) <= 0) {
342
 
                                                        uwsgi_log_verbose("uWSGI spooler screams: UAAAAAAH my master died, i will follow him...\n");
343
 
                                                        end_me(0); 
344
 
                                        }
345
 
                                        else {
346
 
#ifdef UWSGI_DEBUG
347
 
                                                uwsgi_log_verbose("master sent signal %d to the spooler\n", uwsgi_signal);
348
 
#endif
349
 
                                                if (uwsgi_signal_handler(uwsgi_signal)) {
350
 
                                                        uwsgi_log_verbose("error managing signal %d on the spooler\n", uwsgi_signal);
351
 
                                                }
352
 
                                        }
 
343
                                        uwsgi_receive_signal(interesting_fd, "spooler", (int) getpid());
353
344
                                }
354
345
                        }
355
346
                }
361
352
                }
362
353
                wakeup = tmp_wakeup;
363
354
 
 
355
                // need to recycle ?
 
356
                if (uwsgi.spooler_max_tasks > 0 && uspool->tasks >= (uint64_t)uwsgi.spooler_max_tasks) {
 
357
                        uwsgi_log("[spooler %s pid: %d] maximum number of tasks reached (%d) recycling ...\n", uspool->dir, (int) uwsgi.mypid, uwsgi.spooler_max_tasks);
 
358
                        end_me(0);
 
359
                }
 
360
 
364
361
        }
365
362
}
366
363
 
508
505
                        // now the task is running and should not be waken up
509
506
                        uspool->running = 1;
510
507
 
511
 
                        if (!uwsgi.spooler_quiet) 
512
 
                                uwsgi_log("[spooler %s pid: %d] managing request %s ...\n", uspool->dir, (int) uwsgi.mypid, task); 
 
508
                        if (!uwsgi.spooler_quiet)
 
509
                                uwsgi_log("[spooler %s pid: %d] managing request %s ...\n", uspool->dir, (int) uwsgi.mypid, task);
513
510
 
514
511
 
515
512
                        // chdir before running the task (if requested)
532
529
                                        }
533
530
                                        if (ret == 0) continue;
534
531
                                        callable_found = 1;
 
532
                                        // increase task counter
 
533
                                        uspool->tasks++;
535
534
                                        if (ret == -2) {
536
535
                                                if (!uwsgi.spooler_quiet)
537
536
                                                        uwsgi_log("[spooler %s pid: %d] done with task %s after %d seconds\n", uspool->dir, (int) uwsgi.mypid, task, time(NULL)-now);