@@ -131,6 +131,7 @@ const IMAP_COMMAND_HANDLER imap_handler_functions[] = {
131
131
static int imap4_tokenizer (ImapSession * , char * );
132
132
static int imap4 (ImapSession * );
133
133
static void imap_handle_input (ImapSession * );
134
+ static void imap_handle_abort (ImapSession * );
134
135
135
136
void imap_cleanup_deferred (gpointer data )
136
137
{
@@ -189,9 +190,11 @@ void socket_write_cb(int UNUSED fd, short UNUSED what, void *arg)
189
190
case CLIENTSTATE_QUIT_QUEUED :
190
191
break ; // ignore
191
192
case CLIENTSTATE_LOGOUT :
192
- case CLIENTSTATE_ERROR :
193
193
imap_session_bailout (session );
194
194
break ;
195
+ case CLIENTSTATE_ERROR :
196
+ imap_handle_abort (session );
197
+ break ;
195
198
default :
196
199
ci_write_cb (session -> ci );
197
200
break ;
@@ -213,8 +216,7 @@ void imap_cb_read(void *arg)
213
216
TRACE (TRACE_DEBUG ,"state [%d] enough %d: %" PRIu64 "/%" PRIu64 "" , state , enough , have , need );
214
217
215
218
if (state & CLIENT_ERR ) {
216
- dbmail_imap_session_set_state (session ,CLIENTSTATE_ERROR );
217
- imap_session_bailout (session );
219
+ imap_handle_abort (session );
218
220
} else if (state & CLIENT_EOF ) {
219
221
ci_cork (session -> ci );
220
222
if (enough )
@@ -275,29 +277,29 @@ static void imap_session_reset(ImapSession *session)
275
277
* only the main thread may write to the network event
276
278
* worker threads must use an async queue
277
279
*/
278
- static int64_t imap_session_printf (ImapSession * self , char * message , ...)
280
+ static int64_t imap_session_printf (ImapSession * session , char * message , ...)
279
281
{
280
282
va_list ap , cp ;
281
283
uint64_t l ;
282
284
int e = 0 ;
283
285
284
- p_string_truncate (self -> buff , 0 );
286
+ p_string_truncate (session -> buff , 0 );
285
287
286
288
assert (message );
287
289
va_start (ap , message );
288
290
va_copy (cp , ap );
289
- p_string_append_vprintf (self -> buff , message , cp );
291
+ p_string_append_vprintf (session -> buff , message , cp );
290
292
va_end (cp );
291
293
va_end (ap );
292
294
293
- if ((e = ci_write (self -> ci , (char * )p_string_str (self -> buff ))) < 0 ) {
295
+ if ((e = ci_write (session -> ci , (char * )p_string_str (session -> buff ))) < 0 ) {
294
296
TRACE (TRACE_DEBUG , "ci_write failed [%s]" , strerror (e ));
295
- dbmail_imap_session_set_state ( self , CLIENTSTATE_ERROR );
297
+ imap_handle_abort ( session );
296
298
return e ;
297
299
}
298
300
299
- l = p_string_len (self -> buff );
300
- p_string_truncate (self -> buff , 0 );
301
+ l = p_string_len (session -> buff );
302
+ p_string_truncate (session -> buff , 0 );
301
303
302
304
return (int64_t )l ;
303
305
}
@@ -360,7 +362,7 @@ static int checktag(const char *s)
360
362
return 1 ;
361
363
}
362
364
363
- static void imap_handle_abort (ImapSession * session )
365
+ void imap_handle_abort (ImapSession * session )
364
366
{
365
367
dbmail_imap_session_set_state (session ,CLIENTSTATE_ERROR ); /* fatal error occurred, kick this user */
366
368
imap_session_reset (session );
@@ -375,7 +377,7 @@ static void imap_handle_continue(ImapSession *session)
375
377
if ((e = ci_write (session -> ci , (char * )p_string_str (session -> buff ))) < 0 ) {
376
378
int serr = errno ;
377
379
TRACE (TRACE_DEBUG ,"ci_write returned error [%s]" , strerror (serr ));
378
- dbmail_imap_session_set_state (session , CLIENTSTATE_ERROR );
380
+ imap_handle_abort (session );
379
381
return ;
380
382
}
381
383
dbmail_imap_session_buff_clear (session );
@@ -493,8 +495,8 @@ void imap_handle_input(ImapSession *session)
493
495
if (l == 0 ) break ; // done
494
496
495
497
if (session -> error_count >= MAX_FAULTY_RESPONSES ) {
496
- dbmail_imap_session_set_state (session ,CLIENTSTATE_ERROR );
497
498
imap_session_printf (session , "* BYE [TRY RFC]\r\n" );
499
+ imap_handle_abort (session );
498
500
break ;
499
501
}
500
502
@@ -660,7 +662,7 @@ void _ic_cb_leave(gpointer data)
660
662
);
661
663
662
664
if (state & CLIENT_ERR ) {
663
- dbmail_imap_session_set_state (session , CLIENTSTATE_ERROR );
665
+ imap_handle_abort (session );
664
666
return ;
665
667
}
666
668
@@ -710,7 +712,7 @@ int imap4(ImapSession *session)
710
712
int j = 0 ;
711
713
712
714
if (! dm_db_ping ()) {
713
- dbmail_imap_session_set_state (session , CLIENTSTATE_ERROR );
715
+ imap_handle_abort (session );
714
716
return DM_EQUERY ;
715
717
}
716
718
0 commit comments