Bugfixes.
* imap4d/io.c (imap4d_tokbuf_decrlf): Rewrite to run in O(n). * libmailutils/server/ipsrv.c (mu_ip_tcp_accept): Return 0 on EINTR (unless srv->f_intr tells otherwise) and EAGAIN. The caller will retry. (mu_ip_server_accept): output a diagnostic message before returning error.
Showing
2 changed files
with
20 additions
and
11 deletions
... | @@ -436,16 +436,17 @@ imap4d_tokbuf_decrlf (struct imap4d_tokbuf *tok, size_t off, size_t *plen) | ... | @@ -436,16 +436,17 @@ imap4d_tokbuf_decrlf (struct imap4d_tokbuf *tok, size_t off, size_t *plen) |
436 | size_t len = *plen; | 436 | size_t len = *plen; |
437 | char *p, *end = buf + len; | 437 | char *p, *end = buf + len; |
438 | 438 | ||
439 | for (p = end - 1; p > buf; p--) | 439 | for (p = buf; p < end; ) |
440 | { | 440 | { |
441 | if (*p == '\n' && p > buf && p[-1] == '\r') | 441 | if (*p == '\r' && p + 1 < end && p[1] == '\n') |
442 | { | 442 | { |
443 | memmove (p - 1, p, end - p); | 443 | p++; |
444 | end--; | 444 | len--; |
445 | p--; | ||
446 | } | 445 | } |
446 | else | ||
447 | *buf++ = *p++; | ||
447 | } | 448 | } |
448 | *plen = end - buf; | 449 | *plen = len; |
449 | } | 450 | } |
450 | 451 | ||
451 | static void | 452 | static void | ... | ... |
... | @@ -361,10 +361,14 @@ mu_ip_tcp_accept (mu_ip_server_t srv, void *call_data) | ... | @@ -361,10 +361,14 @@ mu_ip_tcp_accept (mu_ip_server_t srv, void *call_data) |
361 | if (connfd == -1) | 361 | if (connfd == -1) |
362 | { | 362 | { |
363 | int ec = errno; | 363 | int ec = errno; |
364 | if (ec == EINTR) | 364 | switch (ec) |
365 | { | 365 | { |
366 | if (srv->f_intr && srv->f_intr (srv->data, call_data)) | 366 | case EINTR: |
367 | mu_ip_server_shutdown (srv); | 367 | if (srv->f_intr && srv->f_intr (srv->data, call_data)) |
368 | break; | ||
369 | /* fall through */ | ||
370 | case EAGAIN: | ||
371 | ec = 0; | ||
368 | } | 372 | } |
369 | return ec; | 373 | return ec; |
370 | } | 374 | } |
... | @@ -493,7 +497,11 @@ mu_ip_server_accept (mu_ip_server_t srv, void *call_data) | ... | @@ -493,7 +497,11 @@ mu_ip_server_accept (mu_ip_server_t srv, void *call_data) |
493 | } | 497 | } |
494 | 498 | ||
495 | if (rc) | 499 | if (rc) |
496 | mu_ip_server_shutdown (srv); | 500 | { |
501 | mu_error (_("socket error on \"%s\": %s"), IDENTSTR (srv), | ||
502 | mu_strerror (rc)); | ||
503 | mu_ip_server_shutdown (srv); | ||
504 | } | ||
497 | return rc; | 505 | return rc; |
498 | } | 506 | } |
499 | 507 | ... | ... |
-
Please register or sign in to post a comment