~ubuntu-branches/ubuntu/utopic/haproxy/utopic-proposed

« back to all changes in this revision

Viewing changes to src/proxy.c

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2009-02-17 08:55:12 UTC
  • mfrom: (1.1.5 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090217085512-qmij51nun3rbxorz
Fix build without debian/patches directory (Closes: #515682) using
/usr/share/quilt/quilt.make.

Show diffs side-by-side

added added

removed removed

Lines of Context:
314
314
        /* if there are enough free sessions, we'll activate proxies */
315
315
        if (actconn < global.maxconn) {
316
316
                while (p) {
317
 
                        if (p->feconn < p->maxconn) {
 
317
                        if (!p->maxconn || p->feconn < p->maxconn) {
318
318
                                if (p->state == PR_STIDLE) {
319
319
                                        for (l = p->listen; l != NULL; l = l->next)
320
320
                                                enable_listener(l);
351
351
                                if (t == 0) {
352
352
                                        Warning("Proxy %s stopped.\n", p->id);
353
353
                                        send_log(p, LOG_WARNING, "Proxy %s stopped.\n", p->id);
354
 
 
355
 
                                        for (l = p->listen; l != NULL; l = l->next) {
356
 
                                                unbind_listener(l);
357
 
                                                if (l->state >= LI_ASSIGNED) {
358
 
                                                        delete_listener(l);
359
 
                                                        listeners--;
360
 
                                                }
361
 
                                        }
362
 
                                        p->state = PR_STSTOPPED;
 
354
                                        stop_proxy(p);
363
355
                                        /* try to free more memory */
364
356
                                        pool_gc2();
365
357
                                }
388
380
        tv_now(&now); /* else, the old time before select will be used */
389
381
        while (p) {
390
382
                if (p->state != PR_STSTOPPED) {
391
 
                        Warning("Stopping proxy %s in %d ms.\n", p->id, p->grace);
392
 
                        send_log(p, LOG_WARNING, "Stopping proxy %s in %d ms.\n", p->id, p->grace);
 
383
                        Warning("Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace);
 
384
                        send_log(p, LOG_WARNING, "Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace);
393
385
                        tv_ms_add(&p->stop_time, &now, p->grace);
394
386
                }
395
387
                p = p->next;
421
413
        }
422
414
}
423
415
 
 
416
 
 
417
/*
 
418
 * This function completely stops a proxy and releases its listeners. It has
 
419
 * to be called when going down in order to release the ports so that another
 
420
 * process may bind to them. It must also be called on disabled proxies at the
 
421
 * end of start-up. When all listeners are closed, the proxy is set to the
 
422
 * PR_STSTOPPED state.
 
423
 */
 
424
void stop_proxy(struct proxy *p)
 
425
{
 
426
        struct listener *l;
 
427
 
 
428
        for (l = p->listen; l != NULL; l = l->next) {
 
429
                unbind_listener(l);
 
430
                if (l->state >= LI_ASSIGNED) {
 
431
                        delete_listener(l);
 
432
                        listeners--;
 
433
                }
 
434
        }
 
435
        p->state = PR_STSTOPPED;
 
436
}
 
437
 
424
438
/*
425
439
 * This function temporarily disables listening so that another new instance
426
440
 * can start listening. It is designed to be called upon reception of a
436
450
        p = proxy;
437
451
        tv_now(&now); /* else, the old time before select will be used */
438
452
        while (p) {
439
 
                if (p->state != PR_STERROR &&
 
453
                if (p->cap & PR_CAP_FE &&
 
454
                    p->state != PR_STERROR &&
440
455
                    p->state != PR_STSTOPPED &&
441
456
                    p->state != PR_STPAUSED) {
442
 
                        Warning("Pausing proxy %s.\n", p->id);
443
 
                        send_log(p, LOG_WARNING, "Pausing proxy %s.\n", p->id);
 
457
                        Warning("Pausing %s %s.\n", proxy_cap_str(p->cap), p->id);
 
458
                        send_log(p, LOG_WARNING, "Pausing %s %s.\n", proxy_cap_str(p->cap), p->id);
444
459
                        pause_proxy(p);
445
460
                        if (p->state != PR_STPAUSED) {
446
461
                                err |= 1;
447
 
                                Warning("Proxy %s failed to enter pause mode.\n", p->id);
448
 
                                send_log(p, LOG_WARNING, "Proxy %s failed to enter pause mode.\n", p->id);
 
462
                                Warning("%s %s failed to enter pause mode.\n", proxy_cap_str(p->cap), p->id);
 
463
                                send_log(p, LOG_WARNING, "%s %s failed to enter pause mode.\n", proxy_cap_str(p->cap), p->id);
449
464
                        }
450
465
                }
451
466
                p = p->next;
472
487
        tv_now(&now); /* else, the old time before select will be used */
473
488
        while (p) {
474
489
                if (p->state == PR_STPAUSED) {
475
 
                        Warning("Enabling proxy %s.\n", p->id);
476
 
                        send_log(p, LOG_WARNING, "Enabling proxy %s.\n", p->id);
 
490
                        Warning("Enabling %s %s.\n", proxy_cap_str(p->cap), p->id);
 
491
                        send_log(p, LOG_WARNING, "Enabling %s %s.\n", proxy_cap_str(p->cap), p->id);
477
492
 
478
493
                        for (l = p->listen; l != NULL; l = l->next) {
479
494
                                if (listen(l->fd, p->backlog ? p->backlog : p->maxconn) == 0) {
491
506
                                        else
492
507
                                                port = ntohs(((struct sockaddr_in *)(&l->addr))->sin_port);
493
508
 
494
 
                                        Warning("Port %d busy while trying to enable proxy %s.\n",
495
 
                                                port, p->id);
496
 
                                        send_log(p, LOG_WARNING, "Port %d busy while trying to enable proxy %s.\n",
497
 
                                                 port, p->id);
 
509
                                        Warning("Port %d busy while trying to enable %s %s.\n",
 
510
                                                port, proxy_cap_str(p->cap), p->id);
 
511
                                        send_log(p, LOG_WARNING, "Port %d busy while trying to enable %s %s.\n",
 
512
                                                 port, proxy_cap_str(p->cap), p->id);
498
513
                                        /* Another port might have been enabled. Let's stop everything. */
499
514
                                        pause_proxy(p);
500
515
                                        break;