Commit b2291f98 b2291f9867971c78193eff58135f190dfd93818f by Sergey Poznyakoff

Do not wait for 'DONE' command longer than timeout seconds.

1 parent a2868695
...@@ -21,6 +21,7 @@ int ...@@ -21,6 +21,7 @@ int
21 imap4d_idle (struct imap4d_command *command, char *arg) 21 imap4d_idle (struct imap4d_command *command, char *arg)
22 { 22 {
23 char *sp; 23 char *sp;
24 time_t start;
24 25
25 if (util_getword (arg, &sp)) 26 if (util_getword (arg, &sp))
26 return util_finish (command, RESP_BAD, "Too many args"); 27 return util_finish (command, RESP_BAD, "Too many args");
...@@ -31,6 +32,7 @@ imap4d_idle (struct imap4d_command *command, char *arg) ...@@ -31,6 +32,7 @@ imap4d_idle (struct imap4d_command *command, char *arg)
31 util_send ("+ idling\r\n"); 32 util_send ("+ idling\r\n");
32 util_flush_output (); 33 util_flush_output ();
33 34
35 start = time (NULL);
34 while (1) 36 while (1)
35 { 37 {
36 if (util_wait_input (5)) 38 if (util_wait_input (5))
...@@ -46,6 +48,8 @@ imap4d_idle (struct imap4d_command *command, char *arg) ...@@ -46,6 +48,8 @@ imap4d_idle (struct imap4d_command *command, char *arg)
46 if (rc) 48 if (rc)
47 break; 49 break;
48 } 50 }
51 else if (time (NULL) - start > daemon_param.timeout)
52 imap4d_bye (ERR_TIMEOUT);
49 53
50 imap4d_sync (); 54 imap4d_sync ();
51 util_flush_output (); 55 util_flush_output ();
......