您的位置:首页 > 其它

6.9.2 qmgr_active_done函数:处理已存在的退信文件

2016-04-07 15:36 99 查看
从qmgr_active_done开始的一系列函数继续完成邮件延迟的处理工作:

qmgr_active_done_2_bounce_flush

qmgr_active_done_2_generic

qmgr_active_done_25_generic

qmgr_active_done_25_trace_flush

qmgr_active_done_3_defer_flush

qmgr_active_done_3_defer_warn

qmgr_active_done_3_generic

以上函数是按顺序调用的,但由于实际的工作是交给独立的bounce模块完成的,这些函数没有等待该模块的执行结果直接调用了下面的处理函数,所以它们与bounce模块的执行是“异步”的。

/qmgr/qmgr_active.c
256 /* qmgr_active_done - dispose ofmessage after recipients have been tried */
257
258 void   qmgr_active_done(QMGR_MESSAGE *message)
259 {
260    const char *myname = "qmgr_active_done";
261    struct stat st;
262
263    if (msg_verbose)
264        msg_info("%s: %s", myname, message->queue_id);
265
266    /*
267     * During a previous iteration, an attempt to bounce this message may
268     * have failed, so there may still be a bounce log lying around. XXX By
269     * groping around in the bounce queue, we're trespassing on the bounce
270     * service's territory. But doing so is more robust than depending on the
271     * bounce daemon to do the lookup for us, and for us to do the deleting
272     * after we have received a successful status from the bounce service.
273     * The bounce queue directory blocks are most likely in memory anyway. If
274     * these lookups become a performance problem we will have to build an
275     * in-core cache into the bounce daemon.
276     *
277     * Don't bounce when the bounce log is empty. The bounce processobviously
278     * failed, and the delivery agent will have requested that the message be
279     * deferred.
280     *
281     * Bounces are sent asynchronously to avoid stalling while the cleanup
282     * daemon waits for the qmgr to accept the "new mail" trigger.
283     *
284     * See also code in cleanup_bounce.c.
285     */
286    if (stat(mail_queue_path((VSTRING *) 0, MAIL_QUEUE_BOUNCE,message->queue_id), &st) == 0) {


286 如果已经存在退信文件,说明进行过发送退信的操作。

287        if (st.st_size == 0) {
288             if(mail_queue_remove(MAIL_QUEUE_BOUNCE, message->queue_id))
289                 msg_fatal("remove %s %s:%m",
290                           MAIL_QUEUE_BOUNCE,message->queue_id);


287-290 如果退信文件大小为0,说明退信文件无效,移除该文件。

291        } else {
292             if (msg_verbose)
293                 msg_info("%s: bounce %s",myname, message->queue_id);
294             if (message->verp_delims == 0|| var_verp_bounce_off)
295                abounce_flush(BOUNCE_FLAG_KEEP,
296                              message->queue_name,
297                              message->queue_id,
298                              message->encoding,
299                              message->smtputf8,
300                              message->sender,
301                              message->dsn_envid,
302                               message->dsn_ret,
303                              qmgr_active_done_2_bounce_flush,
304                               (void *)message);
305             else
306                abounce_flush_verp(BOUNCE_FLAG_KEEP,
//类似abounce_flush的参数
315                                      qmgr_active_done_2_bounce_flush,
317             return;
318        }
319    }


291-319如果退信文件大小不为0,根据是否存在XVERP命令连接符,也就是根据MAIL命令是否使用了XVERP扩展参数,分别用abounce_flush或abounce_flush_verp函数通过/global/abounce.c使用bounce模块发送退信。我们可以看到参数中的encoding、smtputf8、dsn_envid、dsn_ret等smtp协议扩展参数。
320
321    /*
322     * Asynchronous processing does not reach this point.
323     */
324    qmgr_active_done_2_generic(message);
325 }


324不存在退信文件的话,继续用qmgr_active_done_2_generic函数进行延迟处理。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: