Postfix3.3.1
cleanup_final.c
[詳解]
1 /*++
2 /* NAME
3 /* cleanup_final 3
4 /* SUMMARY
5 /* finalize queue file
6 /* SYNOPSIS
7 /* #include "cleanup.h"
8 /*
9 /* void cleanup_final(state)
10 /* CLEANUP_STATE *state;
11 /* DESCRIPTION
12 /* cleanup_final() performs final queue file content (not
13 /* attribute) updates so that the file is ready to be closed.
14 /* LICENSE
15 /* .ad
16 /* .fi
17 /* The Secure Mailer license must be distributed with this software.
18 /* AUTHOR(S)
19 /* Wietse Venema
20 /* IBM T.J. Watson Research
21 /* P.O. Box 704
22 /* Yorktown Heights, NY 10598, USA
23 /*--*/
24 
25 /* System library. */
26 
27 #include <sys_defs.h>
28 #include <errno.h>
29 
30 /* Utility library. */
31 
32 #include <msg.h>
33 
34 /* Global library. */
35 
36 #include <cleanup_user.h>
37 #include <rec_type.h>
38 
39 /* Application-specific. */
40 
41 #include "cleanup.h"
42 
43 /* cleanup_final - final queue file content updates */
44 
46 {
47  const char *myname = "cleanup_final";
48 
49  /*
50  * vstream_fseek() would flush the buffer anyway, but the code just reads
51  * better if we flush first, because it makes seek error handling more
52  * straightforward.
53  */
54  if (vstream_fflush(state->dst)) {
55  if (errno == EFBIG) {
56  msg_warn("%s: queue file size limit exceeded", state->queue_id);
57  state->errs |= CLEANUP_STAT_SIZE;
58  } else {
59  msg_warn("%s: write queue file: %m", state->queue_id);
60  state->errs |= CLEANUP_STAT_WRITE;
61  }
62  return;
63  }
64 
65  /*
66  * Update the preliminary message size and count fields with the actual
67  * values.
68  */
69  if (vstream_fseek(state->dst, 0L, SEEK_SET) < 0)
70  msg_fatal("%s: vstream_fseek %s: %m", myname, cleanup_path);
72  (REC_TYPE_SIZE_CAST1) (state->xtra_offset - state->data_offset),
77  (REC_TYPE_SIZE_CAST6) state->smtputf8);
78 }
int smtputf8
Definition: cleanup.h:134
void cleanup_out_format(CLEANUP_STATE *state, int type, const char *fmt,...)
Definition: cleanup_out.c:155
#define REC_TYPE_SIZE_CAST3
Definition: rec_type.h:130
#define CLEANUP_STAT_SIZE
Definition: cleanup_user.h:59
#define REC_TYPE_SIZE_CAST2
Definition: rec_type.h:129
#define REC_TYPE_SIZE
Definition: rec_type.h:37
char * cleanup_path
Definition: cleanup_init.c:111
off_t xtra_offset
Definition: cleanup.h:78
#define REC_TYPE_SIZE_FORMAT
Definition: rec_type.h:127
void msg_warn(const char *fmt,...)
Definition: msg.c:215
char * queue_id
Definition: cleanup.h:56
NORETURN msg_fatal(const char *fmt,...)
Definition: msg.c:249
off_t vstream_fseek(VSTREAM *stream, off_t offset, int whence)
Definition: vstream.c:1093
VSTREAM * dst
Definition: cleanup.h:53
int vstream_fflush(VSTREAM *stream)
Definition: vstream.c:1257
off_t cont_length
Definition: cleanup.h:79
ssize_t rcpt_count
Definition: cleanup.h:88
#define REC_TYPE_SIZE_CAST4
Definition: rec_type.h:131
#define CLEANUP_STAT_WRITE
Definition: cleanup_user.h:58
void cleanup_final(CLEANUP_STATE *state)
Definition: cleanup_final.c:45
#define REC_TYPE_SIZE_CAST1
Definition: rec_type.h:128
#define REC_TYPE_SIZE_CAST5
Definition: rec_type.h:132
#define REC_TYPE_SIZE_CAST6
Definition: rec_type.h:133
off_t data_offset
Definition: cleanup.h:76
int qmgr_opts
Definition: cleanup.h:68