Changeset 639
- Timestamp:
- 27/07/08 21:52:22 (4 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
c2s/c2s.c (modified) (3 diffs)
-
c2s/main.c (modified) (5 diffs)
-
etc/c2s.xml.dist.in (modified) (1 diff)
-
sx/Makefile.am (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/c2s/c2s.c
r636 r639 59 59 } 60 60 61 log_write(sess->c2s->log, LOG_NOTICE, "%d is throttled, disconnecting", sess->fd->fd);62 63 /* Disconnect the user. Ideally we would just stop64 reading from their socket until the throttle time65 expires. But that's difficult. */66 sx_kill(s);67 61 return -1; 68 62 } … … 238 232 sess->stanza_rate_log = 1; 239 233 } 240 241 log_write(sess->c2s->log, LOG_NOTICE, "%d is throttled, disconnecting", sess->fd->fd);242 243 /* Disconnect the user. Ideally we would just stop244 reading from their socket and delay processing of this245 stanza until the throttle time expires. But that's246 difficult. */247 sx_kill(s);248 return -1;249 234 } 250 235 … … 519 504 520 505 if(rate_check(rt) == 0) { 521 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] is being rate limited", fd->fd, ip);506 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] is being connect rate limited", fd->fd, ip); 522 507 return 1; 523 508 } -
trunk/c2s/main.c
r636 r639 181 181 c2s->stanza_size_limit = j_atoi(config_get_one(c2s->config, "io.limits.stanzasize", 0), 0); 182 182 183 /* tweak timed checks with rate times */ 184 if(c2s->io_check_interval == 0) { 185 if(c2s->byte_rate_total != 0) 186 c2s->io_check_interval = c2s->byte_rate_wait; 187 188 if(c2s->stanza_rate_total != 0 && c2s->io_check_interval > c2s->stanza_rate_wait) 189 c2s->io_check_interval = c2s->stanza_rate_wait; 190 } 191 183 192 str = config_get_one(c2s->config, "io.access.order", 0); 184 193 if(str == NULL || strcmp(str, "deny,allow") != 0) … … 475 484 } 476 485 477 /* Using SSF is potentially dangerous, as SASL can als eset the486 /* Using SSF is potentially dangerous, as SASL can also set the 478 487 * SSF of the connection. However, SASL shouldn't do so until after 479 488 * we've finished mechanism establishment … … 529 538 } 530 539 540 if(sess->rate != NULL && sess->rate->bad != 0 && rate_check(sess->rate) != 0) { 541 /* read the pending bytes when rate limit is no longer in effect */ 542 log_debug(ZONE, "reading throttled %d", sess->fd->fd); 543 sess->s->want_read = 1; 544 sx_can_read(sess->s); 545 } 546 531 547 } while(xhash_iter_next(c2s->sessions)); 532 548 } … … 537 553 char *config_file; 538 554 int optchar; 555 int mio_timeout; 539 556 sess_t sess; 540 557 bres_t res; … … 706 723 _c2s_router_connect(c2s); 707 724 725 mio_timeout = ((c2s->io_check_interval != 0 && c2s->io_check_interval < 5) ? 726 c2s->io_check_interval : 5); 727 708 728 while(!c2s_shutdown) { 709 mio_run(c2s->mio, 5);729 mio_run(c2s->mio, mio_timeout); 710 730 711 731 if(c2s_logrotate) { -
trunk/etc/c2s.xml.dist.in
r636 r639 209 209 The format is: 210 210 211 <stanzas seconds='Y' throttle='Z'>X</ bytes>211 <stanzas seconds='Y' throttle='Z'>X</stanzas> 212 212 213 213 Default Y 1, default Z is 5. Set X to 0 to disable --> -
trunk/sx/Makefile.am
r635 r639 1 1 noinst_LTLIBRARIES = libsx.la 2 2 noinst_HEADERS = plugins.h sasl.h sx.h 3 4 SUBDIRS =5 3 6 4 libsx_la_SOURCES = callback.c chain.c client.c env.c error.c io.c server.c sx.c
