~ubuntu-branches/ubuntu/raring/postfix/raring

« back to all changes in this revision

Viewing changes to src/smtp/smtp_trouble.c

Tags: upstream-2.2.6
ImportĀ upstreamĀ versionĀ 2.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
/*      record why the host is being skipped; soft error, final server:
61
61
/*      defer delivery of all remaining recipients and mark the destination
62
62
/*      as problematic; hard error: bounce all remaining recipients.
 
63
/*      The session is marked as "do not cache".
63
64
/*      The result is non-zero.
64
65
/*
65
66
/*      smtp_mesg_fail() handles the case where the smtp server
86
87
/*      The policy is: non-final server: log an informational record
87
88
/*      with the reason why the host is being skipped; final server:
88
89
/*      defer delivery of all remaining recipients.
 
90
/*      The session is marked as "do not cache".
89
91
/*      The result is non-zero.
90
92
/* DIAGNOSTICS
91
93
/*      Panic: unknown exception code.
136
138
 
137
139
/* smtp_check_code - check response code */
138
140
 
139
 
static void smtp_check_code(SMTP_STATE *state, int code)
 
141
static void smtp_check_code(SMTP_SESSION *session, int code)
140
142
{
141
143
 
142
144
    /*
152
154
    if ((!SMTP_SOFT(code) && !SMTP_HARD(code))
153
155
        || code == 555                  /* RFC 1869, section 6.1. */
154
156
        || (code >= 500 && code < 510))
155
 
        state->error_mask |= MAIL_ERROR_PROTOCOL;
 
157
        session->error_mask |= MAIL_ERROR_PROTOCOL;
156
158
}
157
159
 
158
160
/* smtp_site_fail - skip site, defer or bounce all recipients */
214
216
        if (soft_error && request->hop_status == 0)
215
217
            request->hop_status = mystrdup(vstring_str(why));
216
218
    }
217
 
    smtp_check_code(state, code);
 
219
    if (session)
 
220
        smtp_check_code(session, code);
 
221
 
 
222
    /*
 
223
     * Don't cache this session. We can't talk to this server.
 
224
     */
 
225
    if (session)
 
226
        session->reuse_count = 0;
218
227
 
219
228
    /*
220
229
     * Cleanup.
271
280
            status = (soft_error ? defer_append : bounce_append)
272
281
                (DEL_REQ_TRACE_FLAGS(request->flags), request->queue_id,
273
282
                 rcpt->orig_addr, rcpt->address, rcpt->offset,
274
 
                 session->namaddr, request->arrival_time,
275
 
                 "%s", vstring_str(why));
 
283
                 session ? session->namaddr : "none",
 
284
                 request->arrival_time, "%s", vstring_str(why));
276
285
            if (status == 0)
277
286
                deliver_completed(state->src, rcpt->offset);
278
287
            SMTP_RCPT_DROP(state, rcpt);
279
288
            state->status |= status;
280
289
        }
281
290
    }
282
 
    smtp_check_code(state, code);
 
291
    if (session)
 
292
        smtp_check_code(session, code);
283
293
 
284
294
    /*
285
295
     * Cleanup.
334
344
        status = (soft_error ? vdefer_append : vbounce_append)
335
345
            (DEL_REQ_TRACE_FLAGS(request->flags), request->queue_id,
336
346
             rcpt->orig_addr, rcpt->address, rcpt->offset,
337
 
             session->namaddr, request->arrival_time, format, ap);
 
347
             session ? session->namaddr : "none",
 
348
             request->arrival_time, format, ap);
338
349
        va_end(ap);
339
350
        if (status == 0)
340
351
            deliver_completed(state->src, rcpt->offset);
341
352
        SMTP_RCPT_DROP(state, rcpt);
342
353
        state->status |= status;
343
354
    }
344
 
    smtp_check_code(state, code);
 
355
    if (session)
 
356
        smtp_check_code(session, code);
345
357
}
346
358
 
347
359
/* smtp_stream_except - defer domain after I/O problem */
355
367
    VSTRING *why = vstring_alloc(100);
356
368
 
357
369
    /*
 
370
     * Sanity check.
 
371
     */
 
372
    if (session == 0)
 
373
        msg_panic("smtp_stream_except: no session");
 
374
 
 
375
    /*
358
376
     * Initialize.
359
377
     */
360
378
    switch (code) {
368
386
        vstring_sprintf(why, "conversation with %s timed out while %s",
369
387
                        session->namaddr, description);
370
388
        break;
 
389
    case SMTP_ERR_PROTO:
 
390
        vstring_sprintf(why, "remote protocol error in reply from %s while %s",
 
391
                        session->namaddr, description);
 
392
        break;
371
393
    }
372
394
 
373
395
    /*
402
424
                                          "%s", vstring_str(why));
403
425
            SMTP_RCPT_DROP(state, rcpt);
404
426
        }
 
427
        /* XXX This assumes no fall-back relay. */
 
428
        if (request->hop_status == 0)
 
429
            request->hop_status = mystrdup(vstring_str(why));
405
430
    }
406
431
 
407
432
    /*
 
433
     * Don't attempt to cache this session.
 
434
     */
 
435
    session->reuse_count = 0;
 
436
 
 
437
    /*
408
438
     * Cleanup.
409
439
     */
410
440
    vstring_free(why);