annotate src/pop3/client.c @ 9658:8ba4253adc9b HEAD tip

*-login: SSL connections didn't get closed when the client got destroyed.
author Timo Sirainen <tss@iki.fi>
date Thu, 08 May 2014 16:41:29 +0300
parents b2d30a8d3fb4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9532
00cd9aacd03c Updated copyright notices to include year 2010.
Timo Sirainen <tss@iki.fi>
parents: 8745
diff changeset
1 /* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
4 #include "buffer.h"
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "ioloop.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "network.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "istream.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "ostream.h"
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
9 #include "str.h"
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
10 #include "var-expand.h"
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 #include "mail-storage.h"
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 #include "commands.h"
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
13 #include "mail-search-build.h"
5500
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
14 #include "mail-namespace.h"
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 #include <stdlib.h>
3960
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
17 #include <unistd.h>
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
1053
28f606ada24a Reduce input buffer size
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
19 /* max. length of input command line (spec says 512) */
28f606ada24a Reduce input buffer size
Timo Sirainen <tss@iki.fi>
parents: 1044
diff changeset
20 #define MAX_INBUF_SIZE 2048
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
22 /* Stop reading input when output buffer has this many bytes. Once the buffer
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
23 size has dropped to half of it, start reading input again. */
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
24 #define OUTBUF_THROTTLE_SIZE 4096
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
25
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 /* Disconnect client when it sends too many bad commands in a row */
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 #define CLIENT_MAX_BAD_COMMANDS 20
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
7103
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
29 /* Disconnect client after idling this many milliseconds */
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
30 #define CLIENT_IDLE_TIMEOUT_MSECS (10*60*1000)
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
31 /* If client starts idling for this many milliseconds, commit the current
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
32 transaction. This allows the mailbox to become unlocked. */
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
33 #define CLIENT_COMMIT_TIMEOUT_MSECS (10*1000)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 static struct client *my_client; /* we don't need more than one currently */
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36
4907
5b4c9b20eba0 Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
37 static void client_input(struct client *client);
5b4c9b20eba0 Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
38 static int client_output(struct client *client);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
40 static void client_commit_timeout(struct client *client)
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
41 {
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
42 if (client->cmd != NULL) {
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
43 /* Can't commit while commands are running */
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
44 return;
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
45 }
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
46
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
47 (void)mailbox_transaction_commit(&client->trans);
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
48 client->trans = mailbox_transaction_begin(client->mailbox, 0);
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
49 }
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
50
7103
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
51 static void client_idle_timeout(struct client *client)
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
52 {
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
53 if (client->cmd != NULL) {
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
54 client_destroy(client,
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
55 "Disconnected for inactivity in reading our output");
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
56 } else {
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
57 client_send_line(client, "-ERR Disconnected for inactivity.");
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
58 client_destroy(client, "Disconnected for inactivity");
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
59 }
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
60 }
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
61
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
62 static bool init_mailbox(struct client *client, const char **error_r)
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
63 {
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
64 struct mail_search_args *search_args;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
65 struct mailbox_transaction_context *t;
1845
bd8b6ed35327 Removed fetch_init/fetch_next from mail-storage. search_* makes it
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
66 struct mail_search_context *ctx;
2976
96a4ab34c8f1 Added pop3_uidl_format setting.
Timo Sirainen <tss@iki.fi>
parents: 2927
diff changeset
67 struct mailbox_status status;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
68 struct mail *mail;
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
69 buffer_t *message_sizes_buf;
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
70 uint32_t failed_uid = 0;
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
71 uoff_t size;
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3517
diff changeset
72 int i;
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
73 bool failed, expunged;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
74
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
75 message_sizes_buf = buffer_create_dynamic(default_pool, 512);
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
76
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
77 search_args = mail_search_build_init();
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
78 mail_search_build_add_all(search_args);
1845
bd8b6ed35327 Removed fetch_init/fetch_next from mail-storage. search_* makes it
Timo Sirainen <tss@iki.fi>
parents: 1672
diff changeset
79
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
80 for (i = 0; i < 2; i++) {
6652
c62f30cc1153 Fixed using uninitialized variable in error handling.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
81 expunged = FALSE;
6463
aeee5076f99f Use mailbox_sync() instead of our own implementation.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
82 if (mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FULL_READ,
aeee5076f99f Use mailbox_sync() instead of our own implementation.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
83 STATUS_UIDVALIDITY, &status) < 0) {
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2238
diff changeset
84 client_send_storage_error(client);
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
85 break;
2092
952a4106d3b8 assert fix
Timo Sirainen <tss@iki.fi>
parents: 2039
diff changeset
86 }
2976
96a4ab34c8f1 Added pop3_uidl_format setting.
Timo Sirainen <tss@iki.fi>
parents: 2927
diff changeset
87 client->uid_validity = status.uidvalidity;
2092
952a4106d3b8 assert fix
Timo Sirainen <tss@iki.fi>
parents: 2039
diff changeset
88
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
89 t = mailbox_transaction_begin(client->mailbox, 0);
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
90 ctx = mailbox_search_init(t, search_args, NULL);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
91
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
92 client->last_seen = 0;
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
93 client->total_size = 0;
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
94 buffer_set_used_size(message_sizes_buf, 0);
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
95
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
96 failed = FALSE;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
97 mail = mail_alloc(t, MAIL_FETCH_VIRTUAL_SIZE, NULL);
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
98 while (mailbox_search_next(ctx, mail) > 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
99 if (mail_get_virtual_size(mail, &size) < 0) {
6312
05aabdc581b1 Fix to last change: Don't continue if we can't get message's size.
Timo Sirainen <tss@iki.fi>
parents: 6311
diff changeset
100 expunged = mail->expunged;
05aabdc581b1 Fix to last change: Don't continue if we can't get message's size.
Timo Sirainen <tss@iki.fi>
parents: 6311
diff changeset
101 failed = TRUE;
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
102 if (failed_uid == mail->uid) {
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
103 i_error("Getting size of message "
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
104 "UID=%u failed", mail->uid);
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
105 break;
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
106 }
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
107 failed_uid = mail->uid;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
108 break;
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
109 }
2621
c6cc163344c3 Added pop3_enable_last setting to enable deprecated LAST command.
Timo Sirainen <tss@iki.fi>
parents: 2525
diff changeset
110
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
111 if ((mail_get_flags(mail) & MAIL_SEEN) != 0)
2621
c6cc163344c3 Added pop3_enable_last setting to enable deprecated LAST command.
Timo Sirainen <tss@iki.fi>
parents: 2525
diff changeset
112 client->last_seen = mail->seq;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
113 client->total_size += size;
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
114
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
115 buffer_append(message_sizes_buf, &size, sizeof(size));
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
116 }
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
117 client->messages_count =
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
118 message_sizes_buf->used / sizeof(uoff_t);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
119
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
120 mail_free(&mail);
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
121 if (mailbox_search_deinit(&ctx) < 0 || (failed && !expunged)) {
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
122 client_send_storage_error(client);
6512
1a3604c8ee05 mailbox_transaction_commit*() doesn't sync the mailbox anymore, so it
Timo Sirainen <tss@iki.fi>
parents: 6463
diff changeset
123 (void)mailbox_transaction_commit(&t);
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
124 break;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
125 }
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
126
2010
01d2eb10a1c9 index wasn't unlocked initially
Timo Sirainen <tss@iki.fi>
parents: 1994
diff changeset
127 if (!failed) {
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
128 client->trans = t;
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
129 client->message_sizes =
6414
a6a49d5efc59 Changed buffer_free() and buffer_free_without_data() APIs to take ** pointer
Timo Sirainen <tss@iki.fi>
parents: 6411
diff changeset
130 buffer_free_without_data(&message_sizes_buf);
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
131 mail_search_args_unref(&search_args);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
132 return TRUE;
2010
01d2eb10a1c9 index wasn't unlocked initially
Timo Sirainen <tss@iki.fi>
parents: 1994
diff changeset
133 }
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
134
5761
8008fbb660c1 Even if mailbox sync fails, commit the transaction so that cache file gets
Timo Sirainen <tss@iki.fi>
parents: 5613
diff changeset
135 /* well, sync and try again. we might have cached virtual
8008fbb660c1 Even if mailbox sync fails, commit the transaction so that cache file gets
Timo Sirainen <tss@iki.fi>
parents: 5613
diff changeset
136 sizes, make sure they get committed. */
6512
1a3604c8ee05 mailbox_transaction_commit*() doesn't sync the mailbox anymore, so it
Timo Sirainen <tss@iki.fi>
parents: 6463
diff changeset
137 (void)mailbox_transaction_commit(&t);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
138 }
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
139 mail_search_args_unref(&search_args);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
140
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
141 if (expunged) {
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
142 client_send_line(client,
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
143 "-ERR [IN-USE] Couldn't sync mailbox.");
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
144 *error_r = "Can't sync mailbox: Messages keep getting expunged";
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
145 } else {
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
146 struct mail_storage *storage = client->inbox_ns->storage;
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
147 enum mail_error error;
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
148
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
149 *error_r = mail_storage_get_last_error(storage, &error);
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
150 }
6414
a6a49d5efc59 Changed buffer_free() and buffer_free_without_data() APIs to take ** pointer
Timo Sirainen <tss@iki.fi>
parents: 6411
diff changeset
151 buffer_free(&message_sizes_buf);
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
152 return FALSE;
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
153 }
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
154
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 7927
diff changeset
155 struct client *client_create(int fd_in, int fd_out, struct mail_user *user)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
156 {
5500
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
157 struct mail_storage *storage;
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
158 const char *inbox;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
159 struct client *client;
2039
f0925b2271e1 Added pop3_mails_keep_recent option. Fixed recent assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2020
diff changeset
160 enum mailbox_open_flags flags;
5178
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
161 const char *errmsg;
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
162 enum mail_error error;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
163
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
164 /* always use nonblocking I/O */
3960
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
165 net_set_nonblock(fd_in, TRUE);
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
166 net_set_nonblock(fd_out, TRUE);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
167
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
168 client = i_new(struct client, 1);
3960
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
169 client->fd_in = fd_in;
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
170 client->fd_out = fd_out;
6162
896cc473c1f0 Renamed i_stream_create_file() to i_stream_create_fd().
Timo Sirainen <tss@iki.fi>
parents: 6161
diff changeset
171 client->input = i_stream_create_fd(fd_in, MAX_INBUF_SIZE, FALSE);
6161
c62f7ee79446 Split o_stream_create_file() to _create_fd() and _create_fd_file().
Timo Sirainen <tss@iki.fi>
parents: 6142
diff changeset
172 client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
173 o_stream_set_flush_callback(client->output, client_output, client);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
174
3960
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
175 client->io = io_add(fd_in, IO_READ, client_input, client);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
176 client->last_input = ioloop_time;
7103
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
177 client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS,
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
178 client_idle_timeout, client);
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
179 if (!lock_session) {
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
180 client->to_commit = timeout_add(CLIENT_COMMIT_TIMEOUT_MSECS,
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
181 client_commit_timeout, client);
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
182 }
5500
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
183
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 7927
diff changeset
184 client->user = user;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
185
5500
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
186 inbox = "INBOX";
8082
db66611fd195 Added struct mail_user and fixed the code to support multiple users per process.
Timo Sirainen <tss@iki.fi>
parents: 7927
diff changeset
187 client->inbox_ns = mail_namespace_find(user->namespaces, &inbox);
5500
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
188 if (client->inbox_ns == NULL) {
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
189 client_send_line(client, "-ERR No INBOX namespace for user.");
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
190 client_destroy(client, "No INBOX namespace for user.");
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
191 return NULL;
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
192 }
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
193
4862cb37106c Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents: 5178
diff changeset
194 storage = client->inbox_ns->storage;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
195
8259
4dc07239ddfa pop3+maildir: Make sure virtual sizes always get written to dovecot-uidlist file.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
196 flags = MAILBOX_OPEN_POP3_SESSION;
2719
f8adc5cb2508 Renamed pop3_mails_keep_recent to pop3_no_flag_updates which includes
Timo Sirainen <tss@iki.fi>
parents: 2712
diff changeset
197 if (no_flag_updates)
2039
f0925b2271e1 Added pop3_mails_keep_recent option. Fixed recent assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2020
diff changeset
198 flags |= MAILBOX_OPEN_KEEP_RECENT;
4153
690c72358cd5 Added pop3_lock_session setting.
Timo Sirainen <tss@iki.fi>
parents: 4118
diff changeset
199 if (lock_session)
690c72358cd5 Added pop3_lock_session setting.
Timo Sirainen <tss@iki.fi>
parents: 4118
diff changeset
200 flags |= MAILBOX_OPEN_KEEP_LOCKED;
8468
d4eab639c253 mailbox_open() now takes struct mail_storage ** so it can be changed.
Timo Sirainen <tss@iki.fi>
parents: 8467
diff changeset
201 client->mailbox = mailbox_open(&storage, "INBOX", NULL, flags);
1363
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
202 if (client->mailbox == NULL) {
5178
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
203 errmsg = t_strdup_printf("Couldn't open INBOX: %s",
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
204 mail_storage_get_last_error(storage,
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
205 &error));
5178
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
206 i_error("%s", errmsg);
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
207 client_send_line(client, "-ERR [IN-USE] %s", errmsg);
bbe25ef34f03 If INBOX can't be opened, give better error messages. The reason is never
Timo Sirainen <tss@iki.fi>
parents: 5102
diff changeset
208 client_destroy(client, "Couldn't open INBOX");
1363
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
209 return NULL;
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
210 }
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
211
6311
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
212 if (!init_mailbox(client, &errmsg)) {
e84fad8d3987 Handle initial syncing errors better.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
213 i_error("Couldn't init INBOX: %s", errmsg);
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
214 client_destroy(client, "Mailbox init failed");
1363
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
215 return NULL;
383e4b9e347c Crashfix if there was some errors while opening mailbox
Timo Sirainen <tss@iki.fi>
parents: 1059
diff changeset
216 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
217
8745
22d70947597c pop3: Don't crash at startup if mailbox is empty.
Timo Sirainen <tss@iki.fi>
parents: 8723
diff changeset
218 if (!no_flag_updates && client->messages_count > 0)
8717
6f29380ba3a0 pop3: Track \Seen flag changes in a bitmask and do the changes at QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
219 client->seen_bitmask = i_malloc(MSGS_BITMASK_SIZE(client));
6f29380ba3a0 pop3: Track \Seen flag changes in a bitmask and do the changes at QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
220
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
221 i_assert(my_client == NULL);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
222 my_client = client;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
223
1646
a7c742b940e5 Added pop3 hooks
Timo Sirainen <tss@iki.fi>
parents: 1640
diff changeset
224 if (hook_client_created != NULL)
a7c742b940e5 Added pop3 hooks
Timo Sirainen <tss@iki.fi>
parents: 1640
diff changeset
225 hook_client_created(&client);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
226 return client;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
227 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
228
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
229 static const char *client_stats(struct client *client)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
230 {
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
231 static struct var_expand_table static_tab[] = {
8544
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
232 { 'p', NULL, "top_bytes" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
233 { 't', NULL, "top_count" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
234 { 'b', NULL, "retr_bytes" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
235 { 'r', NULL, "retr_count" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
236 { 'd', NULL, "deleted_count" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
237 { 'm', NULL, "message_count" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
238 { 's', NULL, "message_bytes" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
239 { 'i', NULL, "input" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
240 { 'o', NULL, "output" },
983d38de06c9 var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents: 8468
diff changeset
241 { '\0', NULL, NULL }
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
242 };
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
243 struct var_expand_table *tab;
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
244 string_t *str;
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
245
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
246 tab = t_malloc(sizeof(static_tab));
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
247 memcpy(tab, static_tab, sizeof(static_tab));
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
248
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
249 tab[0].value = dec2str(client->top_bytes);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
250 tab[1].value = dec2str(client->top_count);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
251 tab[2].value = dec2str(client->retr_bytes);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
252 tab[3].value = dec2str(client->retr_count);
4566
aa9109a17db6 Show number of actually expunged messages in logout message, instead of
Timo Sirainen <tss@iki.fi>
parents: 4153
diff changeset
253 tab[4].value = dec2str(client->expunged_count);
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
254 tab[5].value = dec2str(client->messages_count);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
255 tab[6].value = dec2str(client->total_size);
5979
433745f10290 Added %i and %o for input/output bytes to pop3_logout_format.
Timo Sirainen <tss@iki.fi>
parents: 5761
diff changeset
256 tab[7].value = dec2str(client->input->v_offset);
433745f10290 Added %i and %o for input/output bytes to pop3_logout_format.
Timo Sirainen <tss@iki.fi>
parents: 5761
diff changeset
257 tab[8].value = dec2str(client->output->offset);
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
258
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
259 str = t_str_new(128);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
260 var_expand(str, logout_format, tab);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
261 return str_c(str);
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
262 }
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
263
7453
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
264 static const char *client_get_disconnect_reason(struct client *client)
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
265 {
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
266 errno = client->input->stream_errno != 0 ?
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
267 client->input->stream_errno :
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
268 client->output->stream_errno;
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
269 return errno == 0 || errno == EPIPE ? "Connection closed" :
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
270 t_strdup_printf("Connection closed: %m");
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
271 }
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
272
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
273 void client_destroy(struct client *client, const char *reason)
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
274 {
8723
eaffedbc23f2 pop3: Fix to previous changes: Update \Seen flags even when not using QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8718
diff changeset
275 if (client->seen_change_count > 0)
eaffedbc23f2 pop3: Fix to previous changes: Update \Seen flags even when not using QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8718
diff changeset
276 client_update_mails(client);
eaffedbc23f2 pop3: Fix to previous changes: Update \Seen flags even when not using QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8718
diff changeset
277
4096
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
278 if (!client->disconnected) {
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
279 if (reason == NULL)
7453
3353ddd8ac9f If remote disconnects, log "Connection closed: reason" just like IMAP does.
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
280 reason = client_get_disconnect_reason(client);
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
281 i_info("%s %s", reason, client_stats(client));
4096
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
282 }
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
283
2502
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
284 if (client->cmd != NULL) {
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
285 /* deinitialize command */
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
286 i_stream_close(client->input);
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
287 o_stream_close(client->output);
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
288 client->cmd(client);
2695
Timo Sirainen <tss@iki.fi>
parents: 2665
diff changeset
289 i_assert(client->cmd == NULL);
2502
e628e0ab8924 Deinitialize pop3 commands if connection is closed unexpectedly.
Timo Sirainen <tss@iki.fi>
parents: 2494
diff changeset
290 }
5102
f8c2cf9e3267 Commit the transaction even if client didn't QUIT so cached data gets saved.
Timo Sirainen <tss@iki.fi>
parents: 5091
diff changeset
291 if (client->trans != NULL) {
f8c2cf9e3267 Commit the transaction even if client didn't QUIT so cached data gets saved.
Timo Sirainen <tss@iki.fi>
parents: 5091
diff changeset
292 /* client didn't QUIT, but we still want to save any changes
f8c2cf9e3267 Commit the transaction even if client didn't QUIT so cached data gets saved.
Timo Sirainen <tss@iki.fi>
parents: 5091
diff changeset
293 done in this transaction. especially the cached virtual
f8c2cf9e3267 Commit the transaction even if client didn't QUIT so cached data gets saved.
Timo Sirainen <tss@iki.fi>
parents: 5091
diff changeset
294 message sizes. */
6512
1a3604c8ee05 mailbox_transaction_commit*() doesn't sync the mailbox anymore, so it
Timo Sirainen <tss@iki.fi>
parents: 6463
diff changeset
295 (void)mailbox_transaction_commit(&client->trans);
5102
f8c2cf9e3267 Commit the transaction even if client didn't QUIT so cached data gets saved.
Timo Sirainen <tss@iki.fi>
parents: 5091
diff changeset
296 }
2722
8c5bcd6585a4 Use only a single transaction for the whole duration of pop3 session. Avoids
Timo Sirainen <tss@iki.fi>
parents: 2719
diff changeset
297 if (client->mailbox != NULL)
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
298 mailbox_close(&client->mailbox);
8467
03c418eadc8b mail_user_*() now handles home directory lookups when necessary.
Timo Sirainen <tss@iki.fi>
parents: 8259
diff changeset
299 mail_user_unref(&client->user);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
300
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
301 i_free(client->message_sizes);
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
302 i_free(client->deleted_bitmask);
8717
6f29380ba3a0 pop3: Track \Seen flag changes in a bitmask and do the changes at QUIT.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
303 i_free(client->seen_bitmask);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
304
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
305 if (client->io != NULL)
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
306 io_remove(&client->io);
7103
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
307 timeout_remove(&client->to_idle);
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
308 if (client->to_commit != NULL)
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
309 timeout_remove(&client->to_commit);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
310
4070
71b8faa84ec6 Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents: 3970
diff changeset
311 i_stream_destroy(&client->input);
71b8faa84ec6 Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents: 3970
diff changeset
312 o_stream_destroy(&client->output);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
313
3960
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
314 if (close(client->fd_in) < 0)
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
315 i_error("close(client in) failed: %m");
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
316 if (client->fd_in != client->fd_out) {
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
317 if (close(client->fd_out) < 0)
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
318 i_error("close(client out) failed: %m");
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
319 }
aeb424e64f24 Call io_remove() before closing the fd. It's required by kqueue.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
320
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
321 i_free(client);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 /* quit the program */
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 my_client = NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325 io_loop_stop(ioloop);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
327
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
328 void client_disconnect(struct client *client, const char *reason)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
329 {
4096
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
330 if (client->disconnected)
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
331 return;
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
332
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
333 client->disconnected = TRUE;
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
334 i_info("Disconnected: %s %s", reason, client_stats(client));
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
335
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
336 (void)o_stream_flush(client->output);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
338 i_stream_close(client->input);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
339 o_stream_close(client->output);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
340 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
342 int client_send_line(struct client *client, const char *fmt, ...)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344 va_list va;
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
345 ssize_t ret;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347 if (client->output->closed)
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
348 return -1;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
349
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
350 va_start(va, fmt);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
351
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7103
diff changeset
352 T_BEGIN {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
353 string_t *str;
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
354
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
355 str = t_str_new(256);
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
356 str_vprintfa(str, fmt, va);
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
357 str_append(str, "\r\n");
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
358
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
359 ret = o_stream_send(client->output,
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
360 str_data(str), str_len(str));
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
361 i_assert(ret < 0 || (size_t)ret == str_len(str));
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7103
diff changeset
362 } T_END;
2735
25113dcc9705 Crashfix
Timo Sirainen <tss@iki.fi>
parents: 2722
diff changeset
363 if (ret >= 0) {
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
364 if (o_stream_get_buffer_used_size(client->output) <
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
365 OUTBUF_THROTTLE_SIZE) {
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
366 ret = 1;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
367 client->last_output = ioloop_time;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
368 } else {
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
369 ret = 0;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
370 if (client->io != NULL) {
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
371 /* no more input until client has read
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
372 our output */
3879
928229f8b3e6 deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents: 3863
diff changeset
373 io_remove(&client->io);
3352
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
374
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
375 /* If someone happens to flush output,
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
376 we want to get our IO handler back in
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
377 flush callback */
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
378 o_stream_set_flush_pending(client->output,
75cfcf7736a7 Connection could have gotten stuck sometimes, doing nothing until idle
Timo Sirainen <tss@iki.fi>
parents: 3336
diff changeset
379 TRUE);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
380 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
381 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
382 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
383
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
384 va_end(va);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
385 return (int)ret;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
386 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
387
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
388 void client_send_storage_error(struct client *client)
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
389 {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
390 enum mail_error error;
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
391
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1845
diff changeset
392 if (mailbox_is_inconsistent(client->mailbox)) {
1415
c1a7da406bbd Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents: 1412
diff changeset
393 client_send_line(client, "-ERR Mailbox is in inconsistent "
c1a7da406bbd Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents: 1412
diff changeset
394 "state, please relogin.");
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
395 client_disconnect(client, "Mailbox is in inconsistent state.");
1415
c1a7da406bbd Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents: 1412
diff changeset
396 return;
c1a7da406bbd Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents: 1412
diff changeset
397 }
c1a7da406bbd Handle inconsistency error separately.
Timo Sirainen <tss@iki.fi>
parents: 1412
diff changeset
398
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
399 client_send_line(client, "-ERR %s",
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
400 mail_storage_get_last_error(client->inbox_ns->storage,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5608
diff changeset
401 &error));
1044
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
402 }
50d258907c99 Read the sizes of all messages to memory at startup. More failsafe and
Timo Sirainen <tss@iki.fi>
parents: 1043
diff changeset
403
7927
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
404 bool client_handle_input(struct client *client)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
405 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 char *line, *args;
3469
7e39590da48a Call t_push/t_pop around client command execution function, so if client
Timo Sirainen <tss@iki.fi>
parents: 3441
diff changeset
407 int ret;
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
408
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
409 o_stream_cork(client->output);
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
410 while (!client->output->closed &&
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
411 (line = i_stream_next_line(client->input)) != NULL) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 args = strchr(line, ' ');
4816
8ac2a2d27364 Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents: 4566
diff changeset
413 if (args != NULL)
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
414 *args++ = '\0';
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7103
diff changeset
416 T_BEGIN {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
417 ret = client_command_execute(client, line,
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6652
diff changeset
418 args != NULL ? args : "");
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7103
diff changeset
419 } T_END;
3469
7e39590da48a Call t_push/t_pop around client command execution function, so if client
Timo Sirainen <tss@iki.fi>
parents: 3441
diff changeset
420 if (ret >= 0) {
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1053
diff changeset
421 client->bad_counter = 0;
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
422 if (client->cmd != NULL) {
3336
a3a72d5bdfce o_stream_uncork() was previously always setting IO_WRITE handler even if
Timo Sirainen <tss@iki.fi>
parents: 3260
diff changeset
423 o_stream_set_flush_pending(client->output,
a3a72d5bdfce o_stream_uncork() was previously always setting IO_WRITE handler even if
Timo Sirainen <tss@iki.fi>
parents: 3260
diff changeset
424 TRUE);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
425 client->waiting_input = TRUE;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
426 break;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
427 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
428 } else if (++client->bad_counter > CLIENT_MAX_BAD_COMMANDS) {
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1053
diff changeset
429 client_send_line(client, "-ERR Too many bad commands.");
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
430 client_disconnect(client, "Too many bad commands.");
1056
a9b499b2611e Disconnect after too many bad commands. We also crashed if there were no
Timo Sirainen <tss@iki.fi>
parents: 1053
diff changeset
431 }
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432 }
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
433 o_stream_uncork(client->output);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434
7927
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
435 if (client->output->closed) {
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
436 client_destroy(client, NULL);
7927
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
437 return FALSE;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
438 }
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
439 return TRUE;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
440 }
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
441
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
442 static void client_input(struct client *client)
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
443 {
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
444 if (client->cmd != NULL) {
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
445 /* we're still processing a command. wait until it's
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
446 finished. */
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
447 io_remove(&client->io);
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
448 client->waiting_input = TRUE;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
449 return;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
450 }
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
451
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
452 client->waiting_input = FALSE;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
453 client->last_input = ioloop_time;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
454 timeout_reset(client->to_idle);
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
455 if (client->to_commit != NULL)
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
456 timeout_reset(client->to_commit);
7927
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
457
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
458 switch (i_stream_read(client->input)) {
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
459 case -1:
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
460 /* disconnected */
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
461 client_destroy(client, NULL);
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
462 return;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
463 case -2:
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
464 /* line too long, kill it */
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
465 client_send_line(client, "-ERR Input line too long.");
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
466 client_destroy(client, "Input line too long");
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
467 return;
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
468 }
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
469
2351a81ce699 If commands are pipelined after the login command, pass them to the
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
470 (void)client_handle_input(client);
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
471 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
472
4907
5b4c9b20eba0 Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents: 4848
diff changeset
473 static int client_output(struct client *client)
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
474 {
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
475 int ret;
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
476
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
477 if ((ret = o_stream_flush(client->output)) < 0) {
3384
3b75956d20c4 Added configurable logging for login process. Added configurable pop3 logout
Timo Sirainen <tss@iki.fi>
parents: 3372
diff changeset
478 client_destroy(client, NULL);
2790
02c0b8d532c2 Changed ostream's flush callback to have return value which can tell if
Timo Sirainen <tss@iki.fi>
parents: 2735
diff changeset
479 return 1;
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
480 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
481
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
482 client->last_output = ioloop_time;
7103
284dd5f2777d Use separate idle timeouts to avoid unneededly checking them every n seconds.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
483 timeout_reset(client->to_idle);
8718
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
484 if (client->to_commit != NULL)
ea9a186d64f9 pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
Timo Sirainen <tss@iki.fi>
parents: 8717
diff changeset
485 timeout_reset(client->to_commit);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
486
3394
30099e1ccf97 Small optimization
Timo Sirainen <tss@iki.fi>
parents: 3391
diff changeset
487 if (client->cmd != NULL) {
30099e1ccf97 Small optimization
Timo Sirainen <tss@iki.fi>
parents: 3391
diff changeset
488 o_stream_cork(client->output);
2494
a2e2c76021b9 Fixes for nonblocking changes.
Timo Sirainen <tss@iki.fi>
parents: 2421
diff changeset
489 client->cmd(client);
3394
30099e1ccf97 Small optimization
Timo Sirainen <tss@iki.fi>
parents: 3391
diff changeset
490 o_stream_uncork(client->output);
30099e1ccf97 Small optimization
Timo Sirainen <tss@iki.fi>
parents: 3391
diff changeset
491 }
2494
a2e2c76021b9 Fixes for nonblocking changes.
Timo Sirainen <tss@iki.fi>
parents: 2421
diff changeset
492
3391
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
493 if (client->cmd == NULL) {
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
494 if (o_stream_get_buffer_used_size(client->output) <
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
495 OUTBUF_THROTTLE_SIZE/2 && client->io == NULL) {
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
496 /* enable input again */
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
497 client->io = io_add(i_stream_get_fd(client->input),
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
498 IO_READ, client_input, client);
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
499 }
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
500 if (client->io != NULL && client->waiting_input)
d01de9d362c1 Code cleanup. Removed useless previous "fix".
Timo Sirainen <tss@iki.fi>
parents: 3384
diff changeset
501 client_input(client);
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
502 }
2494
a2e2c76021b9 Fixes for nonblocking changes.
Timo Sirainen <tss@iki.fi>
parents: 2421
diff changeset
503
9623
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
504 if (client->cmd != NULL) {
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
505 /* command not finished yet */
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
506 return 0;
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
507 } else if (client->io == NULL) {
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
508 /* data still in output buffer, get back here to add IO */
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
509 return 0;
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
510 } else {
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
511 return 1;
b2d30a8d3fb4 pop3: Fixed a potential hang.
Timo Sirainen <tss@iki.fi>
parents: 9532
diff changeset
512 }
2421
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
513 }
d141e1bfdd63 We never do blocking reads/writes to network anymore. Changed imap and pop3
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
514
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
515 void clients_init(void)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
516 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
517 my_client = NULL;
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
518 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
519
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
520 void clients_deinit(void)
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
521 {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
522 if (my_client != NULL) {
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
523 client_send_line(my_client, "-ERR Server shutting down.");
4096
904c53275e83 Log a line when IMAP client disconnects with a reason why it happened.
Timo Sirainen <tss@iki.fi>
parents: 4070
diff changeset
524 client_destroy(my_client, "Server shutting down");
1043
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
525 }
cacabd33c68a Initial code for POP3 server. RETR isn't working right yet, there's some
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
526 }